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

Concurrent reads from cell objects (LOAD_DEREF) do not scale well #123358

Open
colesbury opened this issue Aug 26, 2024 · 2 comments
Open

Concurrent reads from cell objects (LOAD_DEREF) do not scale well #123358

colesbury opened this issue Aug 26, 2024 · 2 comments
Assignees
Labels

Comments

@colesbury
Copy link
Contributor

colesbury commented Aug 26, 2024

Concurrent accesses from multiple threads to the same cell object do not scale well in the free-threaded build. There are two problems:

  1. LOAD_DEREF calls PyCell_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.

  2. PyCell_GetRef returns a strong reference and LOAD_DEREF will need a _PyStackRef to handle objects that use deferred reference counting.

Linked PRs

@colesbury colesbury added performance Performance or resource usage topic-free-threading labels Aug 26, 2024
@colesbury
Copy link
Contributor Author

This came up in the context of wjakob/nanobind#695

@corona10
Copy link
Member

@colesbury Can I take a look at it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Todo
Development

No branches or pull requests

5 participants
@colesbury @corona10 and others