Skip to content

fix flaky table-lengths linearity guard (ratio -> absolute ceiling) - #767

Merged
d-q222 merged 1 commit into
mainfrom
agent/daniel-parent/flaky-table-lengths
Sep 16, 2026
Merged

d-q222 merged 1 commit into
mainfrom
agent/daniel-parent/flaky-table-lengths

Conversation

@d-q222

@d-q222 d-q222 commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

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_tables in
crates/render-pipeline/src/adapter.rs asserted 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 in
crates/render-pipeline/tests/adapt_linear_time.rs (#765).

Why

The ratio amplified scheduler noise: on PR #765 CI it failed as

800 tables took 5.044542ms, 200 took 587.834us: not linear
test result: FAILED. 163 passed; 1 failed; 1 ignored

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 few
hundred 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 a
ratio 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):

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 different
    test on a different machine/branch — no overlap.
  • python3 scripts/coord.py claims: only GH-659-MAC-FAILURE-EVIDENCE and
    GH-660-SNAPSHOT-ENV-GATE (daniel-muse-lead, unrelated tests/files) were
    active 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):

800 tables took 5.044542ms, 200 took 587.834us: not linear
test result: FAILED. 163 passed; 1 failed; 1 ignored

After, one --release run:

table lengths: 200 tables 308.875us, 400 tables 603.834us, 800 tables 1.200166ms
test adapter::tests::table_lengths_scale_linearly_with_the_number_of_tables ... ok
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 164 filtered out; finished in 0.01s

30x loop (--release), to show it does not flake: 30/30 test result: ok. t800 across all 30 runs ranged 1.162084ms–1.252833ms, t200
ranged 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_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; 0 ignored; 0 measured; 164 filtered out; finished in 8.21s

Then reverted that temporary change immediately (git diff confirmed a
clean, single-purpose diff before this commit).

Full adapter::tests:: module (--release), to confirm nothing else
broke: test result: ok. 38 passed; 0 failed; 1 ignored; 0 measured; 126 filtered out; finished in 0.30s.

Not done

🤖 Generated with Claude Code

https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz

…(#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
@d-q222
d-q222 merged commit 06eb911 into main Sep 16, 2026
21 of 22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant