[pypy-dev] JIT'ed function performance degrades

Armin Rigo arigo at tunes.org
Fri Aug 20 11:31:58 CEST 2010


Hi Hart,

On Wed, Aug 18, 2010 at 06:25:02PM -0700, Hart's Antler wrote:
> I am starting to learn how to use the JIT, and i'm confused why my
> function gets slower over time, twice as slow after running for a few
> minutes.  Using a virtualizable did speed up my code, but it still has
> the degrading performance problem.  I have yesterdays SVN and using
> 64bit with boehm.  I understand boehm is slower, but overall my JIT'ed
> function is many times slower than un-jitted, is this expected
> behavior from boehm?

It seems that there are still issues with the 64-bit JIT -- it could be
something along the line of "the guards are not correctly overwritten",
or likely something more subtle along these lines, causing more and more
assembler to be produced.  We have observed "infinite"-looking memory
usage for long-running programs, too.

Note that in the example you posted, you are doing the common mistake of
putting some code (the looping condition) between can_enter_jit and
jit_merge_point.  We should really do something about checking that
people don't do that.  It mostly works, except in some cases where it
doesn't :-(  The issue is more precisely:

    while x < y:
        my_jit_driver.jit_merge_point(...)
        ...loop body...
        my_jit_driver.can_enter_jit(...)

In this case, the "x < y" is evaluated between can_enter_jit and
jit_merge_point, and that's the mistake.  You should rewrite your
examples as:

    while x < y:
        my_jit_driver.can_enter_jit(...)
        my_jit_driver.jit_merge_point(...)
        ...loop body...


A bientot,

Armin.



More information about the Pypy-dev mailing list