Skip to content
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

threading.local() access should scale well from multiple threads #128691

Open
colesbury opened this issue Jan 9, 2025 · 0 comments
Open

threading.local() access should scale well from multiple threads #128691

colesbury opened this issue Jan 9, 2025 · 0 comments
Labels
performance Performance or resource usage topic-free-threading type-feature A feature request or enhancement

Comments

@colesbury
Copy link
Contributor

colesbury commented Jan 9, 2025

Currently, accessing a threading.local() from multiple threads doesn't scale well because of reference count contention on the shared _thread._local object. We should use deferred reference counting on _thread._local to avoid this bottleneck.

Linked PRs

@colesbury colesbury added performance Performance or resource usage topic-free-threading labels Jan 9, 2025
colesbury added a commit to colesbury/cpython that referenced this issue Jan 9, 2025
After this change, the "thread_local_read" micro benchmark in
Tools/ftscalingbench/ftscalingbench.py now scales well when multiple
threads read from the same thread-local variable.
colesbury added a commit to colesbury/cpython that referenced this issue Jan 9, 2025
After this change, the "thread_local_read" micro benchmark in
Tools/ftscalingbench/ftscalingbench.py now scales well when multiple
threads read from the same thread-local variable.
colesbury added a commit to colesbury/cpython that referenced this issue Jan 9, 2025
This change, along with the LOAD_ATTR specializations, makes the
"thread_local_read" micro benchmark in Tools/ftscalingbench/ftscalingbench.py
scale well to multiple threads.
@colesbury colesbury added the type-feature A feature request or enhancement label Jan 9, 2025
colesbury added a commit to colesbury/cpython that referenced this issue Jan 10, 2025
@colesbury colesbury changed the title threading.local() access should scale well threading.local() access should scale well from multiple threads Jan 10, 2025
colesbury added a commit that referenced this issue Jan 10, 2025
This change, along with the LOAD_ATTR specializations, makes the
"thread_local_read" micro benchmark in Tools/ftscalingbench/ftscalingbench.py
scale well to multiple threads.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance Performance or resource usage topic-free-threading type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

1 participant