Adapting CPython for yk, a tool that adds JIT compilers to C interpreters
The author describes adapting CPython 3.15.1, the reference Python interpreter, for yk, a tool that adds a JIT compiler[1] to C interpreters. The adapted version is called ykcpython, and the post walks through the steps taken; the author says the code added totals just under 450 lines.
On the AWFY benchmark suite, run on a 64-core AMD EPYC 7773X machine, ykcpython is faster than normal CPython on every benchmark except DeltaBlue, where it is about 2.5% slower. It is faster than CPython with its experimental JIT on 8 of 13 benchmarks. The author stresses that ykcpython is not ready for use and that results on a wider set of programs will not match these numbers. The work on ykcpython took roughly 3-4 days, after a separate week and a half of general yk bug fixes.
The first version was much slower than expected. The cause was quickening[2], a technique that rewrites generic opcodes into faster specialised ones; each switch between the two forms discarded the associated trace[3] and created a new one, and in most cases traces were not used long enough to pay back the cost of creating them.
Read the original tratt.netDiscussion
Sources
-
tratt.net
Adapting CPython for Yk


