hn.today

Adapting CPython for Yk

tratt.net79 points6 comments
Screenshot of Adapting CPython for Yk

The work tests whether yk, a meta-tracing JIT that adds compilation to lightly modified C interpreters, can deliver gains in a large and complex system such as CPython. Rather than replacing Python’s interpreter, yk records its execution through hot loops, optimizes the resulting traces, and generates machine code. The adaptation ultimately used CPython’s tier 2 interpreter, an alternative implementation of core interpreter operations that also supports CPython’s experimental JIT. This proved a better fit than tier 1: CPython’s quickening repeatedly changes generic opcodes into specialized ones, and the initial approach discarded traces whenever those changes occurred, often before they could pay for themselves.

The resulting ykcpython required roughly 450 lines of changes, with about 80 lines for tier 2 support; the direct adaptation took three to four days, following a week and a half of fixing general yk bugs. On 13 AWFY benchmarks, ykcpython beat standard CPython in 12, and beat CPython with its experimental JIT in eight. It was especially fast on Mandelbrot, taking 4.20 seconds versus 6.94 for the experimental JIT and 11.66 for standard CPython. It lost to standard CPython only on DeltaBlue, by about 2.5%. These measurements use 30 process runs on a 64-core AMD EPYC system. The results show that yk can improve a large interpreter, but ykcpython is not ready for users, and benchmark gains do not guarantee similar results across real-world programs.

Read on tratt.net6 comments on Hacker News

Summary generated by AI from the linked article. hn.today is not affiliated with Hacker News or Y Combinator.

More in Programming

Ggml v1.0.0

Ggml v1.0.0

ggml 1.0.0 removes deprecated public APIs and legacy DIAG_MASK operations, while adding configurable YaRN truncation and FP8 support. It also improves backend performance with quantized matrix multiplication, fused MoE operations, and new attention and scheduling paths. (github.com)

The daily digest

Today's best Hacker News stories, summarized and screenshotted, one email a day.