[Python-Dev] Opcode frequency (original) (raw)

Georg Brandl g.brandl at gmx.net
Wed Jun 18 21:45:07 CEST 2008


Antoine Pitrou schrieb:

Hi,

Maciej Fijalkowski did an opcode analysis for PyPy, it also shows the relative frequency of opcodes following a specifc one:

http://codespeak.net/svn/user/fijal/opcodes.txt Nice, but we have to be careful here: what is the tested workload? For example, I find it hard to believe that CALLFUNCTIONVARKW would always (99%) be followed by STOREFAST.

I'm sorry, I should have given a reference to the original message: http://codespeak.net/pipermail/pypy-dev/2008q2/004666.html

I'm not even sure we're talking about the same VM/compiler. What are CALLLIKELYBUILTIN and LOOKUPMETHOD? :-)

He used the PyPy compiler, of course.

Might it make sense to add more PREDICT()ions based on this, e.g. for BUILDSLICE -> BINARYSUBSCR? This particular one sounds fine, yes. Another approach is to create opcodes which better reflect actual usage. For example part of the following patch (*) was to create opcodes fusing JUMPIF{TRUE,FALSE} and POPTOP. This is because in most cases, you want to pop the comparison result regardless of its value (true or false), which nowadays produces the following kind of code: JUMPIFFALSE POPTOP [... do stuff and then ...] JUMPFORWARD branchforfalse: POPTOP branchforfalseafterpoptop: [etc.] With a JUMPIFFALSE which also pops the pop of the stack, this gives: JUMPIFFALSE [... do stuff and then ...] branchforfalse: [etc.] Prediction doesn't help you in this case.

Agreed; is there a way for a JUMP to end up without popping the top after jumping? It would have to do a DUP first then.

Georg



More information about the Python-Dev mailing list