Skip to content

GH-125174: Make immortal objects more robust, following design from PEP 683 - #125251

Merged
markshannon merged 4 commits into
python:mainfrom
faster-cpython:more-robust-immortality
Oct 10, 2024
Merged

markshannon merged 4 commits into
python:mainfrom
faster-cpython:more-robust-immortality

Conversation

@markshannon

@markshannon markshannon commented Oct 10, 2024 •

Copy link
Copy Markdown
Member
@markshannon

Copy link
Copy Markdown
Member Author

This is not a complete fix for #125174, just enough to unblock other work

@markshannon markshannon added the 🔨 test-with-refleak-buildbots Test PR w/ refleak buildbots; report in status section label Oct 10, 2024
@bedevere-bot

Copy link
Copy Markdown

🤖 New build scheduled with the buildbot fleet by @markshannon for commit 94f8fd0 🤖

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 Oct 10, 2024
@markshannon

Copy link
Copy Markdown
Member Author

The two "failing" refleak buildbots seem to be hanging in test.test_concurrent_futures.test_shutdown. There are no reported refleaks.

@markshannon

Copy link
Copy Markdown
Member Author

Performance impact:

Overall a small slowdown, with a large 7-10% slowdown on nbody.
This is almost certainly due to the regression in stack spilling around _Py_IsImmortal_Loose fixed here.

ARM 64 darwin
x86-64 linux

I'll re-run the linux benchmarks with the fix as a sanity check.

Comment thread Include/refcount.h Resolved
@markshannon

Copy link
Copy Markdown
Member Author

Windows shows an over 2% improvement. With the regression fixed, this I would expect this to be more than 3%.

This reason for this is that the MSVC does not convert unsigned int x; x > (1 << 31) into signed x; x < 0 as do clang and gcc.
This PR uses the signed x; x < 0 form. Hence the speedup.

@markshannon

Copy link
Copy Markdown
Member Author

x86-64 linux performance numbers are a bit noisy, but show no significant change.

@markshannon
markshannon merged commit c901437 into python:main Oct 10, 2024
@markshannon
markshannon deleted the more-robust-immortality branch October 10, 2024 17:20
tacaswell added a commit to tacaswell/msgspec that referenced this pull request Oct 24, 2024
python/cpython#125251 renamed
_PY_IMMORTAL_REFCNT -> _PY_IMMORTAL_INITIAL_REFCNT
jcrist added a commit to msgspec/msgspec that referenced this pull request Oct 24, 2024
* MNT: account for CPython 314 changes

python/cpython#125251 renamed
_PY_IMMORTAL_REFCNT -> _PY_IMMORTAL_INITIAL_REFCNT

* Define new macro to reduce duplication

---------

Co-authored-by: Jim Crist-Harif <jcristharif@gmail.com>
akretz added a commit to akretz/iteration_utilities that referenced this pull request Dec 4, 2025
akretz added a commit to akretz/iteration_utilities that referenced this pull request Dec 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants