GeezerVison is showing github.com — GH-100288: Specialize class attribute loads by brandtbucher · Pull Request #101379 · python/cpython
Conversation
brandtbucher
commented
Jan 27, 2023
•
edited by bedevere-bot
Loading
Uh oh!
There was an error while loading. Please reload this page.
This handles all of the "class attr simple" failures.
Benchmarking results are "1.00x faster". It improves the LOAD_ATTR hit rate by less than 1%, and has a 32% miss rate (I suspect, due to polymorphism).
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
If this addresses the "class attr simple" case, then according to the stats it should improve the hit rate by 4-5% (13.3% * 0.36).
So, something isn't right there. Are the stats right?
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
So, something isn't right there. Are the stats right?
I assume so. Here are the stats for the base commit and this branch.
For LOAD_ATTR, deferreds fell by 1.3%, hits rose by 0.7%, and misses rose by 0.6%.
I'm guessing that there are two reasons why the number of hits didn't increase by the full 5% you're expecting:
- About 1/3 of the new instructions that do specialize end up missing (so we should really be expecting a ~3% increase in hits).
- More importantly, it looks like nearly all of the cases that used to fail with "class attr simple" are now failing with "has managed dict" (line 860 in this PR). You can see that, before, we had ~600k each of "class attr simple" and "has managed dict" failures. Now, we have 0 "class attr simple" failures, and 1.1M "has managed dict" failures.
So, it appears that "class attr simple" is not so "simple" after all... 5 out of 6 instances that reach it have a __dict__!
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
gvanrossum
commented
Feb 5, 2023
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
|
When (if?) you fix the merge conflict, could you add those new opcodes to the LOAD_ATTR family and properly declare their cache/stack effects, letting the generator take care of those? I recently modernized all the existing family members (gh-101488).
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Reviewers
markshannon
Awaiting requested review from markshannon
markshannon is a code owner
Uh oh!
There was an error while loading. Please reload this page.
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|