-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
gh-130313: Avoid locking when clearing objects #130126
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comment about clear_inline_values
, but otherwise LGTM.
It might be worth running the refleak build bots because these code paths are tricky.
Objects/dictobject.c
Outdated
clear_inline_values(PyDictValues *values) | ||
{ | ||
if (values->valid) { | ||
values->valid = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this need to be FT_ATOMIC_STORE_UINT8(values->valid, 0)
for the call from set_dict_inline_values
?
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