Skip to content

gh-162705: Report QSBR progress during list and tuple scans - #162942

Closed
mehdipanjwani7-glitch wants to merge 1 commit into
python:mainfrom
mehdipanjwani7-glitch:fix/qsbr-sequence-scan-progress
Closed

mehdipanjwani7-glitch wants to merge 1 commit into
python:mainfrom
mehdipanjwani7-glitch:fix/qsbr-sequence-scan-progress

Conversation

@mehdipanjwani7-glitch

@mehdipanjwani7-glitch mehdipanjwani7-glitch commented Dec 1, 2026 •

Copy link
Copy Markdown

Refs #162705. Long attached list and tuple scans can hold up reclamation of arrays retired by other threads. This reports QSBR progress every 1,024 iterations in membership, index and count scans.

Membership and index scans report on continuing paths, after temporary element references have been released. Count scans cover the identity-fast-path continue too. Each report reloads the current QSBR record. The out-of-line thread-state getter keeps Clang's TLS address resolution off short scan paths; disassembly of the initial inline-getter version showed that lookup being hoisted before the loop.

The native regression helper advances the write epoch after preparing arguments and observes the read sequence before returning to Python. Eight list/tuple subcases fail without the runtime change and pass with it. The index cases start at one, so a report only at index zero cannot satisfy them.

Validation on macOS arm64, Apple Clang 21, based on ce50df41e3b9aa68b10bbe49cbb57382d6201ec8:

  • Free-threaded debug and optimized builds: nine selected modules, 469 tests run (12 and 13 skipped, respectively).
  • GIL debug build: six selected modules, 762 tests run, nine skipped.
  • Five paired fresh-process optimized trials, with identical bounded worker work: extra peak RSS about 97 to 6 MiB; total peak about 178 to 88 MiB. Both workers finish within each scan in every arm.
  • Separate long-scan timing medians: +0.1% to +4.4%. Common-case timings for sizes 0, 1 and 4: -3.9% to +6.3%, including Python loop overhead. These are local, non-PGO/non-LTO measurements.

Raw measurements, build settings and test logs, long-scan/pressure matrix, common cases, and baseline regression failure. Superseded variants and their unfavorable results are retained in the same directory.

This builds on the manual quiescent-reporting approach proposed in the original issue. It addresses these six scans; other long native calls and uncooperative threads remain outside this change, so it should not close the broader issue.

AI assistance: Codex was used for implementation, technical review, and the supporting test/benchmark scripts.

Report quiescence every 1024 iterations while preserving early returns. Use the out-of-line thread-state getter to keep TLS address resolution off short scan paths. Add native epoch-progress regression checks and a NEWS entry. Developed and technically reviewed with Codex AI assistance.
@python-cla-bot

python-cla-bot Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

@bedevere-app bedevere-app Bot added the type-feature A feature request or enhancement label Dec 1, 2026
@picnixz picnixz added the AI-guidelines-not-met The contribution does not meet our guidelines for using AI tools and is closed automatically. label Dec 1, 2026
@bedevere-app

bedevere-app Bot commented Dec 1, 2026

Copy link
Copy Markdown

Thank you for your interest in contributing to Python. This is a community-driven project, and we want it to be a welcoming place to learn and collaborate.

Contributors are responsible for reviewing and understanding what they submit, checking its claims, and being able to explain changes in their own words. This helps reviewers focus on the contribution and leaves more time to support other contributors.

We believe this contribution does not meet our guidelines for using AI tools, so we're closing it. If you think we've misunderstood your contribution, please let us know. You're welcome to explain your approach or ask questions about the guidelines.

Please read our guidelines for using AI tools.

@bedevere-app bedevere-app Bot closed this Dec 1, 2026
@picnixz

picnixz commented Dec 1, 2026

Copy link
Copy Markdown
Member

There is nothing actionable for now, a PR is premature.

@mehdipanjwani7-glitch

mehdipanjwani7-glitch commented Dec 1, 2026 •

Copy link
Copy Markdown
Author

Edited to clarify attribution and update the validation results.

I’m Muhammad Mehdi (mehdipanjwani7-glitch), the contributor behind this PR. I authorized the work and submission. Codex provided substantial assistance with implementation, technical investigation, test execution and documentation, including this clarification.

The proposal addresses delayed reclamation during long list and tuple membership, index and count scans in free-threaded CPython. It adds periodic QSBR reports every 1,024 iterations, after temporary list-element references have been released on continuing paths. It follows the retention report and manual-quiescence proposal in #162705. The unresolved design question is whether callers also satisfy the quiescence contract; local reference-lifetime checks do not establish that for every native caller.

The separate audit corrected a checker defect that missed reference uses inside acquisition initializers, tightened benchmark validation to reject incomplete worker overlap and missing build metadata, and enlarged concurrent-resize tests beyond the reporting interval. Those are improvements to the research tooling and evidence, not additional runtime fixes. All 31 checker/qualification tests pass; the nine native behavior tests pass on the five recorded build arms. The audit record contains the exact revisions, measurements and limits.

The fork’s official CI run has finished: 39 jobs passed, two skipped, five could not acquire runners, and MSan plus the aggregate check failed. The MSan failure is an external-inspection source-location assertion; independence from the patch has not been established. The overall result is not green.

I acknowledge the request for human design discussion first. The PR remains closed, and no replacement PR or renewed review is being requested.

@picnixz

picnixz commented Dec 1, 2026

Copy link
Copy Markdown
Member

We are not interested in having an agent doing work autonomously. The issue needs disucssion first, by humans.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI-guidelines-not-met The contribution does not meet our guidelines for using AI tools and is closed automatically. awaiting review type-feature A feature request or enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants