3 ms·
How does the PyPy JIT compare to the JIT in the upcoming CPython 3.13?
by puzzledobserver 2y ago
How does the PyPy JIT compare to the JIT in the upcoming CPython 3.13?
- i80and 2y agoVery different technologies. The PyPy JIT is a tracing JIT where hot paths of execution are identified, then that specific path is compiled and optimized. Same as LuaJIT. The CPython JIT is a newer and less invasive technique called copy-and-patch[1]. It's a lot less powerful, but a lot easier to plug into an existing language implementation: known sequences of python bytecode are mapped to templates of machine code [1] https://en.wikipedia.org/wiki/Copy-and-patch https://en.wikipedia.org/wiki/Copy-and-patch
- AlotOfReading 2y agoI'm a bit surprised that copy-and-patch is "new". I remember writing a JIT framework that did something similar back in the aughts and I got the idea from reading docs that were already old then. I understand people at IBM were doing it industrially for Java bytecode in the late 90s under the name quasi-static compilation, and the DyC/Tempo folks were doing similar things over in C land under different names. There were some minor differences due to the technology of the day, but it was broadly similar. For example, explicitly building to IR was uncommon outside Java land and register scheduling didn't have a lot of choices to make. The Java stuff even allowed the template specializations to exist on other computers and be dynamically loaded and validated over the network, for thin-client reasons. Very cool for the early 2000s.
- chc4 2y agoTemplate JITs aren't new. Copy and patch is a specific scheme for automatically creating a template JIT by using relocations in order to generate templates from normal C++ code. That wikipedia page is just very bad.
- ris 2y agoRead the paper which fully explains the subtle cleverness that sets it apart: https://arxiv.org/abs/2011.13127 https://arxiv.org/abs/2011.13127