Skip to content

fix(tests): compare the Codex bounded-time cases with an input of the same size - #2169

Merged
devswha merged 4 commits into
mainfrom
fix/codex-ratio-test-bound
Oct 28, 2026
Merged

devswha merged 4 commits into
mainfrom
fix/codex-ratio-test-bound

Conversation

@devswha

@devswha devswha commented Oct 28, 2026

Copy link
Copy Markdown
Owner

Follow-up to #2150. Addresses item 1 of #2155; the other #2155 items are left as they are.

Change

Test-only: server/codex.test.ts, plus the wording of #2150's unreleased changelog fragment.

#2150's bounded-time cases compared the thread CPU time of a small input with that of an input five times larger. That growth still moved on busy hosts:

Each case now compares its input with one of the same size that the code reads in one pass. The work both share (parsing, the screen) stays out of the ratio, while the regression's cost grows with the size:

case subject reference (same length) as written bound regression with it
unclosed links 5 answers of 8,000 chars, all unclosed ]( one closed link 1.2-1.8 10 cutAtLinkTargets as a regex split 403-506
large answer 40,000 links one link 1.4-9.4 20 cutAtLinkTargets with unshift (work per link grows) 145-247
citation 1,000 unmatched backtick runs ' instead of backticks 0.6-5.7 20 each unmatched delimiter searches the rest of the line 670

The "as written" ranges cover every loaded run below.

The helper (cpuGrowth, now cpuRatio) also takes a fix for a problem Codex reproduced, which predates this PR. Without a thread clock (Windows), process.cpuUsage counts in steps of about 16 ms, and only the first reference run was checked against the 20 ms floor. A later, warmer run could read 0, which made the ratio NaN or Infinity. The least reference of each set of three is now checked, and the set is timed again over twice the runs while it is too short. On that clock the floor is 100 ms.

#2155 item 1: the three cases get a 30 s timeout, so direct runs without --timeout do not hit Bun's 5 s default on a busy host. The large-answer case also reads 8 candidates instead of 32: the ratio does not depend on the count, and with 32, six runs sharing two cores took up to 11.6 s.

Known limit: a reference of the same size bounds the cost tied to what the regression reacts to (unclosed links, links, backtick runs). It does not catch a cost that grows with the text's length alone, which both inputs share. The doc comment says so.

Proof

SHAs below are from before the rebase onto bcd75e0, with no conflicts: f49d460e = ec224ec, 7f3515df = 057d4ed, 83412911 = a6780c6, ff480649 = baf772e. bun run check fast passed on the rebased head as well.

All runs use this host's thread clock unless noted. Logs are in the lane's .omo/run.

  • Load, final test code (83412911): 30 rounds through dori heavy, alongside bun run check fast. Each round ran the real file without --timeout plus five ratio-logging copies at once.
    • 0 failures; 150 samples per case, the highest as follows. Unclosed links: max 1.78 (median 1.56). Large answer: max 9.42 (median 3.09). Citation: max 5.74 (median 1.45).
    • The direct runs passed 30 of 30 (75 tests each). The slowest matcher case took 963 ms.
    • The citation bound then went from 10 to 20 (ff480649). Only the bound changed, so these runs still hold.
  • Two cores, six copies at a time (taskset): 30 rounds and 0 failures (unclosed max 1.68, large max 8.03, citation max 3.46).
  • Mutants: each fails only its own case.
    • Regex split: 10 of 10 runs, at 403 to 506 against a bound of 10.
    • unshift: 145 to 247 against 20.
    • Citation tail search: 670 against 20. The other citation tests still pass with it.
  • Coarse clock, modeled on Linux: the thread clock is forced off and process.cpuUsage is floored to 15.625 ms per user/system counter, which is Codex's model.
  • bun run check fast: ok on ff480649 (7,904 pass, 0 fail).

Reviews

  • omo-native-code-reviewer (f49d460e): PASS, LOW findings only. Changes made from them: the changelog no longer overclaims, and the known limit is in the doc comment. Left as follow-ups: LOW-1 (the large reference's GC share) has headroom under its bound; LOW-5 (neither link case reaches matchShortCodexAnswers's second loop) was already true before this PR.
  • Codex Sol 6.1 Fast xhigh:
    • Round 1 (f49d460e): BLOCK on one MEDIUM, the coarse-clock zero reference above, which also reproduces on fix(tests): measure what the code controls in three tests that failed on busy hosts #2150. It is fixed in 7f3515df. Its LOW (changelog wording) is fixed too.
    • Round 2 (7f3515df): PASS, no open findings, and both earlier findings resolved.
      • It checked the helper under a controlled clock: a third reference that turns to 0 after calibration is discarded, then retimed over twice the runs.
      • It repeated the coarse-clock model: 36 of 36 cases passed, and no accepted reference was below 109.375 ms.
    • Not reviewed by Codex: the two commits after round 2 change only parameters, both measured above.
      • 83412911 doubles the unclosed answers to 8,000 characters. With 4,000, the regex split read as low as 85 under load.
      • ff480649 raises the citation bound from 10 to 20.
  • CodeRabbit is not needed: test-only change.

… same size

The CPU-time growth from a small input to a five times larger one, which
#2150 bounded, still moved on busy hosts: the unclosed-links case (3x as
written, bound 8) read 10.8 on a GitHub runner, and under local load the
large-answer and citation cases crossed their bounds too (10.3 vs 10,
45.5 vs 40). Each case now times its input against one as large that the
code reads in one pass, so the work both share stays out of the ratio,
and a quadratic scan still costs a multiple that grows with the size.
The matcher cases also get a 30 s timeout, for direct runs without
--timeout on a busy host (#2155).
Codex's review: without a thread clock (Windows), process.cpuUsage counts
in steps of about 16 ms, and only the first reference run was checked
against the 20 ms floor. A later, warmer run could read none, so the
ratio read NaN or Infinity (5 of 30 runs on a modeled coarse clock, and
the parent commit fails the same way). The least reference of each set
of three is now checked, and the set is timed again over twice the runs
while it is short; on that clock the floor is 100 ms, several steps.

The large-answer case reads 8 candidates instead of 32: the ratio does
not depend on how many, and six runs sharing two cores took up to 11.6 s
with 32. The citation case gets the 30 s timeout too, which it needed on
the modeled coarse clock under that load.
Under load the regex-split regression read as low as 85 against the
bound of 10 with answers of 4,000 characters. Its multiple grows with
the length while the as-written one does not: with 8,000 it read 403 to
506 (10 runs) and the code as written 1.18 to 1.76 (30 runs, at most
505 ms each), all at once on one host.
Across 450 loaded runs the citation case read 0.6 to 5.7 as written,
the top one outlying (the rest under 3.5); its regression reads about
670. A bound of 20, as the large-answer case has, keeps a 33 times
margin to the regression and more room for a busy runner.
@coderabbitai

coderabbitai Bot commented Oct 28, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 22 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration
Commits

Reviewing files that changed from the base of the PR and between bcd75e0 and baf772e.

Files selected for processing: 2
  • changelog.d/timing-flakes-under-load.md
  • server/codex.test.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@devswha

devswha commented Oct 28, 2026

Copy link
Copy Markdown
Owner Author

The bundle (macos-15, darwin-universal) failure is not from this change: scripts/build-remote-bundle.ts stops with TimeoutError: The operation timed out. on the macOS arm64 runner. That happened in the first attempt and again in a rerun of only the failed job. The same job fails on fix/sidebar-token-snapshots in its current run too. This PR changes only server/codex.test.ts and a changelog fragment, and that job is not a required check. Fast checks, which run server/codex.test.ts, passed.

@devswha

devswha commented Oct 28, 2026

Copy link
Copy Markdown
Owner Author

Merging baf772e: omo-native-code-reviewer and Codex both pass this head. It fixes the CPU-ratio flake from #2150 that failed Fast checks on #2158 (10.8, 8.3) and #2161 (9.1). It is test-only, every quadratic mutation still fails its case by a wide margin, and 26 direct runs under heavy load passed, with and without --timeout. The required checks are green, and CodeRabbit did not review this head. omo's MEDIUM (a cost that grows with length alone now cancels out, a limit the PR states) and the LOW notes go to a follow-up issue.

@devswha
devswha merged commit 391b906 into main Oct 28, 2026
32 of 34 checks passed
@devswha
devswha deleted the fix/codex-ratio-test-bound branch October 28, 2026 04:43
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