I don't think we have a complete list of the modifications we've made
anywhere, but to my knowledge we haven't done too much. What comes to
mind is:
- There's feedback code in the eval loop that you will probably bump into
- We removed IMPORT_NAME and made it a builtin function, and then added it back
- In the future, I'm trying to add LOAD_METHOD and CALL_METHOD
- There's the recent WITH_CLEANUP and END_FINALLY changes
Reid
> Unladen does a lot of low-level optimizations right? It won't do any
> python-python inlining, last time I checked.
Not yet. But I have a patch that must be updated to trunk :-]
> Since unladen is no tracing JIT, it fails to optimize *those* situations.
Not necessarily. You just have to implement all those little optimizations.
> I wrote an optimizer once that inspects bytecode and does that sort of
> specialization and inlining.
I guess you are generating new code objects or change old ones. We do
not do that because we like to keep the complete CPython semantics, i.e.
a optimized program should behave exactly like normal (as long as you
don't touch a _* function).
In case of inlineing that means preserving all the stack frames and
being able to bail into the eval loop, even when in inlined code.
> In
> the function call benchmark, for instance, the python-python inlining
> practically removes the entire benchmark (because that specific one only
> calls no-op functions, so after inlining it's simply a for loop that
> does nothing).
That benchmark is only good for measuring the time the call code takes.
Anecdote: During my work P/P Inlineing that benchmark run with 20 times
faster or 20 times slower depending on how much was inlined.
> Is there any documentation on the changes made other than the source? A
> summary of differences in opcodes perhaps?
> Having a list of things to look out for would help wonders.
You can take a look at Python/import.c: There is a list of all opcode
changes.
Regards,
J�rg "ebo" Blank
I guess you are generating new code objects or change old ones.
> I wrote an optimizer once that inspects bytecode and does that sort of
> specialization and inlining.
We do
not do that because we like to keep the complete CPython semantics, i.e.
a optimized program should behave exactly like normal (as long as you
don't touch a _* function).
In case of inlineing that means preserving all the stack frames and
being able to bail into the eval loop, even when in inlined code.
That benchmark is only good for measuring the time the call code takes.
> In
> the function call benchmark, for instance, the python-python inlining
> practically removes the entire benchmark (because that specific one only
> calls no-op functions, so after inlining it's simply a for loop that
> does nothing).
Anecdote: During my work P/P Inlineing that benchmark run with 20 times
faster or 20 times slower depending on how much was inlined.
> Is there any documentation on the changes made other than the source? AYou can take a look at Python/import.c: There is a list of all opcode
> summary of differences in opcodes perhaps?
> Having a list of things to look out for would help wonders.
changes.
> Well, I would certainly not have a problem with messed up frames. I bet
> lots of people would be comfortable with the idea of slightly convoluted
> tracebacks when running optimized code.
There are more programs that look at such stuff than you might think.
This is likely true for code written with that in mind, but not for
'legacy code'.
> So you could consider it for -OO I guess ?
Nope, sry. While I generally encourage bytecode-hackery (see:
http://bitbucket.org/ebo/pyvm), for US this is entirely userspace,
nothing we want to implement.
Regards,
J�rg Blank