Don't quicken in-place. #338
Replies: 4 comments
-
It is important that quickening, if it happens at all, must occur on the first call. |
Beta Was this translation helpful? Give feedback.
-
I'm a bit worried that this will negatively impact startup time, due to needing to allocate and expand the bytecode and all debugging tables for every function's first call. It seems that the main issue here is memory bloat due to the debugging tables growing to accommodate more What's the estimated break-even point (% of code objects ever actually executed once) where this would result in memory savings over the current scheme? |
Beta Was this translation helpful? Give feedback.
-
We currently need to get the expanded bytecode during unmarshaling, so this shouldn't be worse; less data to fetch from disk, but an additional allocation and some copying.
Yes, #324 should cover it. But we need to implement that as well.
The break-even is about 65%, given that the bytecode with caches is about 3 times the compact form. |
Beta Was this translation helpful? Give feedback.
-
Can we collect stats about unused code objects? Not from benchmarks. Maybe Cinder knows this for the Instagram code? I imagine CLI apps might have lots of code that’s never run in any particular invocation. |
Beta Was this translation helpful? Give feedback.
-
Now that we are quickening in-place, I wonder if we shouldn't.
An alternative scheme would be to add back the
co_firstinstr
pointer, and originalco_code
bytes object.For functions,
co_firstinstr
would initially point to aQUICKEN
bytecode, to quicken without an additional test on each call.For classes and modules,
co_firstinstr
would point to the start of the code in theco_code
bytes object.There are a number of advantages:
QUICKEN
does the work of expanding the bytecode.Although there are also some disadvantages:
BINARY_OP_UNSPECIALIZED
andBINARY_SUBSCR_UNSPECIALIZED
bytecodes for quickened code when we want an unspecialized form of those operations, as the base forms would not skip the following cache.Cost analysis:
QUICKEN
bytecode does the job for us.The
QUICKEN
bytecodeThis would expand out the compact form into the form with caches, doing quickening at the same time.
It would then update the
co_firstinstr
and internal variables, and resume execution.Beta Was this translation helpful? Give feedback.
All reactions