Skip to content
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

Optimizing super().meth() via adaptive superinstructions #242

Closed
Fidget-Spinner opened this issue Jan 28, 2022 · 6 comments
Closed

Optimizing super().meth() via adaptive superinstructions #242

Fidget-Spinner opened this issue Jan 28, 2022 · 6 comments

Comments

@Fidget-Spinner
Copy link
Collaborator

Fidget-Spinner commented Jan 28, 2022

Please see #239 for the discussion and https://bugs.python.org/issue46564 for the BPO.

@Fidget-Spinner
Copy link
Collaborator Author

CPython PR is at python/cpython#30992.

@Fidget-Spinner
Copy link
Collaborator Author

@markshannon your 3.11 TODO reminded me that this is dead in the water. Do you think this will ever be worth it?

With the new inline cache infrastructure. It is easier to share caches across multiple instructions. But IMO the complexity involved makes it unpalatable.

For the record, the PR above measured no speedups in pyperformance, but in super() microbenchmarks, it saw super().meth() speeding up by nearly 2.2x. With super().meth() now only having a ~10% slowdown over self.meth() (basically, non-existent in the real world), versus a 2x slowdown previously. In fact, the new super.meth() is as fast as or even faster than pre-3.11 plain self.meth() calls thanks to caching of method lookups.

@gvanrossum
Copy link
Collaborator

Hi @Fidget-Spinner I'm a little confused about what you're saying at the end. I understand the PR (that won't ever be merged) saw a 2.2 speedup. After that, are you saying that in the main branch, super().meth() is now 10% slower than self.meth(), which is an improvement over that ratio for 3.10?

@Fidget-Spinner
Copy link
Collaborator Author

Fidget-Spinner commented Mar 15, 2022

@gvanrossum Sorry, I meant specifically in that PR, super().meth() is only 10% slower than self.meth(). In 3.10, super().meth() was around 2x slower than self.meth().

On main, it should still be around 2x slower. Although we optimized super() with vectorcall support, we also optimized self.meth() via specialization. Most likely the latter outstrips the former. I have yet to benchmark main recently.

@gvanrossum
Copy link
Collaborator

@Fidget-Spinner Do we still need this issue?

@Fidget-Spinner
Copy link
Collaborator Author

@gvanrossum Nope. Carl has has merged his version, so it's done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants