125 points · by matt_d · 2y ago · 42 comments
I ask because z3 has been used for type inference (Typpete) and for solving equations written in Python.
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
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.
> (x & c1) | (x & c1) == x & (c1 | c2)
Is this a typo? Shoud the second c1 be c2 instead?
(llm's aren't involved, it's all based on z3)
I don't plan on implementing something like this for now, I'd rather take the inefficiencies and manually extract optimizations out of them and implement them in PyPy's jit.
AlphaZero-type systems were unable to significantly improve over near-optimal solvers such as z3.
Run the test suite, identify optimizations. One by one, make the the optimization change to the implementation as suggested by the LLM.
Instrument the changed methods on the second test run and see if runtime performance has changed. Verify that the test still passes.