[Python-Dev] Opcode frequency (original) (raw)
Antoine Pitrou solipsis at pitrou.net
Wed Jun 18 20:04:45 CEST 2008
- Previous message: [Python-Dev] Opcode frequency
- Next message: [Python-Dev] Opcode frequency
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hi,
Maciej Fijalkowski did an opcode analysis for PyPy, it also shows the relative frequency of opcodes following a specifc one:
Nice, but we have to be careful here: what is the tested workload? For example, I find it hard to believe that CALL_FUNCTION_VAR_KW would always (99%) be followed by STORE_FAST.
I'm not even sure we're talking about the same VM/compiler. What are CALL_LIKELY_BUILTIN and LOOKUP_METHOD? :-)
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 JUMP_IF_{TRUE,FALSE} and POP_TOP. 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:
JUMP_IF_FALSE <branch_for_false>
POP_TOP
[... do stuff and then ...]
JUMP_FORWARD <branch_for_false_after_pop_top>branch_for_false: POP_TOP branch_for_false_after_pop_top: [etc.]
With a JUMP_IF_FALSE which also pops the pop of the stack, this gives:
JUMP_IF_FALSE <branch_for_false>
[... do stuff and then ...]branch_for_false: [etc.]
Prediction doesn't help you in this case.
(*) http://bugs.python.org/issue2459
Regards
Antoine.
- Previous message: [Python-Dev] Opcode frequency
- Next message: [Python-Dev] Opcode frequency
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]