[Python-Dev] computed goto's in ceval loop
simon at arrowtheory.com
Wed Jan 18 04:56:12 CET 2006
I have been experimenting with replacing the big switch in ceval.c by
a computed goto construct . It uses #define's to make it optional.
This work was inspired by Mono's MINT interpreter code,
and Neil Norwitz's attempt to use a function pointer table .
Result: about 1% slower on the pystone benchmark.
It also seems to have broken the interpreter; at least one test fails (test_StringIO). Whoops.
Not sure if the other switch-speedup hacks (eg. PREDICT(op)) conflict
at all with this patch (ie. make it slower than it could be).
Mono uses a much larger opcode set, with 2-byte opcodes, that includes
type info in each opcode. This means that the actual case statements are much faster.
My initial thought about using computed goto's (January 2003) was that the python opcode cases
were much fatter than mono's (often involving a function call) so that the overhead of
branching on opcodes would be insignificant. It seems that this is true indeed.
The patch id is 1408710.
Simon Burton, B.Sc.
Licensed PO Box 8066
ANU Canberra 2601
Ph. 61 02 6249 6940
More information about the Python-Dev