FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

[3.13] gh-126914: Store the Preallocated Thread State's Pointer in a PyInterpreterState Field by ericsnowcurrently · Pull Request #127114 · python/cpython · GitHub

/ cpython Public

[3.13] gh-126914: Store the Preallocated Thread State's Pointer in a PyInterpreterState Field - #127114

Merged
ericsnowcurrently merged 2 commits into
python:3.13from
ericsnowcurrently:backport-1c0a104-3.13
Dec 2, 2024
Merged

[3.13] gh-126914: Store the Preallocated Thread State's Pointer in a PyInterpreterState Field#127114
ericsnowcurrently merged 2 commits into
python:3.13from
ericsnowcurrently:backport-1c0a104-3.13

Conversation

ericsnowcurrently commented Nov 21, 2024
edited by bedevere-app Bot
Loading

Copy link
Copy Markdown
Member

This approach eliminates the originally reported race. It also gets rid of the deadlock reported in gh-96071, so we can remove the workaround added then.

This is mostly a cherry-pick of 1c0a104 (AKA gh-126989). The difference is we add PyInterpreterState.threads_preallocated at the end of PyInterpreterState, instead of adding PyInterpreterState.threads.preallocated. That avoids ABI disruption.

…yInterpreterState Field (pythongh-126989)

This approach eliminates the originally reported race. It also gets rid of the deadlock reported in pythongh-96071, so we can remove the workaround added then.

Copy link
Copy Markdown
Member Author

@Yhg1s, this changes only internal ABI, so we should be fine updating the ABI data file, right?

Yhg1s commented Nov 25, 2024

Copy link
Copy Markdown
Member

Yes, the struct is always allocated by the runtime, and the new field is used only by the runtime, never extension modules, so updating the ABI definition is fine.

Yhg1s commented Dec 2, 2024

Copy link
Copy Markdown
Member

Do you want to get this into 3.13.1? (It's scheduled for tomorrow :)

ericsnowcurrently enabled auto-merge (squash) December 2, 2024 18:39
ericsnowcurrently merged commit 219b826 into python:3.13 Dec 2, 2024
ericsnowcurrently deleted the backport-1c0a104-3.13 branch December 2, 2024 19:01
colesbury added a commit to colesbury/cpython that referenced this pull request Apr 1, 2025
The 3.13 free threaded build immortalizes certain objects to avoid
reference count contention. In pythongh-127114 the condition was
unintentionally changed to happen when the first thread was created
instead of the first non-main thread. The `interp->gc.immortalize` field
is then cleared again during `_PyGC_Init()`.

Change the condition so that we check if we should immortalize objects
using deferred reference counting whenever a non-main thread is created.
Yhg1s pushed a commit that referenced this pull request Apr 7, 2025
gh-131988: Fix a multithreaded scaling regression

The 3.13 free threaded build immortalizes certain objects to avoid
reference count contention. In gh-127114 the condition was
unintentionally changed to happen when the first thread was created
instead of the first non-main thread. The `interp->gc.immortalize` field
is then cleared again during `_PyGC_Init()`.

Change the condition so that we check if we should immortalize objects
using deferred reference counting whenever a non-main thread is created.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL