Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

colesbury
Copy link
Contributor

@colesbury colesbury commented Apr 1, 2025

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.
@colesbury colesbury requested a review from Yhg1s April 1, 2025 19:42
@colesbury colesbury added the 🔨 test-with-refleak-buildbots Test PR w/ refleak buildbots; report in status section label Apr 1, 2025
@bedevere-bot
Copy link

🤖 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-bot bedevere-bot removed the 🔨 test-with-refleak-buildbots Test PR w/ refleak buildbots; report in status section label Apr 1, 2025
@colesbury colesbury changed the title gh-131988: Fix a multithreaded scaling regression [3.13] gh-131988: Fix a multithreaded scaling regression Apr 1, 2025
@python-cla-bot
Copy link

python-cla-bot bot commented Apr 6, 2025

All commit authors signed the Contributor License Agreement.

CLA signed

@Yhg1s Yhg1s merged commit 1fcf409 into python:3.13 Apr 7, 2025
54 checks passed
@nedbat
Copy link
Member

nedbat commented Apr 14, 2025

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
Contributor Author

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 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.

4 participants