During the past two weeks we invested some more efforts on the baseline performance of pypy-c. Some of the tweaks we did were just new ideas, and others were based on actual profiling. The net outcome is that we now expect PyPy to be in the worst case twice as slow than CPython on real applications. Here are some small-to-medium-size benchmark results. The number is the execution time, normalized to 1.0 for CPython 2.4:
- 1.90 on templess (a simple templating language)
- 1.49 on gadfly (pure Python SQL database)
- 1.49 on translate.py (pypy's own translation toolchain)
- 1.44 on mako (another templating system)
- 1.21 on pystone
- 0.78 on richards
(This is all without the JIT, as usual. The JIT is not ready yet.)
You can build yourself a pypy-c with this kind of speed with the magic command line (gcrootfinder is only for a 32-bit Linux machine):
pypy/translator/goal/translate.py --gc=hybrid --gcrootfinder=asmgcc targetpypystandalone --allworkingmodules --faassen
The main improvements come from:
- A general shortcut for any operation between built-in objects: for example, a subtraction of two integers or floats now dispatches directly to the integer or float subtraction code, without looking up the '__sub__' in the class.
- A shortcut for getting attributes out of instances of user classes when the '__getattribute__' special method is not overridden.
- The so-called Hybrid Garbage Collector is now a three-generations collector. More about our GCs...
- Some profiling showed bad performance in our implementation of the built-in id() -- a trivial function to write in CPython, but a lot more fun when you have a moving GC and your object's real address can change.
- The bytecode compiler's parser had a very slow linear search algorithm that we replaced with a dictionary lookup.
These benchmarks are doing CPU-intensive operations. You can expect
a similar blog post soon about the I/O performance, as the
io-improvements branch gets closer to being merged
:-) The branch could also improve the speed of
string operations, as used e.g. by the templating systems.