-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
Concurrent reads from cell
objects (LOAD_DEREF
) do not scale well
#123358
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
Labels
Comments
This came up in the context of wjakob/nanobind#695 |
@colesbury Can I take a look at it? |
corona10
added a commit
to corona10/cpython
that referenced
this issue
Sep 24, 2024
corona10
added a commit
to corona10/cpython
that referenced
this issue
Sep 25, 2024
corona10
added a commit
to corona10/cpython
that referenced
this issue
Sep 25, 2024
corona10
added a commit
to corona10/cpython
that referenced
this issue
Sep 25, 2024
corona10
added a commit
to corona10/cpython
that referenced
this issue
Oct 3, 2024
colesbury
pushed a commit
to colesbury/cpython
that referenced
this issue
Feb 13, 2025
colesbury
added a commit
to colesbury/cpython
that referenced
this issue
Mar 24, 2025
colesbury
added a commit
that referenced
this issue
Mar 26, 2025
Concurrent accesses from multiple threads to the same `cell` object did not scale well in the free-threaded build. Use `_PyStackRef` and optimistically avoid locking to improve scaling. With the locks around cell reads gone, some of the free threading tests were prone to starvation: the readers were able to run in a tight loop and the writer threads weren't scheduled frequently enough to make timely progress. Adjust the tests to avoid this. Co-authored-by: Donghee Na <[email protected]>
diegorusso
pushed a commit
to diegorusso/cpython
that referenced
this issue
Apr 1, 2025
Concurrent accesses from multiple threads to the same `cell` object did not scale well in the free-threaded build. Use `_PyStackRef` and optimistically avoid locking to improve scaling. With the locks around cell reads gone, some of the free threading tests were prone to starvation: the readers were able to run in a tight loop and the writer threads weren't scheduled frequently enough to make timely progress. Adjust the tests to avoid this. Co-authored-by: Donghee Na <[email protected]>
seehwan
pushed a commit
to seehwan/cpython
that referenced
this issue
Apr 16, 2025
Concurrent accesses from multiple threads to the same `cell` object did not scale well in the free-threaded build. Use `_PyStackRef` and optimistically avoid locking to improve scaling. With the locks around cell reads gone, some of the free threading tests were prone to starvation: the readers were able to run in a tight loop and the writer threads weren't scheduled frequently enough to make timely progress. Adjust the tests to avoid this. Co-authored-by: Donghee Na <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Uh oh!
There was an error while loading. Please reload this page.
Concurrent accesses from multiple threads to the same
cell
object do not scale well in the free-threaded build. There are two problems:LOAD_DEREF
callsPyCell_GetRef
, which acquires the per-object lock on the cell instance. We'll need to use_Py_TryXGetRef
or similar to safely access the value.PyCell_GetRef
returns a strong reference andLOAD_DEREF
will need a_PyStackRef
to handle objects that use deferred reference counting.Linked PRs
_PyStackRef
inLOAD_DEREF
#130064The text was updated successfully, but these errors were encountered: