Repository navigation
fix flaky table-lengths linearity guard (ratio -> absolute ceiling) - #767
Merged
Merged
Conversation
…(#GH-FLAKY-TABLE-LENGTHS-LINEAR) What changed: `adapter::tests::table_lengths_scale_linearly_with_the_number_of_tables` asserted `t800 < t200 * 8`, a ratio over a sub-millisecond baseline (~587us on PR #765 CI). Scheduler noise of a few hundred microseconds is a large fraction of that baseline, and a ratio's error bars scale with the smaller operand, so it amplified the noise into an occasional false failure ("800 tables took 5.044542ms, 200 took 587.834us: not linear", which passed on an unmodified re-run at the same commit). Replaced the ratio with an absolute ceiling (300ms on t800), the same pattern as crates/render-pipeline/tests/adapt_linear_time.rs (#765). Measured on dev hardware: normal 800-table runs (best of 5) take ~1-1.3ms in --release, ~10-11ms unoptimized. Forcing `length_at_checked` to always fall through to `length_at_scan` (i.e. reverting #623 so every table rescans the source instead of using the per-document index) makes 800 tables take ~1.4s in --release - about a thousandfold jump. 300ms sits ~250-300x above the normal case and ~5x below the reintroduced-quadratic case. What was run: - `cargo test --no-run` (separate step) before counting any results: compiled clean. - Before (already established on PR #765, not reproduced here): CI failure "800 tables took 5.044542ms, 200 took 587.834us: not linear", the same commit re-run went green with no change. - After, single run (--release): `table lengths: 200 tables 308.875us, 400 tables 603.834us, 800 tables 1.200166ms` / `test ... ok`. - 30x loop (--release): 30/30 `test result: ok`, t800 ranged 1.162084ms-1.252833ms, all far under the 300ms ceiling. - Negative control: temporarily forced `length_at_checked` to always call `length_at_scan` (reverting #623) and rebuilt. The fixed test failed: "800 tables took 1.391193958s (200 took 34.739917ms, 400 took 207.798417ms): quadratic regression suspected, see #623" / `test result: FAILED. 0 passed; 1 failed`. Reverted the temporary change immediately after (git diff confirmed clean before committing). - Full `adapter::tests::` module (--release): `test result: ok. 38 passed; 0 failed; 1 ignored`. Next step: open PR to main; no further code changes anticipated for this task. Implementation-Agent: claude-sonnet-5 subagent of daniel-parent Commit-Executor: daniel-parent subagent Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz
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.
What
This is a flake fix (unbreaking), not a new feature — no new functionality is added.
adapter::tests::table_lengths_scale_linearly_with_the_number_of_tablesincrates/render-pipeline/src/adapter.rsasserted a ratio,t800 < t200 * 8,over a sub-millisecond baseline. Replaced it with an absolute time ceiling
(300ms on
t800), following the same pattern already reviewed incrates/render-pipeline/tests/adapt_linear_time.rs(#765).Why
The ratio amplified scheduler noise: on PR #765 CI it failed as
and the identical commit re-run at the same SHA with no change went
completed/success— proof it's a flake, not a real regression. A fewhundred microseconds of jitter is a large fraction of a ~587us baseline,
and a ratio's error bars scale with the smaller operand, so the ratio
amplifies exactly that noise.
I did not just widen the multiplier (e.g.
* 8→* 16) — that keeps aratio over a sub-millisecond baseline and only delays the next false alarm
while catching less real regression. Instead I replaced the ratio with an
absolute ceiling with a large margin (option (b) from the task):
~1-1.3ms in
--releaseand ~10-11ms unoptimized.length_at_checkedto always fall through tolength_at_scan(i.e. reverting render-pipeline: adapt is linear again — index list/theorem nesting once, memoise setlength (18 s → 0.19 s warm edit on #535) #623, so every table rescans the source instead of using
the per-document index) makes 800 tables take ~1.4s in
--release—about a thousandfold jump.
reintroduced-quadratic case, so it stays quiet on a loaded/noisy machine
and still fires if a per-item source rescan comes back.
I chose the absolute-ceiling approach over inflating the input size
(option (a)) because it keeps the test's real workload and runtime
unchanged (~10ms today) while giving a much larger, asymmetric margin in
both directions than the original ratio ever could.
Overlap check
gh pr list --repo flash-tex/flashtex --state all --search "table_lengths_scale_linearly"and--search "adapt_linear": no results.gh pr list --repo flash-tex/flashtex --state open --search "flaky":only mac: fix GH-680 flaky extra compile_result — test's observer, not the shell #719 (
mac: fix GH-680 flaky extra compile_result), a differenttest on a different machine/branch — no overlap.
python3 scripts/coord.py claims: onlyGH-659-MAC-FAILURE-EVIDENCEandGH-660-SNAPSHOT-ENV-GATE(daniel-muse-lead, unrelated tests/files) wereactive besides this task's own claim.
Test results
cargo test --no-run(separate step, before counting any results):compiled clean, no other changes needed.
Before (already established on PR #765, not reproduced here — this PR
does not re-run that CI job):
After, one
--releaserun:30x loop (
--release), to show it does not flake: 30/30test result: ok.t800across all 30 runs ranged 1.162084ms–1.252833ms,t200ranged 304.791us–340.209us — consistently far under the 300ms ceiling and
consistent with the single-run numbers above.
Negative control (proves the guard can still fail): temporarily forced
length_at_checkedto always calllength_at_scan(reverting #623) andrebuilt. The fixed test failed:
Then reverted that temporary change immediately (
git diffconfirmed aclean, single-purpose diff before this commit).
Full
adapter::tests::module (--release), to confirm nothing elsebroke:
test result: ok. 38 passed; 0 failed; 1 ignored; 0 measured; 126 filtered out; finished in 0.30s.Not done
crates/render-pipeline/tests/adapt_linear_time.rs(render-pipeline: guard that adapt stays linear — recovers the two timing tests #627's revert took with it #765)itself — it already uses the absolute-ceiling pattern this PR follows.
l200/l800content-equalityassertions in the same test — they were unaffected and still pass.
🤖 Generated with Claude Code
https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz