Skip to content

[3.13] gh-131988: Fix a multithreaded scaling regression - #131989

Merged
Yhg1s merged 1 commit into
python:3.13from
colesbury:gh-131988-immortalize
Apr 7, 2025
Merged

[3.13] gh-131988: Fix a multithreaded scaling regression#131989
Yhg1s merged 1 commit into
python:3.13from
colesbury:gh-131988-immortalize

Conversation

@colesbury

@colesburycolesbury commented Apr 1, 2025

Copy link
Copy Markdown
Contributor

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.

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.
@bedevere-bot

Copy link
Copy Markdown

🤖 New build scheduled with the buildbot fleet by @colesbury for commit 22349fd 🤖

Results will be shown at:

https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F131989%2Fmerge

If you want to schedule another build, you need to add the 🔨 test-with-refleak-buildbots label again.

@bedevere-botbedevere-bot removed the 🔨 test-with-refleak-buildbots Test PR w/ refleak buildbots; report in status section label Apr 1, 2025
@colesburycolesbury changed the title gh-131988: Fix a multithreaded scaling regression[3.13] gh-131988: Fix a multithreaded scaling regressionApr 1, 2025
@python-cla-bot

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

@Yhg1s
Yhg1s merged commit 1fcf409 into python:3.13Apr 7, 2025
@nedbat

Copy link
Copy Markdown
Member

The coverage.py nightly test suite has been failing on 3.13t since this commit. In particular, the test that my C extension isn't leaking code objects. It looks like now we expect code objects will never be reclaimed, and this change is only on 3.13 and will not be applied to 3.14, is that right? I can adjust my tests if so.

@colesbury

Copy link
Copy Markdown
ContributorAuthor

this change is only on 3.13 and will not be applied to 3.14, is that right?

Yes, that's right

@colesbury
colesbury deleted the gh-131988-immortalize branch April 14, 2025 14:53
Sign up for freeto 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.

4 participants

@colesbury@bedevere-bot@nedbat@Yhg1s