gh-152063: Cache the offset of the inline values 'valid' byte in LOAD_ATTR#153122
gh-152063: Cache the offset of the inline values 'valid' byte in LOAD_ATTR#153122Aniketsy wants to merge 5 commits into
Conversation
markshannon
left a comment
There was a problem hiding this comment.
The changes to _LOAD_ATTR_INSTANCE_VALUE and the specializer look good.
There should be no reason to increase the cache size for LOAD_ATTR, there is already spare space in LOAD_ATTR_INSTANCE_VALUE
| typedef struct { | ||
| _Py_BackoffCounter counter; | ||
| uint16_t type_version[2]; | ||
| uint16_t value_offset; |
There was a problem hiding this comment.
This shouldn't need changing
| macro(LOAD_ATTR) = | ||
| _SPECIALIZE_LOAD_ATTR + | ||
| unused/8 + | ||
| unused/9 + |
There was a problem hiding this comment.
The cache is already large enough.
If you reduce the size of the unused cache in LOAD_ATTR_INSTANCE_VALUE by one, the other specializations don't need to change.
| cache->index = (uint16_t)offset; | ||
| write_u32(cache->version, tp_version); | ||
| if (base_op == LOAD_ATTR) { | ||
| Py_ssize_t valid_offset = (char *)&values->valid - (char *)owner; |
There was a problem hiding this comment.
| Py_ssize_t valid_offset = (char *)&values->valid - (char *)owner; | |
| Py_ssize_t validity_offset = (char *)&values->valid - (char *)owner; |
valid_offset sounds like a bool for whether the offset is valid.
|
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
|
@markshannon thanks for the review, could you please help me with this patch, after applying these changes getting this error while building.. i was kind of stuck from yesterday, so thought to take help from you 😊 . Thank you ! |
|
It means that you've changed either the size of some of the |
|
If you increase the size of the |
|
@markshannon gentle ping, please have a look in this when you get chance. Thanks :) |
markshannon
left a comment
There was a problem hiding this comment.
I think you may be missing the offset in the cache for LOAD_ATTR_METHOD_WITH_VALUES when specializing
| EXIT_IF(!FT_ATOMIC_LOAD_UINT8(_PyObject_InlineValues(owner_o)->valid)); | ||
| } | ||
|
|
||
| op(_CHECK_MANAGED_OBJECT_HAS_VALUES_OFFSET, (validity_offset/1, owner -- owner)) { |
There was a problem hiding this comment.
Can you rename this to _CHECK_MANAGED_OBJECT_HAS_VALUES it isn't checking an offset.
There was a problem hiding this comment.
After renaming it creates the duplicate op, so i've removed
| SPECIALIZATION_FAIL(LOAD_ATTR, SPEC_FAIL_OUT_OF_VERSIONS); | ||
| return 0; | ||
| } | ||
| write_u32(cache->keys_version, shared_keys_version); |
There was a problem hiding this comment.
This seems odd.
Why are you writing the keys version? What about the offset?
You may need to change _PyLoadMethodCache to reflect how it is now used
|
@markshannon thanks for the review and improvement, i've updated with changes as per your suggestions, please let me know if this needs further improvement. |
Fixes #152063
LOAD_ATTR_INSTANCE_VALUEinstruction can be sped up by storing the offset of thevalidfield in the cache. #152063