gh-130313: Avoid locking when clearing objects#130126
Merged
Merged
Conversation
mpage
reviewed
Feb 19, 2025
colesbury
reviewed
Feb 19, 2025
colesbury
approved these changes
Feb 20, 2025
Contributor
colesbury
left a comment
There was a problem hiding this comment.
See comment about clear_inline_values, but otherwise LGTM.
It might be worth running the refleak build bots because these code paths are tricky.
| clear_inline_values(PyDictValues *values) | ||
| { | ||
| if (values->valid) { | ||
| values->valid = 0; |
Contributor
There was a problem hiding this comment.
Does this need to be FT_ATOMIC_STORE_UINT8(values->valid, 0) for the call from set_dict_inline_values?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
There's no need for us to lock the object when clearing the managed dict. We may need to lock the dict if it's been materialized and points to external objects as we could be doing a simple free of the object while other things refer to the dict.
This requires us to relax an assert because we clear objects after we've restarted the world. But we're past the point of resurrection so no one else can be referring to this object.
https://github.com/facebookexperimental/free-threading-benchmarking/tree/main/results/bm-20250214-3.14.0a5+-c00cd86-NOGIL