python / cpython

The Python programming language
https://www.python.org
Other
62.51k stars 30.01k forks source link

_overlapped room for improvement #84332

Open e963db72-c8db-4b8b-b0b5-71a12b2ef945 opened 4 years ago

e963db72-c8db-4b8b-b0b5-71a12b2ef945 commented 4 years ago
BPO 40151
Nosy @pfmoore, @tjguk, @zware, @zooba, @ariccio
PRs
  • python/cpython#19298
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields: ```python assignee = None closed_at = None created_at = labels = ['type-feature', '3.9', 'OS-windows'] title = '_overlapped room for improvement' updated_at = user = 'https://github.com/ariccio' ``` bugs.python.org fields: ```python activity = actor = 'steve.dower' assignee = 'none' closed = False closed_date = None closer = None components = ['Windows'] creation = creator = 'Alexander Riccio' dependencies = [] files = [] hgrepos = [] issue_num = 40151 keywords = ['patch'] message_count = 2.0 messages = ['365567', '365605'] nosy_count = 5.0 nosy_names = ['paul.moore', 'tim.golden', 'zach.ware', 'steve.dower', 'Alexander Riccio'] pr_nums = ['19298'] priority = 'normal' resolution = None stage = 'patch review' status = 'open' superseder = None type = 'enhancement' url = 'https://bugs.python.org/issue40151' versions = ['Python 3.9'] ```

    e963db72-c8db-4b8b-b0b5-71a12b2ef945 commented 4 years ago

    Similarly to bpo-40145, I've tweaked build options to reduce the size of the binary.

    This patch turns on (for release builds) Whole Program Optimization, MinSpace optimization, /Ob2 AnySuitable function inlining, /Zo (so that people can still debug it when lots of code has been optimized out), /OPT:REF dead code elimination, /OPT:ICF COMDAT folding, Link Time Code Generation, and DebugFull debugging information creation.

    For debug builds, it enables all of that, except instead of the MinSpace optimization, it's only /Ob2 with custom optimization. My intent is to not optimize any asserts or similar checks, while still getting the benefit of dead and duplicate code elimination.

    _overlapped.pyd 32 bit unimproved release size: 31KB _overlapped.pyd 32 bit improved release size: 29KB size reduction: -3KB % size reduction: 10%

    _overlapped_d.pyd 32 bit unimproved release size: 55KB _overlapped_d.pyd 32 bit improved release size: 34KB size reduction: -21KB % size reduction: 38%

    _overlapped.pyd 64 bit unimproved release size: 39KB _overlapped.pyd 64 bit improved release size: 36KB size reduction: -3KB % size reduction: 8%

    _overlapped_d.pyd 64 bit unimproved release size: 74KB _overlapped_d.pyd 64 bit improved release size: 41KB size reduction: -33KB % size reduction: 45%

    If this patch is merged, and all 7 million (estimated) Python developers update their installation, I calculate that I just saved the PSF 21GB worth of bandwidth costs :)

    zooba commented 4 years ago

    While you're working on these, the most important comparison to make is against the binaries from our 64-bit release. We've run PGO on those, and from the stats shown it optimises almost everything for size already. (You can enable the same profile by running "build.bat --pgo".)

    For debug builds, I would prefer to optimise for (re)compile time. We can accept larger binaries in that case.