Skip to content

Give the re-init stress test's readers time to drain - #1633

Merged
asvetlov merged 1 commit into
aio-libs:masterfrom
asvetlov:reinit-stress-timeouts
Sep 28, 2026
Merged

asvetlov merged 1 commit into
aio-libs:masterfrom
asvetlov:reinit-stress-timeouts

Conversation

@asvetlov

Copy link
Copy Markdown
Member

What do these changes do?

test_reinit_finalizer_vs_lock_free_readers (#1621) timed out on the Windows 3.10, 3.11 and 3.12 jobs, at f.result(timeout=60) for its readers. The faulthandler dump from a 183 s run shows every reader still inside Value.__del__() -> probe() after the writer finished, each blocked in coverage/collector.py: lock_data. Under coverage's C tracer (3.10 to 3.12) every traced line takes a lock the threads share, and the readers are draining the finalizers of generations their copy() snapshots outlived. That work is bounded (3216 finalizers, nesting depth 1), just slow: 0.4 s without coverage, 12 to 20 s with it on a Linux 3.11 box, and over three minutes on the Windows runners. The failure reports also show every reader future finished by the time pytest rendered them.

The writer now gets 300 s and the readers a shared 300 s deadline, inside the job's 15-minute limit.

Are there changes in behavior for the user?

No, tests only.

Is it a substantial burden for the maintainers to support this?

No.

Related issue number

Follows #1621. Failed on #1625, #1628 (twice) and #1630; re-runs passed.

Checklist

  • I think the code is well written
  • Unit tests for the changes exist (N/A, a test timeout)
  • Documentation reflects the changes
  • If you provide code modification, please add yourself to CONTRIBUTORS.txt (N/A)
  • Add a new news fragment into the CHANGES/ folder
  • make doc-spelling passes and any new technical words are added to docs/spelling_wordlist.txt
Agent run details (optional, for reviewers)

tests/test_free_threading.py: GIL 3.14.7 10 passed, FT 3.14.7t 10 passed (without coverage); 3.11.13 with coverage, the two cases took 12.4 s and 19.9 s.

Lint: pre-commit clean.

Drafted with Claude Code (Claude Opus 5.5); reviewed by @asvetlov.

test_reinit_finalizer_vs_lock_free_readers timed out on Windows 3.10 to
3.12 while waiting for its readers. A faulthandler dump showed them
still running the finalizers of generations their snapshots outlived,
each blocked in coverage's lock_data(): the C tracer takes a lock the
threads share on every traced line. The work is bounded, it is just
slow, up to three minutes on those runners. Wait up to five minutes for
the writer and five, shared, for the readers, inside the job's fifteen.
@pyba-chronographer pyba-chronographer Bot added the bot:chronographer:provided There is a change note present in this PR label Sep 28, 2026
@asvetlov
asvetlov marked this pull request as ready for review September 28, 2026 18:28
@asvetlov
asvetlov requested a review from webknjaz as a code owner September 28, 2026 18:28
@codspeed

codspeed Bot commented Sep 28, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 706 untouched benchmarks


Comparing asvetlov:reinit-stress-timeouts (2661a1f) with master (2087809)

Open in CodSpeed

@greptile-apps

greptile-apps Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Low risk] Adjusts timeouts in a stress test.

No blocking issues found; safe to merge.

What we checked:

  • Targeted reader tests with coverage were run for both the parent-commit and current-commit, and both runs passed. T-Rex
  • The changed reader-wait logic was exercised with controlled clock values, and a completed reader's result was collected at the deadline while a pending reader raised TimeoutError. T-Rex
  • The zero-second timeout case still returns a completed reader's result, while a reader missing the five-minute deadline triggers TimeoutError; the pytest runs did not reach that deadline. T-Rex
  • Artifacts from logs and Python source capture the deadline-check experiments, providing evidence to inspect timing behavior. T-Rex

Reviews (1) · Last reviewed commit: "Give the re-init stress test's readers t..."

@codecov

codecov Bot commented Sep 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.49%. Comparing base (25b946d) to head (2661a1f).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff             @@
##            master    #1633      +/-   ##
===========================================
- Coverage   100.00%   98.49%   -1.51%     
===========================================
  Files           44       47       +3     
  Lines         8412     9023     +611     
  Branches       710      775      +65     
===========================================
+ Hits          8412     8887     +475     
- Misses           0      132     +132     
- Partials         0        4       +4     
Flag Coverage Δ
CI-GHA 98.49% <100.00%> (-1.51%) ⬇️
pytest 98.49% <100.00%> (-1.51%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@asvetlov
asvetlov merged commit 2800fef into aio-libs:master Sep 28, 2026
64 of 65 checks passed
@asvetlov
asvetlov deleted the reinit-stress-timeouts branch September 28, 2026 18:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot:chronographer:provided There is a change note present in this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant