New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bpo-46841: Quicken code in-place #31888
Conversation
It looks like this results in a 3% memory improvement across all benchmarks:
Ignore |
1% perf improvement too:
|
This is still marked as draft, what is left to do? |
There is still an awkward spot in I’m still trying to understand the code better and figure out a cleaner way of doing this. Any ideas? |
#31968 should help. |
I think it is OK to sort out the peculiarities of |
If you want to schedule another build, you need to add the " |
Buildbot failures are all pre-existing failures and unrelated to this PR. |
* Moves the bytecode to the end of the corresponding PyCodeObject, and quickens it in-place. * Removes the almost-always-unused co_varnames, co_freevars, and co_cellvars member caches * _PyOpcode_Deopt is a new mapping from all opcodes to their un-quickened forms. * _PyOpcode_InlineCacheEntries is renamed to _PyOpcode_Caches * _Py_IncrementCountAndMaybeQuicken is renamed to _PyCode_Warmup * _Py_Quicken is renamed to _PyCode_Quicken * _co_quickened is renamed to _co_code_adaptive (and is now a read-only memoryview). * Do not emit unused nonzero opargs anymore in the compiler.
This moves the bytecode to the end of the corresponding
PyCodeObject
, and quickens it in-place.Related changes:
PyCodeObject
is now more compact. I've removed the almost-always-unusedco_varnames
,co_freevars
, andco_cellvars
member caches, and rearranged someint
members to fill some holes in the struct on 64-bit builds.co_code
has been removed and replaced with_PyCode_GetCode
, andco_quickened
andco_firstinstr
have been replaced with_PyCode_CODE
._PyOpcode_Deopt
is a new mapping from all opcodes to their un-quickened forms._PyOpcode_InlineCacheEntries
is renamed to_PyOpcode_Caches
,_Py_IncrementCountAndMaybeQuicken
is renamed to_PyCode_Warmup
,_Py_Quicken
is renamed to_PyCode_Quicken
, and_co_quickened
is renamed to_co_code_adaptive
(and is now a read-onlymemoryview
).https://bugs.python.org/issue46841