Repository navigation
test(protocols): keep the frame-layer-limit timing bound stable on PyPy (#2160) - #2162
Merged
Merged
Conversation
…Py (#2160) On PyPy each parse of a deep frame sets off major-collection steps that a short frame's parse does not, and their cost grows with the worker's heap, so the best of three deep parses can still carry it. Time both frames after a gc.collect() with the collector disabled, as timeit does; the bound itself is unchanged. best() and bounded() move to module level, and TimingBoundTests drives them with a made-up clock: the collector's share is kept out, the collector state is restored, and a linear or quadratic parse still breaches the bound.
Owner
Author
|
GOOD TO GO at
|
Contributor
|
Coverage: 91.55% (unit tier, Python 3.15,
Per-file detail: the |
Owner
Author
|
Ready to merge at
|
This was referenced Oct 25, 2026
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.
make testpasses, and a test case covers the changeWhat is the purpose of your pull request?
test— tests onlyDescription
Closes #2160.
tests/protocolsprocess. PyPy's GC hooks show each deep parse triggers 2–3 full-collection steps where a short parse triggers none. That cost grows with heap size: deep IPv6 took 8.1, 13.6 and 25.0 ms at 0, 10M and 40M live objects, and 9.4–10.0 ms at every size with the collector off. A CI worker's heap is the likely source of the 125 ms in run 40161694146. Runner CPU steal is the other candidate.best()runsgc.collect()and disables the collector while timing, then restores it, astimeitdoes. The bounddeep < 4 * short + 0.05is unchanged.TimingBoundTestscheck that the collector's cost stays out of the timing, that the GC state is restored even when the parse raises, and that a linear or quadratic per-layer cost still breaks the bound. Without the fix the first test fails (0.1375 != 0.0125).tests/test_tier_guard.py: 133 passed.Not in scope: the bound is loose. A quadratic walk past the limit is caught for IPv6 but not for IPv4 or 802.1Q, where the 0.05 s slack dominates. Tightening it needs measurements across the CI matrix, so it is tracked separately.