Tracing JITs in the Real World CPython Core Dev Sprint
17 hours ago
- #JIT
- #Performance
- #CPython
- The CPython Core Dev Sprint in Cambridge hosted by ARM brought together ~50 core devs and guests, including the author.
- Three main focus areas were discussed: C API improvements leading to PyNI (Python Native Interface), colorful tab completions in Python REPL via fancycompleter, and JIT-related discussions.
- The author shared insights from working on PyPy's JIT, highlighting challenges like trace blockers and data-driven control flow that could affect CPython's JIT.
- CPython's JIT and PyPy's JIT are both tracing JITs, but CPython's faces unique challenges due to its reliance on C extensions and inability to trace through them.
- Performance reasoning becomes complex with JITs, as code speed can depend on unrelated parts of the program, making local optimizations less predictable.
- Data-driven control flow can lead to exponential code path explosions in tracing JITs, complicating optimization efforts.
- Generators and async code present optimization challenges for JITs, with explicit iterators sometimes outperforming generator-based approaches.
- Tooling and profiling support is lacking for JIT environments, making performance analysis and optimization more difficult.
- The potential for 'zero-cost abstractions' in JITs was highlighted, where temporary objects can be optimized away, improving performance.
- The author emphasized the importance of virtual objects and allocation removal optimizations for CPython's JIT development.