Skip to content

perf(rust): build the oracle declaration table once per file - #10469

Merged
EffortlessSteven merged 5 commits into
mainfrom
claude/rust-test-file-release-10363
Oct 25, 2026
Merged

EffortlessSteven merged 5 commits into
mainfrom
claude/rust-test-file-release-10363

Conversation

@EffortlessSteven

Copy link
Copy Markdown
Member

Summary

A very large Rust test file made ripr check cost quadratic time. The assertion classifier cached its declaration table by comparing the whole file against a stored copy on every assertion, so each assertion paid a full-file memcmp. Ten of ten cold gdb samples on a 4 MB file sat in that comparison. The parser and lexical paths now build the table once per file and pass it in; classify_assertion_in is test-only.

Release build, cold ripr check on generated single-file crates: 1 MB 39.8 s before (this branch's first attempt, which rebuilt per function) and now 2.6 s; 2 MB 5.5 s; 4 MB 34.9 s before and now 10.8 s. Scaling is linear. The remaining cost is the cold fact build and is not addressed here.

Swarm / Source Boundary

  • ordinary feature, analyzer, editor, docs, spec, fixture, badge, dependency, or repo-ops development for ripr-swarm

Source-of-truth Links

Proposal: none
Spec: none; verdict-neutral performance change
ADR: none
Plan item: experience tracker #9278
Governing issue or accepted claim: #10363
Acceptance delta (one sentence): Cold analysis of a very large single test file scales linearly instead of quadratically, with identical verdicts.

Candidate Relationships

Candidate branch: claude/rust-test-file-release-10363
Stack parent or prerequisite PR (if any): none
Proposed replacement of PR (if any; not yet accepted): none
Acceptance retained from a replaced candidate (if any): none
Accepted winner and losing candidate disposition (when decided): single candidate

Scope

  • Classifier takes a prebuilt LocalDecls; callers in syntax/ra.rs, syntax/lexical.rs and oracles/scan.rs build it per file.
  • Test replaced: the cache-count test becomes a check that a table belongs to its own source.

Proof

  • cargo test -p ripr --lib -- oracles syntax: 496 passed.
  • cargo xtask precommit: exit 0.
  • Not run locally: full workspace tests, goldens on a fresh main, hosted qualification. No verdict change is expected, since the classifier input is unchanged.

Generated by Claude Code

The table cache compared the whole file against its stored copy for every
assertion, so a very large test file cost quadratic time (4 MB cold: 35 s).
Callers now build the table once per file and pass it in.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WJr6YizPnC777wfxAd9ubU
@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@coderabbitai

coderabbitai Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

  • Ask an admin to enable usage-based reviews

Open in CodeRabbit

Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing.

Next included review available in 19 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available. Your 182 included PR review attempts over the past 7 days set your current allowance at 1 review per hour.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Essentials
  • Run ID: 0bc8dcc0-4282-4954-9521-059d7d44f802
Commits

Reviewing files that changed from the base of the PR and between c923f0d and d96d6d4.

Files selected for processing: 9
  • changelog.d/10363-oracle-declaration-table-once-per-file.md
  • crates/ripr/src/analysis/extract/mod.rs
  • crates/ripr/src/analysis/extract/oracles/classify.rs
  • crates/ripr/src/analysis/extract/oracles/mod.rs
  • crates/ripr/src/analysis/extract/oracles/pattern_admission.rs
  • crates/ripr/src/analysis/extract/oracles/scan.rs
  • crates/ripr/src/analysis/rust_index.rs
  • crates/ripr/src/analysis/syntax/lexical.rs
  • crates/ripr/src/analysis/syntax/ra.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Copy link
Copy Markdown
Member Author

Review of record, head 17b9971

Two independent read-only agent reviewers on the diff against main, each from a different angle. CodeRabbit and Gemini are out of quota, so there is no provider review on this head.

Correctness and verdict neutrality: no findings. For each call site the new table is built from the same string the old code passed as decl_source. In syntax/ra.rs that is the whole file, built once per file. The per-function re-parse path builds from the function text, as before, and it is memoized. In syntax/lexical.rs it is the whole file, built once. In oracles/scan.rs it is the body, as before. No production caller of classify_assertion_in or extract_assertions_in is left stale.

Tests and performance: one finding, resolved. The replacement test checked verdicts only, so a per-function or per-assertion rebuild would have passed CI. I had hit exactly that regression in an earlier draft of this branch: the 1 MB cold run took 40 s. Resolved in 17b9971: a test-only counter on LocalDecls::from_source and one test per adapter (parser and lexical) asserting that a 40-test file builds exactly one table. Negative experiment: building per call in the lexical path makes it fail with "40 tests built 41 declaration tables".

Noted, not changed: the table is now built for every Rust file, including files with no assertions, where the old code built it lazily. It is one linear pass. The per-function re-parse build is bounded by the function text.

Evidence:

  • cargo xtask precommit passes on this head, with main merged (it carries the caplog golden fix).
  • cargo test -p ripr --lib -- oracles syntax: 496 passed before the new tests were added. The three declaration-table tests pass.
  • Release build, cold ripr check on generated single-file crates: 1 MB 2.6 s, 2 MB 5.5 s, 4 MB 10.8 s (35 s before). The scaling is linear.

Not run locally: the full workspace tests and hosted qualification.


Generated by Claude Code

@EffortlessSteven
EffortlessSteven marked this pull request as ready for review October 25, 2026 21:48
@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 2 potential issues.

Devin Review

Comment thread crates/ripr/src/analysis/syntax/ra.rs Resolved
Comment thread crates/ripr/src/analysis/syntax/ra.rs Resolved
…n that needs it (#10363)

A file without assertions no longer pays the masking pass. Adapter tests now
also pin that assertions read the file's own enum and that an assertion-free
file builds no table.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WJr6YizPnC777wfxAd9ubU

Copy link
Copy Markdown
Member Author

Required run 40237228303 on 17b9971 failed in Rust gates, in analysis::language::typescript::loop_count_guard::tests::binding_names_skip_defaults_and_keys (loop_count_guard.rs:2281, "(a, (" reduction is not bounded). That is a 2 s wall-clock assertion in a TypeScript file this PR does not touch, and it failed the same way on #10351 and #10478. It is tracked in #10483 with the TypeScript loop-bound lane as owner. No fix has landed yet, and I am not widening the threshold or adding a skip. Formatting, precommit, clippy, goldens, fixtures, verdict-corpus and base-merge all passed on this head. Nextest stopped at 4,957 of 21,597 tests, so the rest of the suite did not run on this head.

I am about to push a follow-up commit that answers two Devin findings (lazy table construction, and classification assertions in the adapter tests). That push starts a fresh required run, so I am not re-dispatching this one.


Generated by Claude Code

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Decision

  • Needs verification checks before upstream.

Verification questions

  • Confirm the displayed patch differs from the reviewed head described in the seeded thread, which already says LazyDecls and classification assertions landed in fadca31.
  • Confirm the seeded thread reports a required Rust gate failure in an unrelated TypeScript timing test and says the remaining 16,640 nextest cases did not run.

Refuted

  • The parser's function-local reparse path should reuse the whole-file declaration table, but this would broaden scope incorrectly.; refuted because: The uncached reparse path represents a function-only source and intentionally constructs a separate function-scoped table; this preserves prior scope semantics.

Evidence gaps

  • Model proof intent was rejected by deterministic validation.
  • The performance claim is supported by source-route mechanics, but independent executable proof is still pending after the ripr sensor failure.
  • The local sensor packet does not contain a completed cargo-test receipt, so the stated verdict-neutrality and adapter regressions are not independently witnessed in this review.

Copy link
Copy Markdown
Member Author

Review of record, head d96d6d4 (supersedes the 17b9971 review)

Since 17b9971: LazyDecls builds the table on the first assertion (Devin finding on assertion-free files; fixed in fadca31 with a test that such a file builds none), both adapter tests also assert that assertions read the file's own enum, and main was merged. Both agent reviews of the earlier head found nothing blocking; their one finding, the missing build-count guard, is closed.

Exact-head evidence: Ripr Rust Small Result succeeded on this head (run 40241428037, started after the merge-ready label was re-applied), mergeable state is clean, and both Devin threads are replied to and resolved. The earlier failure on 17b9971 was the unrelated TypeScript wall-clock test tracked in #10483; it did not recur. CodeRabbit and Gemini hit quota on this PR, so there is no provider review. The github-actions review on this PR asked for verification items only.

Merging under merge authority.


Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants