Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32k
GH-93533: Shrink theLOAD_ATTR
caches#103014
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
LOAD_ATTR
caches.LOAD_ATTR
cachesTeamSpen210 commentedMar 24, 2023
So if I'm understanding this correctly, for each class only 16 methods/attributes can be specialised, with everything after just failing? If so 16 seems fairly small, especially for larger libraries/applications. Something like |
Correct (not including instance attributes). I definitely prefer a growable cache to this approach, except that the numbers we have are slower. I'm also open to using a larger number of entries, like 32 or 64, if others feel similarly. |
I'm also not sure if this causes problems for interpreter isolation. Maybe putting this sort of state on static built-in types is a bad idea, whether it's resizable or not. |
(Docs now passing now#103019 is merged, and updating this with |
markshannon commentedMar 25, 2023 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
From a correctness point of view, adding the cache to static classes should be fine. All the attributes of superclasses of static classes must also be static. However, we would like static classes to be |
Closing because of the various issues outlined above. |
Uh oh!
There was an error while loading.Please reload this page.
This adds a fixed array of cached methods to the
PyTypeObject
struct. This approach saves memory if there are ~23x moreLOAD_ATTR
sites than there are types.A size of 16 was chosen because:
LOAD_ATTR
hit rate onpyperformance
, with 32.5% of specialization failures due to a too-small cache.LOAD_ATTR
hit rate onpyperformance
, with 8.7% of specialization failures due to a too-small cache.LOAD_ATTR
hit rate onpyperformance
, with 3.3% of specialization failures due to a too-small cache.A flexible buffer was also considered, but that was1% slower, likely due to the additional indirection and management of the buffer.
LOAD_ATTR
is too large. #93533