"The geometric average of all benchmarks is 0.23 or 4.3 times faster than cpython" (see https://speed.pypy.org/ ) If we put this figure in context with the CLBG (see https://benchmarksgame-team.pages.debian.net/benchmarksgame/... ) we're somewhere between Racket and Dart. Is a further speedup to be expected? Why is it still slower than V8 after so much development effort?
PyPy: A Faster Python Implementation
11–20 of 25 posts
Re: PyPy: A Faster Python Implementation
#12"The geometric average of all benchmarks is 0.23 or 4.3 times faster than cpython" (see https://speed.pypy.org/ ) If we put this figure in context with the CLBG (see https://benchmarksgame-team.pages.debian.net/benchmarksgame/... ) we're somewhere between Racket and Dart. Is a further speedup to be expected? Why is it still slower than V8 after so much development effort?
Lots of discussion about obstacles to speeding up python in older threads, e.g. https://news.ycombinator.com/item?id=12025309
Re: PyPy: A Faster Python Implementation
#13I’ve heard PyPy’s JIT described as “meta-tracing - instead of tracing your code, it traces itself as it interprets your code”. Is that accurate? What are the pros & cons of this approach compared to a normal tracing JIT, e.g. LuaJIT?
About 15 years ago there was a series of papers by Andreas Gal (then future and now former CTO of Mozilla) about precisely this aspect of JIT-compilers design. If you have a program and represent it as a series of VM instructions, and you try to jit them individually the kit compiler has very limited ability for optimization. Plus, after each such instruction the execution comes back to the piece of the interpreter t…
It's not the dispatch to the next instruction that's expensive in most virtual machines. It's the sheer complexity of each instruction as it maps to the underlying assembly instructions [2]
Just getting rid of the dispatch loop doesn't help much and in many cases the increased pressure on the instruction cache makes performance worse.
I'm trying to help with this problem at the moment for the CRuby JIT compiler.
SpiderMonkey, LuaJIT and Dalvik record the trace in the bytecode interpreter. There's no generating baseline JITed code with additional trace recording stuff.
What PyPy does is quite different. PyPy is a Python virtual machine written in a language called RPython and has an interpreter and trace compiler for RPython.
It adds a whole layer of indirection compared to traditional trace compilers which makes it harder to do some optimizations but makes it easier to implement some more basic parts of trace recording and compilation and crucially, makes it somewhat re-usable for different languages.
[1] https://archive.org/details/optimizationofho00fish/mode/2up [2] https://www.sciencedirect.com/science/article/pii/S157106610...
Re: PyPy: A Faster Python Implementation
#14Re: PyPy: A Faster Python Implementation
#15Earlier quoted context omitted.
I suspect that the development effort that V8 has seen has been X orders of magnitude greater.
I have no detailed information. But the development of PyPy has been going on for 20 years and was partly sponsored by the EU. If you compare that with LuaJIT which was developed by a single person in a shorter timeframe and a performance even faster than V8 I would assume that maybe the conceptual approach taken by RPython/PyPy is less suited or Python is just that much harder to speedup. I would guess the former be…
Re: PyPy: A Faster Python Implementation
#16Earlier quoted context omitted.
I have no detailed information. But the development of PyPy has been going on for 20 years and was partly sponsored by the EU. If you compare that with LuaJIT which was developed by a single person in a shorter timeframe and a performance even faster than V8 I would assume that maybe the conceptual approach taken by RPython/PyPy is less suited or Python is just that much harder to speedup. I would guess the former be…
V8 became faster than LuaJIT quite some time ago now but LuaJIT is incredibly simple compared to V8.
Re: PyPy: A Faster Python Implementation
#17Re: PyPy: A Faster Python Implementation
#18What is stopping PyPy from getting more widespread adoption in the Python community? Surely it isn't that everyone is using the latest version of CPython; it's been years and many are still using 2.7.
Also it doesn't speed up things that rely on external C libraries, so code using numpy/scipy/tensorflow/etc doesn't generally run appreciably faster.
Re: PyPy: A Faster Python Implementation
#19What is stopping PyPy from getting more widespread adoption in the Python community? Surely it isn't that everyone is using the latest version of CPython; it's been years and many are still using 2.7.
Re: PyPy: A Faster Python Implementation
#20Earlier quoted context omitted.
V8 became faster than LuaJIT quite some time ago now but LuaJIT is incredibly simple compared to V8.
Are you sure? I did a cross-comparison recently and found LuaJIT still to be factor 1.3 to 1.5 faster than V8 in geometric mean (I used the Node.js implementation on the CLBG).
Anything more realistic involving actual object access, not even allocation, and V8 wins by large margins.
time luajit-2.1.0-beta3 nbody.lua 50000000 real 0m8.437s
time node nbody.js 50000000 real 0m5.065s