RPython question about the lifetime of global state
Hi everyone, I am developing a new image blit system for Pygame 2.0 - the SDL2 edition. A blitter prototype project is maintained at https://bitbucket.org/llindstrom/blitter. The prototype implements a blit loop JIT; Pixel format specific blit code is generated dynamically as needed. The prototype is written in RPython as an interpreter for executing array copies. The JIT comes automatically from the RPython tool chain, of course. The prototype blitter is built as a stand-alone shared library with flags -Ojit --gcrootfinder=shadowstack. It has no Python dependencies. There are two entrypoint C functions, both decorated with rpython.rlib.entrypoint.entrypoint. Python side code uses CFFI to access the library. The library is initialized with a single call to rpython_startup_code at load time. The blitter library is meant to be an embedded interpreter, with initialize, configure, and execute functions. So my question, does the RPython tool chained explicitly support embedded interpreters? I ask because I have only seen secondary entry points used as callbacks into an interpreter (PyPy's cpyext interface). So I wish to confirm that the lifetime of an RPython global namespace, the JIT caches, and the garbage collector are that of the loaded library, and not just that of an entry point function call. Thanks in advance, Lenard Lindstrom
Hi Lenard, On 6 March 2014 07:16, Lenard Lindstrom <len-l@telus.net> wrote:
The prototype is written in RPython as an interpreter for executing array copies. The JIT comes automatically from the RPython tool chain, of course.
Cool :-) RPython can certainly be used in this way, although critics might rightfully argue that you're getting a very big framework around a very small piece of code. You're getting for free a JIT that knows all about optimizing temporary allocations and tons of other things typical in a dynamic language, none of which really applies in your case. As long as the interpreter to JIT is only of a few lines of source, I'd recommend to at least have a look at other libraries (LibJIT for example). It would come with a smaller footprint (in code size, in memory usage, and in warm-up time) for similar results. It only works if the interpreter to JIT is small or if you have tons of time on your hand :-)
So I wish to confirm that the lifetime of an RPython global namespace, the JIT caches, and the garbage collector are that of the loaded library, and not just that of an entry point function call.
Yes: it must be initialized only once, and then everything stays around. A bientôt, Armin.
participants (2)
-
Armin Rigo
-
Lenard Lindstrom