Tiers of Execution
Making CPython execute efficiently
Tiers
Each tier jumps to the next tier when code is sufficiently “hot”.
Nothing novel here. Just useful to have some terminology.
CPython today
Tier ~0.3
Compromise between memory use and speed.
Not well optimized for either.
Tier 0
Minimize start-up time and memory use, at expense of execution speed.
Support full set of features including sys.settrace
Should be able to execute from a .pyc file that it is mmapped and immutable.
Maybe 3.11, maybe later.
Tier 1
Adaptive, specializing interpreter.
Might not support all features, e.g. sys.settrace. Can fall back to Tier 0 if needed.
PEP 659
Planned for 3.11
Tiers 2 and 3
Entirely hypothetical at the moment.
“JIT” compilers.
Probably more like luajit than JVM, but I’m just guessing at this stage.
Optimization and Deoptimization
In the JVM, PyPy and other adaptive VMs, switching between tiers can be expensive.
We plan to make it cheap, by having the same in-memory data layout for all tiers.
This is desirable because: