[Python-Dev] tiny optimization in ceval mainloop

Skip Montanaro skip@pobox.com
Fri, 30 Aug 2002 10:41:49 -0500


    >> Opening another hole of a couple machine instructions shouldn't make
    >> much difference, although Py_MakePendingCalls should also be changed
    >> then to reset ticker to 0 in its "early exit because the coincidences
    >> I'm relying on haven't happened yet" cases.

    Guido> OK, let's try it then.

You mean I just wasted my time running pystones? ;-)

Just the same, here's the output, after and before.  For each setting, I ran
pystones twice manually, then the three reported times:

    with patch:

    Pystone(1.1) time for 50000 passes = 7.52
    This machine benchmarks at 6648.94 pystones/second
    Pystone(1.1) time for 50000 passes = 7.51
    This machine benchmarks at 6657.79 pystones/second
    Pystone(1.1) time for 50000 passes = 7.5
    This machine benchmarks at 6666.67 pystones/second


    without patch:

    Pystone(1.1) time for 50000 passes = 7.69
    This machine benchmarks at 6501.95 pystones/second
    Pystone(1.1) time for 50000 passes = 7.68
    This machine benchmarks at 6510.42 pystones/second
    Pystone(1.1) time for 50000 passes = 7.67
    This machine benchmarks at 6518.9 pystones/second

I was quite surprised at the difference.  Someone definitely should check
this.  The patch is at

    http://python.org/sf/602191

My guess is that the code is avoiding a lot of pointer dereferences.  Oh,
wait a minute.  I muffed a bit.  I initialized the ticker and checkinterval
variables to 100.  Should have been 10.

... a short time passes while Skip thanks God he's not rebuilding VTK ...

With _Py_CheckInterval set to 10 it's still not too shabby:

    Pystone(1.1) time for 50000 passes = 7.57
    This machine benchmarks at 6605.02 pystones/second
    Pystone(1.1) time for 50000 passes = 7.56
    This machine benchmarks at 6613.76 pystones/second
    Pystone(1.1) time for 50000 passes = 7.55
    This machine benchmarks at 6622.52 pystones/second

This is still without Jeremy's suggested change.

apples-and-oranges-ly, y'rs,

Skip