The PBC-VM is already working (or was, see below). On pystone, it runs about 50% of the speed of normally compiled code, and this applies to when it's both cold (50,000 passes) and hotspotted (500,000). I have not looked at anything else, for our use case, this is certainly fast enough. The implementation is in org.python.core.PyBytecode, plus support modules _marshal.java and pycimport.py.

We did not consider PyPy, it never occurred to me this was something you had done. In normal Java bytecode, we don't see these sort of dispatch issues. Instead it's attribute lookup, call path, and parts related to frame maintenance that seem to be the biggest issues. Again, not something that has been studied deeply. But we expect to do just that post 2.5.0.

Unfortunately, the PBC-VM is not working now. I was passing the entire regr test with it, as of the merge from the pbcvm branch, excluding some aspects around code introspection and differences in float reprs for CPython and Jython, but now there's something trivial breaking it. Looks I need to add a regression test that uses a well-known chunk of pyc to just verify that the calling conventions are fine.

Naturally, the PBC-VM will be much easier to test once we implement a PBC compiler. For the moment, we just use the pycimport module, which provides for an alternate load path.

- Jim

On Wed, Apr 22, 2009 at 1:17 PM, Antonio Cuni <anto.cuni@gmail.com> wrote:
Hi Jim,


Jim Baker wrote:
I'll address Jython: we plan support for Android in our 2.5.1 release. Supporting Android is similar to supporting unsigned applets: we either compile Python code in advance to Java bytecode, or compile it on the fly to Python bytecode (PBC) and execute with our PBC VM (just a straight port of ceval.c).

this is very interesting.  Is the PBC VM already working?  If so, how do its performances compare against the normally compiled code?

I and Niko did some benchmarking on pypy-jvm and we discovered that we spent (unsurprisingly) the largest amount of time inside the main eval loop (up to 68% of the total on some benchmark, IIRC).  On average, the dispatch overhead is something like 50%.  Is it the same for jython?

Btw, did you consider the possibility of reusing the pypy eval loop instead of rewriting yet another one from scratch?

ciao,
Anto




--
Jim Baker
jbaker@zyasoft.com