Skip to content

perf(owner-pin): fan the workspace constant table parse out off the pool - #14880

Merged
EffortlessSteven merged 1 commit into
mainfrom
perf/cold-check
Nov 16, 2026
Merged

EffortlessSteven merged 1 commit into
mainfrom
perf/cold-check

Conversation

@EffortlessSteven

@EffortlessSteven EffortlessSteven commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

Summary

  • On a cold ripr check (empty RIPR_CACHE_DIR), the single-seam review stage runs on the main thread over the whole-workspace index. Most of that stage went to workspace_constant_table, which parses every corpus file that contains const or static, one file after another on one thread. gdb samples put it at 4 of the 6 samples in that stage.
  • The per-file parses are independent, so they now go through the existing map_scans. Off the pool they fan out over rayon. On a pool worker they stay in line under the perf: share RelatedTestCandidateIndex memos across threads so per-probe classify can run in parallel (#8629 follow-up) #8756 memo-lock guard, so there is no new nested-parallelism risk. Rows are folded back in index file order, so the table and the output stay byte-identical.

Swarm / Source Boundary

  • ordinary feature, analyzer, editor, docs, spec, fixture, badge,
    dependency, or repo-ops development for ripr-swarm
  • repair or follow-up for a same-repo swarm PR
  • swarm-only CI, runner, routing, source-of-truth, or agent-operating
    surface
  • other swarm-scoped work:

Source-of-truth Links

Proposal: n/a
Spec: n/a
ADR: n/a
Plan item: n/a
Governing issue or accepted claim: #12947
Acceptance delta (one sentence): The cold ripr check single-seam review stage builds the workspace constant table over the rayon pool rather than on one thread. On the 216-seam ripr-swarm diff at 1e6f55b this cuts that stage from about 10.7 s to about 5.7 s, and the JSON output stays byte-identical.

Candidate Relationships

Candidate branch (GitHub PR head is authoritative after publication): perf/cold-check
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): n/a
Accepted winner and losing candidate disposition (when decided): n/a

No open or merged PR touches workspace_constant_table. A search for workspace_constant_table, single_constant_value and workspace_constants found only the closed #8077, #8533, #8873, #8915 and #8963. This change is separate from #13911, #14850, #13850, #14214 and #14865.

Scope

  • crates/ripr/src/analysis/classify/owner_pin.rs: workspace_constant_table now maps a new per-file file_constants through map_scans and folds the results in file order.
  • One unit test.
  • One changelog fragment.

Scope Classification

  • One production behavior
  • One public contract
  • One architectural seam
  • Docs/spec/test-only evidence package
  • Other:

Production delta:

  • The workspace constant-table scan runs in parallel when it is built off the rayon pool. The extraction logic and the result are unchanged.

Evidence/support delta:

  • New test the_workspace_constant_table_fans_out_off_the_pool_with_the_same_table.

Single acceptance criterion:

  • Off the pool the scan fans out; on a pool worker it runs in line. The table is identical either way and rows keep index file order.

Non-goals:

  • The other cold-only costs seen in the profile, listed under Claim Boundary.

Support-tier Impact

  • none
  • updates docs/status/SUPPORT_TIERS.md
  • changes a README, release, docs, CLI, JSON, editor, CI, or package claim

Claim/proof notes:

  • Performance only. Output is unchanged.

Policy Impact

  • none

Ledger or exception notes:

  • n/a

Proof

# Profile and A/B: release build with debuginfo, detached ripr-swarm at 1e6f55b3e9,
# `ripr check --base HEAD~1 --format json`, fresh RIPR_CACHE_DIR for every cold run,
# RIPR_REPO_EXPOSURE_LATENCY_TRACE=1, 4-core shared box
cargo test -p ripr --lib the_workspace_constant_table   # ok
cargo test -p ripr --lib classify::owner_pin            # 407 passed
cargo check -p ripr --lib --tests                       # ok
cargo fmt --check                                       # ok
cargo xtask precommit                                   # exit 0

A/B, three alternating cold pairs (base b7191cdee9 against this head), plus one warm run each:

run base wall fix wall base single-seam stage fix single-seam stage
cold 1 96.1 s 88.8 s 10.89 s 5.74 s
cold 2 91.5 s 89.2 s 10.81 s 6.12 s
cold 3 93.7 s 78.7 s 10.47 s 5.30 s
warm 36.6 s 36.6 s (persisted, not run) (persisted, not run)
  • The single-seam stage is the evidence_for_seams_progress processed_1_of_1 trace phase. It drops by a mean of 5.0 s, about 5.5% of cold wall time.
  • Mean cold wall time is 93.7 s for base and 85.6 s for the fix. Wall time on this shared box is noisy, so the phase timing is the reliable number.
  • Warm runs are unchanged: the stage is served from the persisted scoped inventory.
  • cmp shows the JSON is byte-identical between base and fix for all three cold pairs and for warm, and identical between warm and cold.

Negative experiment: I restored owner_pin.rs to origin/main and kept the new test. The test then fails with the per-file constant scan from a thread outside the pool must fan out (left: None, right: Some(true)). With the fix restored it passes.

Result, failures, or skipped proof:

  • The full lib-test build with 2 jobs was OOM-killed on this 14 GB box. With CARGO_BUILD_JOBS=1 the filtered runs above completed.
  • The full workspace test suite was not run locally; hosted CI covers it.

Claim Boundary

May claim: the cold single-seam review stage on this diff is about 5 s faster, and output is unchanged.

Must not claim: a general cold-check speedup beyond this stage, or any change to warm behaviour.

Other cold-only costs observed but not addressed here:

  • first index_cached_parse: about 12 s cold against 2.2 s warm;
  • diff_drop_unreached_test_files module-tree parses: 5.1 s against 0.9 s;
  • the whole-workspace index rebuild for the review stage: about 12 s, with 668 misses;
  • evidence_context over 30,669 tests: about 8.9 s.

Rollback

Revert this commit. The change is self-contained.

Spec-Test-Code Traceability

Static Language Check

  • Static output avoids killed, survived, untested, proven, and adequate.
  • Unknowns include stop reasons where applicable.

CI Economics

n/a

Engineering Check

  • No new panic, unwrap, expect, todo, or unimplemented in production code.
  • No new panic, unwrap, expect, todo, or unimplemented in tests.
  • New non-Rust programming files are allowlisted with owner, surface, and reason.
  • New generated, dependency, process-spawn, or network surfaces are allowlisted with owner and reason.
  • Errors are reported with actionable context.
  • Public JSON/schema changes are documented.

Gates

  • cargo fmt --check
  • cargo xtask precommit
  • Full workspace check, test, clippy and package gates are left to hosted CI.

Generated by Claude Code


Devin Review

The workspace const/static table parsed every corpus file on one thread.
On a cold `ripr check` the single-seam review stage builds it on the main
thread over the whole-workspace index, where it was most of that stage's
~10.7 s. Route the independent per-file parses through `map_scans`, so off
the pool they fan out over rayon and on a pool worker they stay in line
under the #8756 memo-lock guard. Rows fold in index file order, so the
table and the check output are unchanged (#12947).

Co-Authored-By: Claude Opus 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 16, 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 20 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available. Your 145 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: 0b3c4565-0733-442f-b573-142abd0a5401
Commits

Reviewing files that changed from the base of the PR and between 7eb1555 and c62cc6d.

Files selected for processing: 3

  • changelog.d/12947-parallel-workspace-constant-table.md
  • crates/ripr/src/analysis/classify/owner_pin.rs
  • crates/ripr/src/analysis/classify/owner_pin/tests.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: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

@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: c62cc6d. Reviewed read-only by a fresh reviewer who did not write the change; nothing blocks.

Equivalence. The old loop pushed every row into BTreeMap<String, Vec<_>> in index order without deduplicating. Consumers such as single_constant_value treat multiple matches as ambiguous. The new code collects index.files() once, and map_scans keeps index order on both branches. The fold zips the rows back and pushes them the same way. The per-file row order, the macro-call and text-read paths, and the r# strip are unchanged. The old continues became early returns in file_constants.

Re-entrancy. On a pool worker map_scans stays serial (#8756 guard). Off the pool, the caller holds the OnceLock init for workspace constants, and the workers never touch that memo or any borrowed RefCell. The thread-locals on the parse path are pure memos keyed by text (MASK_MEMO), so where a parse runs changes hit rates only, never output. The same exposure already exists for the map_scans macro scan.

Tests. the_workspace_constant_table_fans_out_off_the_pool_with_the_same_table fails with left: None, right: Some(true) when the change is reverted. It pins the serial path on a pool worker and that the off-pool and pool tables are equal. It also pins cross-file row order, including a file read only as text, plus the macro path and a file that adds no rows.

Proof:

  • cargo test -p ripr --lib classify::owner_pin passes (407 tests).
  • cargo xtask precommit exits 0.
  • JSON cmp is identical on 3 cold pairs and warm.
  • The cold single-seam stage drops from 10.7 s to 5.7 s.
  • Not run locally: the full workspace tests, clippy and Windows, which hosted CI covers.

Generated by Claude Code

@EffortlessSteven
EffortlessSteven added this pull request to the merge queue Nov 16, 2026
Merged via the queue into main with commit cd1d1a2 Nov 16, 2026
22 checks passed
@EffortlessSteven
EffortlessSteven deleted the perf/cold-check branch November 16, 2026 13:43
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