The way to a faster python [was Python IS slow !]

Markus Kohler markus_kohler at hp.com
Tue May 4 11:48:12 EDT 1999


Christian Tismer wrote:
> 
> Markus Kohler wrote:
> >
> > Fredrik Lundh wrote:
> ...
> > > http://starship.skyport.net/crew/vlad/archive/threaded_code/
> > >
> >
> > I know.
> >
> > But it's not in the main release yet. Didn't  it improve
> > performance ?
> 
> When I look into MSVC++'s emitted code, the improvement
> would be neglectible. It already produces an indirect
> jump. Just the two insns which do a range check on the
> opcode could perhaps be saved.
> 

Could make a difference on some machines if the branches wouldn't 
predicted correctly. But you are probably right, it shouldn't be
a big difference. 

> AFAIK, direct threading would perform worse if not written
> in machine language, since everything would be turned
> into tiny procedure calls.

As I understand how threading was implemented in an early Squeak 
version, it worked without doing procedure calls. 
Actually the interpreter compiled the byte codes on the fly to the
addresses of the corresponding byte code routines. Then at the end
of each routine the instruction counter is increased and the next
address is used as an argument for goto(address). 
I think one key idea is not to share this code but to have it at the 
end of each byte code routine. 


> Interpreter optimizations seem to be a dead end, when
> comparing efforts with results.
> I could squeeze 8 per cent out of the interpreter by
> simply moving the argument extraction into the opcode,
> and doing this as a word, not shifting bytes. This
> worked for MSVC, but might be worse on other platforms.
> Mark Lemburg did did some optimizations which are
> orthogonal to that, so this could be combined.
> 
> But overall, the speed win isn't so big that it would
> be worth to modify the distribution.
> Must be a dramatic win, then perhaps.
> 

Agreed.

You may alse do a search for E. Miranda's "Brouhaha" Smalltalk compiler. 
It's  a paper about a Smalltalk compiler that was only 2-3 times slower
than the commercial Visualworks compiler, but worked without any
assembler
code. 


Markus
-- 
Markus Kohler  mailto:markus_kohler at hp.com




More information about the Python-list mailing list