Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Makeset thread-safe in--disable-gil builds #112069

Closed
Assignees
corona10tomasr8
Labels
@colesbury

Description

@colesbury

Feature or enhancement

Theset object is not currently thread-safe in--disable-gil builds. We should make it thread-safe by using the"critical section" API. to acquire the per-object locks around operations. There should be no effective change in the default build (i.e., with GIL) because critical sections are no-ops in the default build.

Notes:

  1. Unlikedict andlist, I don't think it's worth the complexity to try to "optimistically avoid locking" around any set operation (exceptset_len). We could consider doing this in the future if there is a performance justification, but not for 3.13.
  2. set_len can avoid locking and instead use relaxed atomics for reading the "used" field. Note that writes to "used" should then also use relaxed atomics.
  3. Some operations require locking two containers (likeset_merge). Some of these will need refactorings so that the critical sections macros can be added in the correct places.

For context, here is the change from thenogil-3.12 fork:colesbury/nogil-3.12@4ca2924f0d. Note that the critical section API is slightly changed in 3.13 fromnogil-3.12; In 3.13Py_BEGIN_CRITICAL_SECTION takes a PyObject instead of a PyMutex.

TODO:

Linked PRs

Metadata

Metadata

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions


    [8]ページ先頭

    ©2009-2025 Movatter.jp