[pypy-dev] Loop invaraints

Armin Rigo arigo at tunes.org
Sun Aug 29 13:04:11 CEST 2010


Hi,

On Sat, Aug 28, 2010 at 03:05:11PM +0200, Hakan Ardo wrote:
> some time ago, there were some discussion about loop invaraints, but
> no conclusion.

A general answer to that question: there are two kinds of goals we can
have when optimizing.  One is to get the fastest possible code for small
Python loops, e.g. doing numerical computations.  The other is to get
reasonably good code for large and complicated loops, e.g. the dispatch
loop of some network application.  Although loop-invariant code motion
would definitely be great for the first kind of loops, it's unclear that
it helps on the second kind of loops.

As a similar consideration, I am thinking about trying to remove the
optimization that passes "virtuals" from one iteration of the loop to
the next one.  Although it has good effects on small loops, it has
actually a negative effect on large loops, because the loop taking
virtual arguments cannot be directly jumped to from the interpreter.

I'm not saying that loop-invariant code motion could also have a
negative effect on large loops; I think it's a pure win, so it's
probably worth a try.  I'm just giving a warning: it may not help much
in the case of a "general Python program doing lots of stuff", but only
in the case of small numerical computation loops.


A bientot,

Armin.



More information about the Pypy-dev mailing list