Repository navigation
render-pipeline: guard that adapt stays linear — recovers the two timing tests #627's revert took with it - #765
Merged
Conversation
… environments What changed: - Adds crates/render-pipeline/tests/adapt_linear_time.rs with the two complexity guards that were lost when #627 reverted 71d8fbf. That revert was deduplication, not a defect: #623 fixed the same quadratic adapt with a SourceIndex and landed on main as bbc9583, so #627 gave the adapter back to #623 — but it took these two tests with it, and #623 shipped only source_index_matches_prefix_scans, which checks identity, not cost. Nothing on main noticed if adapt went quadratic again while still producing the right output. - The file also records the six fuzz-found hang cases (PR #627's mutation fuzzer, "hang in render") with their before/after release timings, so the finding lives in the repo rather than in the message of a reverted commit on an unpushed branch. - Test-only. No product code changes. What was run: - cargo test --test adapt_linear_time --no-run (main, 9c5b028): Finished `test` profile [unoptimized + debuginfo] target(s) in 10.07s - cargo test --test adapt_linear_time (main, 9c5b028): test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.08s - the same file against pre-#623 main (108b2a2, bbc9583^): test result: FAILED. 0 passed; 2 failed; 0 ignored; 0 measured; 0 filtered out; finished in 35.12s 10 000 list items took 17.570090167s to adapt took 17.506552417s to adapt so the guards bite on the regression they name: 17.5 s before, 0.08 s after, against a 10 s threshold. Next step: none; #627 carries the fuzzer itself. Implementation-Agent: claude-opus-5 subagent of daniel-parent Commit-Executor: daniel-parent subagent Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz
This was referenced Sep 16, 2026
ItsAkilesh
pushed a commit
to ItsAkilesh/flashtex
that referenced
this pull request
Sep 18, 2026
…(#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 flash-tex#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 (flash-tex#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 flash-tex#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 flash-tex#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 flash-tex#623) and rebuilt. The fixed test failed: "800 tables took 1.391193958s (200 took 34.739917ms, 400 took 207.798417ms): quadratic regression suspected, see flash-tex#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
Adds
crates/render-pipeline/tests/adapt_linear_time.rs— two complexity guardsthat keep
adapter::adaptlinear in the number of\items and openenvironments. Test-only; no product code changes.
Why
These two tests existed briefly and were lost, and the thing they guard is the
headline fix of an already-merged PR.
bbc9583c) madeadaptlinear again with a per-documentSourceIndex(18 s → 0.19 s warm edit). Before it,
split_at_page_breaksaskedlist_stack_at,in_theorem_environmentandsetlist_callsabout everyblock, and each scanned the source from byte 0, so
adaptwasO(begins × bytes).
71d8fbff, withthese two timing tests. When render-pipeline: adapt is linear again — index list/theorem nesting once, memoise setlength (18 s → 0.19 s warm edit on #535) #623 landed, render-pipeline: mutation fuzzer for the pipeline and exact PDF route + 6 robustness fixes #627 reverted
71d8fbff(
bae83df4) to leave the adapter to render-pipeline: adapt is linear again — index list/theorem nesting once, memoise setlength (18 s → 0.19 s warm edit on #535) #623. That was the right call — but therevert took the tests with it.
source_index_matches_prefix_scans, whichchecks the index answers identically to the old prefix scans. That is an
identity test, not a cost one. So on main today, a change that reintroduces a
per-item source rescan produces correct output and passes every test.
The test file also records the six fuzz-found hang cases from #627's mutation
fuzzer ("hang in render") with their before/after release timings, so that
finding lives in the repo instead of in the commit message of a reverted commit
on an unpushed local branch:
itemizecentereachcentersThe thresholds are 10 s against a current cost of 0.08 s — orders of magnitude
of headroom, so these stay quiet on a loaded shared machine and only fire on a
genuine complexity regression.
Overlap check
GH-PIPELINE-FUZZ-2andGH-FLOAT-LIST-END-SCAN(daniel-parent@mac-m5pro-dq222).
GH-PIPELINE-FUZZisclosedagainst render-pipeline: mutation fuzzer for the pipeline and exact PDF route + 6 robustness fixes #627 —checked deliberately, since it differs from
GH-PIPELINE-FUZZ-2by onehyphen.
gh pr list --state open --search "adapt"and--search "index": no open PRadds adapt timing/complexity guards. render-pipeline: mutation fuzzer for the pipeline and exact PDF route + 6 robustness fixes #627 is the only open PR in this family
and it touches
tests/fuzz_regressions.rs, a different file — this PR adds anew file, so the two do not conflict.
Test results
cargo test --test adapt_linear_time --no-runon this branch (main9c5b028d),run as a separate step so a non-compiling target cannot be counted as green:
cargo test --test adapt_linear_timeon this branch:The same file applied to pre-#623 main (
108b2a29, i.e.bbc9583c^), to showthe guards actually bite on the regression they name:
17.5 s before, 0.08 s after, threshold 10 s.
Not done
render-pipeline: adapt is linear again — index list/theorem nesting once, memoise setlength (18 s → 0.19 s warm edit on #535) #623 carried that evidence when it merged.
test target and changes no library code. The 13 known
adapter.rs:1308debug_assertfailures are unrelated and pre-existing.🤖 Generated with Claude Code
https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz