[pypy-dev] PyPy JIT & C extensions, greenlet

Armin Rigo arigo at tunes.org
Thu Sep 30 14:25:53 CEST 2010


Hi,

On Wed, Sep 29, 2010 at 11:39 PM, Andrew Francis <andrewfr_ice at yahoo.com> wrote:
> I talked briefly with Armin at EuroPython about Stackless and JIT.
> I poke around pypy-dev and use stackless.py. However I am very interested
> in learning about how the stackless transform works and how pypy works so
> I could help. I have been at Stackless for about five years now and I wouldn't mind
> spending a year learning pypy.

Maybe I should expand on an idea posted on #pypy by fijal.  He
mentioned that he would like to try to support Stackless in PyPy
without using the stackless transform, just by using the same
low-level stack hacks that are done by greenlet.c and optionally by
Stackless Python.  This means that there would be two different
approaches we can consider to support Stackless in PyPy:

    stackless transform (done)          C-level stack switching
    --------------------------------    --------------------------------

    approach from Stackless Python 1    approach from Stackless Python 2

    10-20% speed penalty in the         no speed penalty
    whole interpreter

    JIT support needed                  JIT supports comes for free
    (missing so far)

    fully portable                      needs a little bit of assembler

    some issues to integrate with       easy to integrate with C code
    non-PyPy C code

    tasklet-switching Python code       tasklet-switching Python code
    becomes a single loop in            becomes N loops with residual calls
    machine code                        to switch() functions
    (potentially very good)             (less good)


As you can see from the above summary, the main issue with the 2nd
approach would be that Python tasklet-switching loops do not turn into
a form that is as efficient as what we would get in the 1st approach.
Nevertheless it is an interesting approach because it makes basic JIT
support and integration easier.


A bientôt,

Armin.



More information about the Pypy-dev mailing list