New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LOOKUP_METHOD and CALL_METHOD optimization #50283
Comments
This is an optimization ported from PyPy. [1] It tries to prevent bound [1] Test minimum run-time average run-time |
Can you give results of the "richards" benchmark? |
With the patch: Richards benchmark (Python) starting... [<function entry_point at 0x63b430>] Without: Richards benchmark (Python) starting... [<function entry_point at 0x637530>] |
Similar results here. Richards benchmark (Python) starting... [<function entry_point at Without the patch: Richards benchmark (Python) starting... [<function entry_point at |
One thing I was wondering about the current patch is what about objects class C(object):
def foo(self):
return 1
c = c()
print c.foo()
c.foo = lambda: 2
print c.foo() Shouldn't the above print 1 and 2? With the current patch, it seems There's also the possible performance drawback where you're loading I'm doing the same optimization for unladen swallow, and these were some |
Yes, my patch introduces that regression you mention. PyPy solves this |
I have an patch for unladen-swallow out for review here: It resolves the correctness issues I mentioned previously by emitting guards if necessary. If the type is predictable and uses slots, then we don't need to check the instance dict. It gives a 5% speedup on the unpickle benchmark. Presumably the other benchmarks do not do as many method calls. |
First, are these benchmark results jitted or non-jitted? Right now, non-jitted results are a stronger motivation for inclusion in main CPython, IMHO. Second, 2.7 won't receive any features / performance improvements anymore. It would be nice to have 3.2 (non-jitted) benchmark results. Third, if removing intermediate allocations is the kind of optimizations a JIT will do anyway, does it make sense or not to make these optimizations explicit at the bytecode level? (this is really an open question, not a rhetorical one) |
Sorry, I was just posting it so Benjamin could see what this bought us. I'm not pushing to get this in CPython. The results are for JITed code. I forget what the interpreted results are. I think they are good for the microbenchmarks, but not as good for the macro. |
Benjamin confirms a regression in his patch, and the other patch was not intended for CPython. So I'm closing this issue. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: