[Python-Dev] 1.6 speed

Christian Tismer tismer@tismer.com
Sun, 23 Apr 2000 16:43:10 +0200


Mark Hammond wrote:
> 
> > Python has been at a critical size with its main loop.
> > The recently added extra code exceeds this size.
> > I had the same effect with Stackless Python, and
> > I worked around it already.
> 
> OK - so let us in on your secret! :-)
> 
> Were your work-arounds specific to the stackless work, or could they be applied here?

My work-arounds originated from code from last January where
I was on a speed trip, but with the (usual) low interest
from Guido. Then, with Stackless I saw a minor speed loss
and finally came to the conclusion that I would be good to
apply my patches to my Python version.
That was nothing special so far, and Stackless was still a
bit slow. I though this came from the different way to
call functions for quite a long time, until I finally found
out this February:
The central loop of the Python interpreter is at a critical
size for caching. Speed depends very much on which code
gets near which other code, and how big the whole interpreter
loop is.
What I did:
- Un-inlined several code pieces again, back into functions
  in order to make the big switch smaller.
- simplified error handling, especially I ensured that all
  local error variables have very short lifetime and are
  optimized away
- simplified the big switch, tuned the why_code handling
  into special opcodes, therefore the whole things gets
  much simpler.

This reduces code size and therefore the probability
that we are in the cache, and due to short variable
lifetime and a simpler loop structure, the compiler
seems to do a better job of code ordering.

> Only-2-more-years-of-beating-up-Guido-before-stackless-time-ly,

Yup, and until then I will not apply my patches to Python,
this is part of my license: Use it but only *with* Stackless.

ciao - chris

-- 
Christian Tismer             :^)   <mailto:tismer@appliedbiometrics.com>
Applied Biometrics GmbH      :     Have a break! Take a ride on Python's
Kaunstr. 26                  :    *Starship* http://starship.python.net
14163 Berlin                 :     PGP key -> http://wwwkeys.pgp.net
PGP Fingerprint       E182 71C7 1A9D 66E9 9D15  D3CC D4D7 93E2 1FAE F6DF
     where do you want to jump today?   http://www.stackless.com