Skip to content

perf(check): memoize helper-credit closure-callback syntax reads per run (#12947) - #13741

Merged
EffortlessSteven merged 5 commits into
mainfrom
perf/diff-check-wall-2
Nov 8, 2026
Merged

EffortlessSteven merged 5 commits into
mainfrom
perf/diff-check-wall-2

Conversation

@EffortlessSteven

@EffortlessSteven EffortlessSteven commented Nov 8, 2026 •

Copy link
Copy Markdown
Member

Governing issue or accepted claim: #12947

Acceptance delta (one sentence): The helper-credit pass's closure_argument_positions and invoked_callback_params syntax reads are memoized per run, so the overlapping admission-core and main index builds of a diff check stop re-parsing the same test and helper bodies.

Change

  • Routes closure_argument_positions and invoked_callback_params (crates/ripr/src/analysis/syntax/ra/closure_callbacks.rs) through the run-scoped syntax memo (run_memo), with new Product variants. The key is a SHA-256 over the full text plus the length-prefixed helper name.
  • After merging main: perf(analysis): scan each source once per run across overlapping reach indexes (#13577) #13729 already memoized passes_call_making_closure (Product::CallMakingClosure). The conflict was resolved by keeping main's version of that reader and dropping this PR's duplicate variant. This PR now adds only the two remaining readers.
  • Test memoized_callback_reads_match_uncached_and_key_on_text_and_helper: it enters a memo scope twice and calls the readers repeatedly. It asserts each result equals the uncached function's. Its premises are that a changed helper name, test text or helper text gives a different answer, so a key that ignored any of them would fail.

Measurement (before the merge with main, so it includes the now-upstream reader)

Warm check --base HEAD~1 on ripr-swarm, 4 alternating A/B pairs with separate warm caches. Base 0c2d378 had a median of 49.7 s and this branch 48.1 s. Second-build helper credit went from about 3.4 s to about 1.25 s. On top of #13729, the remaining gain from the two readers is smaller and not separately measured. check --format json was byte-identical against base on 3 diffs (at the pre-merge head).

Proof

  • cargo xtask precommit passed at 760e3f6. 92 focused lib tests passed at 760e3f6.
  • The new test and the merge resolution were not compiled locally: lib-test builds were OOM-killed on the shared 15 GB box (signal 9) while another build ran. Hosted CI supplies that run.
  • Independent fresh-reviewer source review: SOURCE_REVIEW_READY on 760e3f6, no blocking defects.

🤖 Generated with Claude Code

https://claude.ai/code/session_01UNUoLWvJLNTjPAkUKhsj5V

…run (#12947)

credit_same_file_assertion_helpers re-parsed the same test and helper bodies
(passes_call_making_closure, closure_argument_positions,
invoked_callback_params) in the second index build of a diff check. Route the
three pure reads through the existing run-scoped syntax memo so the main
index reuse skips them. Output is byte-identical.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UNUoLWvJLNTjPAkUKhsj5V
@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 Nov 8, 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 50 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available. Your 152 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: db4a8724-3386-4824-ba33-e93f130bf697
Commits

Reviewing files that changed from the base of the PR and between f1a321f and aa304e6.

Files selected for processing: 4

  • changelog.d/12947-memoize-helper-credit-closure-parses.md
  • crates/ripr/src/analysis/syntax/ra/closure_callbacks.rs
  • crates/ripr/src/analysis/syntax/ra/closure_callbacks/tests.rs
  • crates/ripr/src/analysis/syntax/run_memo.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@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 1 potential issue.

Devin Review

@github-actions

github-actions Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

ripr static exposure check

Commit aa304e6c53f9 · run · advisory, static evidence only (not a mutation run).

#ripr agent static-advisory base=f1a321f00eca794a41c6bfa7dea15b0b6566ba61 findings=10 gaps=0 static_unknown=10
static_unknown|crates/ripr/src/analysis/syntax/ra/closure_callbacks.rs:58|fn closure_argument_positions_uncached(test_text: &str, helper: &str) -> Option<…|missing=-|test=t1|id=probe:crates_ripr_src_analysis_syntax_ra_closure_callbacks.rs:static_unknown:157a99a1
static_unknown|crates/ripr/src/analysis/syntax/ra/closure_callbacks.rs:49|crate::analysis::syntax::run_memo::memoize_with( crate::analysis::syntax::run_me…|missing=-|test=t1|id=probe:crates_ripr_src_analysis_syntax_ra_closure_callbacks.rs:return_value:8660e785
static_unknown|crates/ripr/src/analysis/syntax/ra/closure_callbacks.rs:56|}|missing=-|test=t2|id=probe:crates_ripr_src_analysis_syntax_ra_closure_callbacks.rs:static_unknown:b77b1478
static_unknown|crates/ripr/src/analysis/syntax/ra/closure_callbacks.rs:516|crate::analysis::syntax::run_memo::memoize( crate::analysis::syntax::run_memo::P…|missing=-|test=t1|id=probe:crates_ripr_src_analysis_syntax_ra_closure_callbacks.rs:return_value:0409cf44
static_unknown|crates/ripr/src/analysis/syntax/ra/closure_callbacks.rs:522|}|missing=-|test=t2|id=probe:crates_ripr_src_analysis_syntax_ra_closure_callbacks.rs:static_unknown:7f861325
t1=crates/ripr/src/analysis/syntax/ra/closure_callbacks/tests.rs:971 memoized_callback_reads_match_uncached_and_key_on_text_and_helper relational_check `assert_ne!( closure_argument_positions_uncached(test, "run"), closure_argument_p…`
t2=crates/ripr/src/analysis/syntax/ra/closure_callbacks/tests.rs:624 a_name_bound_earlier_to_a_call_making_closure_is_withheld exact_value `assert_eq!(passes_call_making_closure(test, "run"), expected, "{shape}");` miss=no_call_path
+5 more limited findings not shown; `--format json` lists all
stop=ripr cannot tell from reading the code whether tests would notice; the documented route is a co-located test that reaches and observes the changed behavior; static advisory, not runtime proof
limits=static_unknown:10
next=ripr explain --root . --base f1a321f00eca794a41c6bfa7dea15b0b6566ba61 --committed --mode draft --format agent probe:crates_ripr_src_analysis_syntax_ra_closure_callbacks.rs:static_unknown:157a99a1
verify=refused|outcome=complete_with_findings|findings=10|exposed=0|reason=gaps_remain

Took 77s.

…text and helper (#12947)

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

@EffortlessSteven EffortlessSteven left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

SOURCE_REVIEW_READY

Head ed198a4. An independent fresh-reviewer pass on 760e3f6 found no blocking defects. It checked that the memo key is a SHA-256 over the full text plus a length-prefixed helper name with a distinct Product per reader, that the *_uncached bodies are pure in their inputs, that the memo is thread-local and run-scoped with entries cleared at scope exit, and that memory growth is small (digest plus small value). Its one gap, which Devin also raised, was that no scoped test exercised the memo path. ed198a4 adds that test and changes no production code. The local lib-test compile was OOM-killed on the shared box, so hosted CI supplies the run.


Generated by Claude Code

@github-actions

github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

merge-ready is set, but this PR conflicts with main (head ed198a41), so GitHub creates no test-merge ref and no qualification run can start. Merge main into the branch and resolve the conflicts, then remove and re-apply merge-ready.

# Conflicts:
#	crates/ripr/src/analysis/syntax/ra/closure_callbacks.rs
#	crates/ripr/src/analysis/syntax/ra/closure_callbacks/tests.rs
#	crates/ripr/src/analysis/syntax/run_memo.rs

@EffortlessSteven EffortlessSteven left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

SOURCE_REVIEW_READY

Head 19e6209. This is a merge of main that resolves the conflict with #13729, which memoized passes_call_making_closure upstream. The resolution keeps main's reader and its Product::CallMakingClosure, drops this PR's duplicate PassesCallMakingClosure variant, and keeps the memo wrappers for closure_argument_positions and invoked_callback_params. Both tests are kept: main's parse-count test and this PR's equality test. The merged files parse under rustfmt. The earlier independent review of the two remaining readers (key, purity, scope, memory) is unchanged. The merged tree was not compiled locally because the shared box was out of memory; hosted CI is the proof.


Generated by Claude Code

EffortlessSteven commented Nov 8, 2026 •

Copy link
Copy Markdown
Member Author

Ripr Rust Small on GitHub Hosted / Rust gates failed on 19e6209 in check-fixture-contracts: fixtures/module_reach_control_qualified/SPEC.md says probe:src_inner.rs:return_value:438cae72 is weakly_exposed while expected/check.json says exposed. This PR does not touch that fixture. Main is red on the same check, from the interaction of #13613 (machine-checked fixture classes) and #13668. Fixes are already open in #13773, #13774 and #13778, so I'm not adding a fourth copy here. I'll merge main into this branch once one of them lands and re-request qualification.

Rust-only feature lane also failed on 19e6209, in cli_reference_matches_the_binary (crates/ripr/tests/cli_reference_doc.rs:139), a CLI reference doc test. This PR changes no CLI surface. The new memoized_callback_reads_match_uncached_and_key_on_text_and_helper test and main's call_making_closure_answers_parse_once_per_pair_inside_a_run_scope both pass in that lane.


Generated by Claude Code

@EffortlessSteven EffortlessSteven left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

SOURCE_REVIEW_READY

Head 0fd78d1. This is a clean merge of main that brings in the module_reach_control_qualified fixture-class fix (#13773). The PR's own changes are the same as the reviewed 19e6209, and on that head the new memo test and main's parse-count test passed in the hosted Rust-only lane.


Generated by Claude Code

@EffortlessSteven EffortlessSteven left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

SOURCE_REVIEW_READY

Head aa304e6. This is a clean merge of main that brings in the CLI reference rebless (#13811), which fixes the cli_reference_matches_the_binary failure on 0fd78d1. That failure came from main and is not in this PR's diff. The PR's own changes are the same as the reviewed heads.


Generated by Claude Code

@EffortlessSteven
EffortlessSteven merged commit 98497e8 into main Nov 8, 2026
71 of 72 checks passed
@EffortlessSteven
EffortlessSteven deleted the perf/diff-check-wall-2 branch November 8, 2026 18:36
EffortlessSteven pushed a commit that referenced this pull request Nov 8, 2026
Resolve against #13768 (process fact memo threaded through the shared
batch parse), #13821 (one embed scan per file) and #13741 (closure
callback memo products). The embed scan is now memoized whole; the
separate directive and shadow memo products are dropped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UNUoLWvJLNTjPAkUKhsj5V
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