Repository navigation
Conversation
The test held blocks of texts to a shared 2 s of CPU time. One full collection of a worker's heap took 1.1 to 1.2 s of that on CI, and a slow runner took twice as long as a fast one over the same scans, so the test failed without any scan changing. Each text now gets its own 2 s, and the collector stays off while the clock runs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Author
|
Closing. #1421 dropped For the record, a CI diagnostic on two runners found one full collection taking 1.12 s and 1.19 s of the test's 2 s budget, with the collector's cost otherwise near zero. The timings also suggest runner variation. An independent review of this branch found that a budget per text misses a quadratic regression the shared budget caught, so this branch's version would have needed more work anyway. 🤖 Generated with Claude Code |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Unblocks #1427, whose
engine-free (3.13)check keeps failing ontest_a_long_string_is_scanned_in_linear_time, though no scan changed.Cause
The test held blocks of texts to a shared 2 s of CPU time. Two things spent that budget without any scan getting slower, and a one-job diagnostic on CI measured both. The diagnostic ran the same pytest flags on #1427 merged with main, which failed, and on main, which passed.
Even with no collection, the slower runner's largest block took 1.65 s of its 2 s. A collection on a slow runner fails the test; on a fast runner it passes. Python 3.14 passed every time on the same heads, but this PR doesn't depend on why.
Fix
_assert_scans_quicklystops the collector while the clock runs and restores it afterwards, even when a scan raises.Tests only. No source or spec file changes.
Invariants
A cost of this change: the shared budget also caught regressions spread thinly over many texts. A slowdown under 2 s on every text, summing to more than 2 s across a block, used to fail and now passes. The test's job stays quadratic and exponential scans, and those blow up on single texts: see below.
Does it still catch slow scans?
I put real slow scans back into
spec_source_citations.pyand ran the old and new tests against each, on Python 3.13.9 with a 200 s limit.finditer_everywherereverse_each_numbermarks_uncachedpunycode_unboundedquotes_backtrackpossessive_offnumber_backtracknumber_backtrackpasses both, so this PR opens no new gap there. The new test fails sooner onfinditer_everywhereandmarks_uncached, because it checks after each text instead of after a block.Checks
test_spec_source_citations.py -k "scan_clock or linear_time": 4 passed on Python 3.13 and on 3.14.ruff checkandruff format --checkpass on the changed file.🤖 Generated with Claude Code