Skip to content

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

Merged
merged 3 commits into from
Feb 20, 2025
Merged

Conversation

DinoV
Copy link
Contributor

@DinoV DinoV commented Feb 14, 2025

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

@DinoV DinoV changed the title gh-xxxxx: Avoid locking when clearing objects gh-130313: Avoid locking when clearing objects Feb 19, 2025
@DinoV DinoV requested review from colesbury and mpage February 19, 2025 18:11
@DinoV DinoV marked this pull request as ready for review February 19, 2025 18:12
Copy link
Contributor

@colesbury colesbury left a 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.

clear_inline_values(PyDictValues *values)
{
if (values->valid) {
values->valid = 0;
Copy link
Contributor

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?

@DinoV DinoV added the 🔨 test-with-refleak-buildbots Test PR w/ refleak buildbots; report in status section label Feb 20, 2025
@DinoV DinoV merged commit 6c450f4 into python:main Feb 20, 2025
43 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔨 test-with-refleak-buildbots Test PR w/ refleak buildbots; report in status section skip news topic-free-threading
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants