[Cython] Cython+PyPy benchmarks

Stefan Behnel stefan_ml at behnel.de
Thu Jul 5 19:36:28 CEST 2012


Hi,

I set up a Jenkins job to run a couple of (simple) benchmarks comparing
Cython's current performance under CPython and PyPy. Note that these are
C-API intensive benchmarks by design.

https://sage.math.washington.edu:8091/hudson/job/cython-devel-cybenchmarks-pypy/lastSuccessfulBuild/artifact/bench_chart.html

Basically, PyPy's cpyext is currently about 100-200x slower than CPython's
native C-API for these kinds of benchmarks. That's because it hasn't been
optimised in any way, correctness and completeness are still the main goals
in its development (and they're not there yet).

The one major performance issue in cpyext is currently the creation and
deallocation of the PyObject representation for each object, which
obviously has a huge impact on everything. I profiled the nbody benchmark
and it showed that almost 80% of the runtime is currently spent in creating
and discarding PyObject instances. Here's the call graph:

http://cython.org/callgrind-pypy-nbody.png

The up side of this is that there is likely a lot of low hanging fruit in
cpyext (plus some more tweaks in Cython), given that no optimisation at all
has been done so far. It shouldn't be too hard to drop the factor
substantially.

I also think we should add a couple of more C-ish benchmarks to see how
much overhead there really is for less C-API intensive code.

Stefan


More information about the cython-devel mailing list