Repository navigation
test(go): assert the region-index comparison count, not just table reads - #10619
2SinceJuly wants to merge 5 commits into
Conversation
Three tests bounded their behavior by wall-clock time, so a loaded CI shard could fail them without a regression. Each now asserts the deterministic work it actually cares about. - `selectorCandidates` counts the code units `shortText` reads from the 4 MiB text, which is exactly the read it bounds, and adds the under-limit case so the count is not satisfied by reading nothing. - `GoStringLiterals` counts indexed load regions and sections through a Proxy, so an accidental quadratic rescan exceeds the bound rather than merely running slower. - `appTaskDraftValues` drops the bound: the case already asserts the resolved references it produces. Refs morluto#10513 The remaining ~62 bounds in the issue are untouched; this is the first slice, one file per kind of measure.
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
[Low impact] The PR appears safe to merge, with no outstanding findings. SummaryAdds a comparison-count guard for the Go readable-region search.
Reviews (5) · Last reviewed commit: "Merge remote-tracking branch 'origin/mai..." · Reviewed by Greptile |
The bounded-work assertion only observed reads on the original load_regions and sections arrays. createReadableLoadRegionIndex copies region bounds into starts/ends before searching them, so replacing the binary search in contains with a linear scan stayed invisible: the counters still reported 25,000 region reads and 50,000 section reads while the search went quadratic. Thread an optional work counter through lastBigIntAtOrBelow and assert the merged-bound search stays within count * 32 comparisons. The linear scan now fails with 312,562,500 comparisons against an 800,000 bound.
|
Status: rebased? No — this is green as-is on its current base (all required checks pass, no conflicts), so nothing on my side is pending. One piece of information that may be useful for the merge decision: the three rewritten assertions verify the bounded work directly rather than the clock, so they cannot go red from a loaded shard. That is the concrete difference from the remaining ~62 bounds in #10513 — those still can. Question: is this first slice small enough to merge on its own, or would you rather I hold it until the rest of #10513 is reduced? I'm happy to keep it at 3 files and land the remainder separately. |
main already replaced all three wall-clock assertions with counted-work bounds, so keep its stronger versions and drop this branch's overlapping test rewrites; the countWork hook in GoStringLiterals stays.
The 11-15 merge into this branch resolved the test half of this change to main's version, leaving `countWork` threaded through `recoverGoStringLiterals` and `lastBigIntAtOrBelow` with no caller and no assertion. Main's replacement bounds container table reads, which still cannot see a linear scan inside `createReadableLoadRegionIndex`: the region bounds are copied into `starts`/`ends` before searching, so those counters stay flat however the search is written. Count comparisons instead and assert the merged-bound search stays within `count * 32`; the linear scan reaches 312,562,500 comparisons against an 800,000 bound.
|
Re-checked this one against Fixed in Verified locally: Scope is now one file's test plus the counter parameter, no production behavior change. If you'd rather take the comparison bound in a different form, say which and I'll reshape it. |
|
Found and fixed a real break on this branch, and trimmed what main had already absorbed. The break. Why it happened. Those two fields landed on What I changed. Merged current What remains is the one piece Verification (on the merged tree,
Diff is now |
|
Thanks. Closing as superseded: |
Summary
Three tests bounded their behavior by elapsed wall-clock time, so a loaded CI
shard could fail them without a regression. Each now asserts the deterministic
work it actually cares about.
Refs #10513. This is a first slice: roughly 62 further bounds in that issue stay
untouched.
Problem and expected behavior
expect(performance.now() - started).toBeLessThan(N)measures the runner, notthe code. The issue records a case (
#5050) where such a bound failed on aloaded shard with no change in behavior, and a 5 s pyc bound that ran in ~0.5 s
locally but 4–7 s on CI.
Expected: each of these cases fails when the work it guards grows, and does not
fail merely because the host is busy.
Change and scope
Main now bounds this test by container table reads (
#11610), but that cannotsee a linear scan inside
createReadableLoadRegionIndex: the region bounds arecopied into
starts/endsbefore searching, so the table counters stay at25,000 region and 50,000 section reads however the search is written.
src/go/GoStringLiterals.ts—recoverGoStringLiteralsandlastBigIntAtOrBelowtake an optionalcountWorkcallback and call it onceper comparison.
src/go/GoStringLiterals.test.ts— the indexed-literals case passes thatcallback and asserts the merged-bound search stays within
count * 32comparisons. Replacing the binary search with a linear scan reaches
312,562,500 comparisons against an 800,000 bound.
Main's version of the two desktop cases (
selectorCandidates,appTaskDraftValues) superseded this earlier slice, so they are unchanged here.No user-visible production behavior changed.
Contract and boundary impact
guidance in
docs/development/testing.md("a test deadline … is not aperformance assertion"). No new capability.
Expected effects:
Evidence and regression coverage
deliberately regressed source and failed there, then passed again once the
source was restored:
MAX_CHILD_TEXTearly return inshortText→ the 65-unitbound failed;
reads against the
count * 4bound, failed;refers_toassertion is what fails if reference resolution breaks.
Validation performed
npm run test:local -- src/domain/desktop/selectorCandidates.test.ts src/go/GoStringLiterals.test.ts src/domain/desktop/appTaskDraftValues.test.ts— 60 passed (3 files)npm run check:fast— typecheck and lint succeedednpx oxfmt --check <the three files>— all correctly formattedCompatibility, safety, and release
Author readiness
Human owner: @2SinceJuly
Before merge
type(scope): outcome.