[pypy-dev] JIT slowdown on creating types

Armin Rigo arigo at tunes.org
Wed Jun 12 20:36:41 CEST 2013


Hi Vasily,

Sorry for the delay.

On Mon, Jun 3, 2013 at 12:08 PM, Vasily Evseenko <svpcom at gmail.com> wrote:
> When i dynamically create new type (for example classes nested to
> functions) I've got linear code slowdown:

It's a known bug, related to the approach we take for JITting.
Technically, it occurs because we write a guard about the exact class
of 'obj'.  When test() is called the 2nd time, the guard fails, and we
compile a new "bridge" (i.e. a new portion of machine code) that
starts with a guard that the class is, this time, the 2nd version.
This fails again at the next test() call, and so on.  In the end we
have 99 guards that fails (so 99 conditional jumps in machine code)
before we reach the working one.  It basically ends up as a switch,
but a very bad variant of a switch, doing linear search.

This bad case can occur in a lot of situations, but all of them
relatively rare.  We should still improve it.


A bientôt,

Armin.


More information about the pypy-dev mailing list