Skip to content

[3.14] gh-144438: Fix false sharing between QSBR and tlbc_index (gh-144554)#144923

Open
colesbury wants to merge 2 commits intopython:3.14from
colesbury:backport-6577d87-3.14
Open

[3.14] gh-144438: Fix false sharing between QSBR and tlbc_index (gh-144554)#144923
colesbury wants to merge 2 commits intopython:3.14from
colesbury:backport-6577d87-3.14

Conversation

@colesbury
Copy link
Contributor

@colesbury colesbury commented Feb 17, 2026

Align the QSBR thread state array to a 64-byte cache line boundary and add padding at the end of _PyThreadStateImpl. Depending on heap layout, the QSBR array could end up sharing a cache line with a thread's tlbc_index, causing QSBR quiescent state updates to contend with reads of tlbc_index in RESUME_CHECK. This is sensitive to earlier allocations during interpreter init and can appear or disappear with seemingly unrelated changes.

Either change alone is sufficient to fix the specific issue, but both are worthwhile to avoid similar problems in the future. (cherry picked from commit 6577d87)

…pythongh-144554)

Align the QSBR thread state array to a 64-byte cache line boundary
and add padding at the end of _PyThreadStateImpl. Depending on heap
layout, the QSBR array could end up sharing a cache line with a
thread's tlbc_index, causing QSBR quiescent state updates to contend
with reads of tlbc_index in RESUME_CHECK. This is sensitive to
earlier allocations during interpreter init and can appear or
disappear with seemingly unrelated changes.

Either change alone is sufficient to fix the specific issue, but both
are worthwhile to avoid similar problems in the future.
(cherry picked from commit 6577d87)

Co-authored-by: Sam Gross <colesbury@gmail.com>
@colesbury colesbury marked this pull request as ready for review February 17, 2026 18:06
@colesbury colesbury requested a review from hugovk February 17, 2026 18:06
@colesbury
Copy link
Contributor Author

Added @hugovk for _PyRuntime size change due to field in struct _qsbr_shared

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.

1 participant