Skip to content

feat(xtask): add targeted rerun benchmark receipt - #1531

Merged
EffortlessSteven merged 15 commits into
mainfrom
perf/targeted-rerun-benchmark
Jul 11, 2026
Merged

EffortlessSteven merged 15 commits into
mainfrom
perf/targeted-rerun-benchmark

Conversation

@EffortlessSteven

Copy link
Copy Markdown
Member

Summary

  • Add cargo xtask targeted-rerun-benchmark for a checked cold/full versus targeted rerun receipt.
  • Register a controlled Rust benchmark workspace, isolated cache execution, explicit cache-reset invalidation, and parity verification.
  • Record the measured SPEC-0123 receipt and policy/traceability links.

Swarm / Source Boundary

This PR targets EffortlessMetrics/ripr-swarm, the normal development trunk for trusted same-repo ripr work.

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

No release, signing, marketplace, or publishing surfaces are changed.

Source-of-truth Links

Proposal: n/a
Spec: docs/specs/RIPR-SPEC-0123-targeted-rerun.md
ADR: n/a
Plan item: perf/targeted-rerun
Active goal: rust-one-shot-evidence-to-repair
Issue: #1424

Scope

  • Add a repo-facing benchmark command and JSON/Markdown receipt.
  • Add a controlled benchmark fixture and the required policy allowlist entries.
  • Document the benchmark contract, measured handoff, and traceability.

Scope Classification

This PR is scoped by:

  • Docs/spec/test-only evidence package
  • One public command surface

Production delta:

  • No analyzer or rerun behavior changes; this is a benchmark/proof surface for the shipped targeted-rerun path.

Evidence/support delta:

  • A named fixture demonstrates cold full, cold targeted, warm targeted, explicit cache reset, and parity outcomes.

Single acceptance criterion:

  • The registered benchmark emits a passing receipt with warm targeted p50 <= 30 seconds and at least 5x speedup over cold full p50.

Non-goals:

  • No universal latency claim, runtime mutation claim, correctness claim, coverage claim, or complete broader-input invalidation attribution.

Support-tier Impact

  • none

Claim/proof notes:

  • No support-tier promotion; the receipt is scoped to the named fixture, revision, configuration, and runner class.

Policy Impact

  • file policy
  • dependency
  • package boundary

Ledger or exception notes:

  • The benchmark fixture manifest is explicitly allowlisted in workspace-shape and dependency policy.
  • The fixture files are allowlisted as a controlled benchmark surface.

Proof

cargo xtask targeted-rerun-benchmark --root benchmarks/targeted_rerun_benchmark/input --changed-test tests/targeted.rs --samples 5 --timeout-ms 120000
cargo test -p xtask targeted_rerun -- --test-threads=1
cargo fmt --check
cargo xtask check-fixture-contracts
cargo xtask check-traceability
cargo xtask check-output-contracts
cargo xtask check-static-language
cargo xtask check-file-policy
cargo xtask check-process-policy
cargo xtask check-spec-format
cargo xtask check-workspace-shape
cargo xtask check-dependencies
cargo-allow --version  # 0.1.10
cargo-allow doctor --profile spec-system --config .allow/profiles/spec-system.toml --format json --output target/cargo-allow/spec-system-doctor.json
cargo-allow check --profile spec-system --config .allow/profiles/spec-system.toml --mode audit --format json --output target/cargo-allow/spec-system.json
cargo-allow worklist --profile spec-system --config .allow/profiles/spec-system.toml --format json --output target/cargo-allow/spec-system-worklist.json
cargo xtask check-pr
git diff --check

Result, failures, or skipped proof:

  • All listed proof passed. The benchmark receipt reports cold full p50 1,972 ms, warm targeted p50 104 ms, 18.9615x speedup, parity matched, and recomputed_file_facts after explicit cache reset.

Claim Boundary

This supports the named benchmark fixture, revision 938eb56, configuration, and local Windows x86_64 runner class. It does not support universal latency, runtime mutation behavior, correctness, coverage adequacy, complete test quality, or broader invalidation attribution.

Rollback

Revert this PR; it removes only the benchmark command, fixture, receipt documentation, and associated policy/traceability entries. The targeted-rerun implementation remains unchanged.

Spec-Test-Code Traceability

  • Spec: docs/specs/RIPR-SPEC-0123-targeted-rerun.md
  • Tests: xtask/src/reports/targeted_rerun.rs unit tests; controlled fixture under benchmarks/targeted_rerun_benchmark/input
  • Code: xtask/src/reports/targeted_rerun.rs, command registration and dispatch
  • Golden outputs: n/a; receipt outputs are generated under target/ripr/reports/
  • Metrics: docs/handoffs/2026-07-11-targeted-rerun-benchmark.md
  • ADR/learning: n/a

Static Language Check

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

CI Economics

  • LEM impact: n/a; no workflow change.
  • Workflows touched: none.
  • Branch protection impact: none.
  • Failure mode caught: benchmark regressions and parity/invalidation drift in the registered receipt.
  • Cheaper signal considered: focused benchmark and unit test run; aggregate check-pr still required.
  • Required lanes affected: none.
  • Advisory lanes affected: none.
  • On-demand/release lanes affected: none.
  • Labels that alter behavior: none.
  • Artifact families affected: local benchmark receipt only.
  • Rollback path: revert this PR.

Engineering Check

  • No new panic-family calls in production code or tests.
  • New benchmark fixture files are policy-allowlisted.
  • New process execution uses the centralized runner.
  • Public command/receipt fields are documented.

Gates

  • cargo fmt --check
  • cargo check --workspace --all-targets
  • cargo test --workspace
  • cargo clippy --workspace --all-targets -- -D warnings
  • cargo doc --workspace --no-deps
  • cargo xtask check-pr
  • policy, fixture, traceability, and cargo-allow checks listed above

@coderabbitai

coderabbitai Bot commented Jul 11, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

@EffortlessSteven, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 22 minutes

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).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: e89d7899-7c4d-4dea-a5f6-c63049baa191

📥 Commits

Reviewing files that changed from the base of the PR and between 3f2c890 and 6302664.

📒 Files selected for processing (17)
  • .ripr/goals/active.toml
  • .ripr/traceability.toml
  • benchmarks/targeted_rerun_benchmark/README.md
  • benchmarks/targeted_rerun_benchmark/input/Cargo.toml
  • benchmarks/targeted_rerun_benchmark/input/src/lib.rs
  • benchmarks/targeted_rerun_benchmark/input/tests/targeted.rs
  • docs/OUTPUT_SCHEMA.md
  • docs/handoffs/2026-07-11-targeted-rerun-benchmark.md
  • docs/specs/RIPR-SPEC-0123-targeted-rerun.md
  • plans/rust-one-shot-evidence-to-repair.md
  • policy/dependency_allowlist.txt
  • policy/non-rust-allowlist.toml
  • policy/workspace_shape.txt
  • xtask/src/command.rs
  • xtask/src/dispatch.rs
  • xtask/src/reports/mod.rs
  • xtask/src/reports/targeted_rerun.rs
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch perf/targeted-rerun-benchmark

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.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new benchmark command, cargo xtask targeted-rerun-benchmark, along with a controlled benchmark fixture workspace to measure the performance of the targeted rerun feature (SPEC-0123). It updates the project's policies, traceability records, and documentation to integrate this benchmark. Feedback on the implementation suggests using an RAII drop guard to guarantee cleanup of the temporary cache directory on early returns or panics, removing the redundant manual cleanup once the guard is in place, and explicitly verifying that the parity run passes for a more robust threshold check.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment on lines +32 to +34
let cache_dir = benchmark_cache_dir();
clear_cache(&cache_dir)?;
let envs = [(CACHE_ENV, cache_dir.to_string_lossy().into_owned())];

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The temporary cache directory cache_dir is currently only cleaned up at the very end of the targeted_rerun_benchmark function. If any of the benchmark runs fail or time out, the function returns early via the ? operator, leaving the temporary directory on disk.

Using an RAII drop guard ensures that the temporary directory is reliably cleaned up under all exit paths, including early returns and panics.

    let cache_dir = benchmark_cache_dir();
    struct CleanupGuard<'a>(&'a Path);
    impl Drop for CleanupGuard<'_> {
        fn drop(&mut self) {
            let _ = fs::remove_dir_all(self.0);
        }
    }
    let _guard = CleanupGuard(&cache_dir);
    clear_cache(&cache_dir)?;
    let envs = [(CACHE_ENV, cache_dir.to_string_lossy().into_owned())];

Comment on lines +97 to +99
crate::write_report("targeted-rerun-benchmark.md", &benchmark_markdown(&report))?;
let _ = fs::remove_dir_all(&cache_dir);
println!("Wrote target/ripr/reports/targeted-rerun-benchmark.json");

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

With the CleanupGuard active, the manual cleanup of cache_dir is redundant and can be removed.

Suggested change
crate::write_report("targeted-rerun-benchmark.md", &benchmark_markdown(&report))?;
let _ = fs::remove_dir_all(&cache_dir);
println!("Wrote target/ripr/reports/targeted-rerun-benchmark.json");
crate::write_report("targeted-rerun-benchmark.md", &benchmark_markdown(&report))?;
println!("Wrote target/ripr/reports/targeted-rerun-benchmark.json");

Comment thread xtask/src/reports/targeted_rerun.rs Outdated
Comment on lines +351 to +357
let threshold_pass = warm_targeted_p50 <= WARM_P50_TARGET_MS
&& cold_full_p50 >= warm_targeted_p50.saturating_mul(SPEEDUP_TARGET)
&& parity_state == "matched"
&& all_pass(cold_full)
&& all_pass(cold_targeted)
&& all_pass(warm_targeted)
&& all_pass(invalidation);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The threshold_pass check currently verifies that cold_full, cold_targeted, warm_targeted, and invalidation series all passed, but it does not explicitly check all_pass(parity).

While a failed parity run would result in parity_state being "unavailable" (which fails the "matched" check), explicitly verifying all_pass(parity) is more robust and self-documenting.

    let threshold_pass = warm_targeted_p50 <= WARM_P50_TARGET_MS
        && cold_full_p50 >= warm_targeted_p50.saturating_mul(SPEEDUP_TARGET)
        && parity_state == "matched"
        && all_pass(cold_full)
        && all_pass(cold_targeted)
        && all_pass(warm_targeted)
        && all_pass(invalidation)
        && all_pass(parity);

@codecov

codecov Bot commented Jul 11, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 23.76033% with 369 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
xtask/src/reports/targeted_rerun.rs 23.38% 367 Missing ⚠️
xtask/src/dispatch.rs 0.00% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c9c3de3871

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@@ -0,0 +1,1004 @@
pub fn target(value: i32) -> bool {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Keep benchmark fixture out of repo scans

Adding this controlled fixture under benchmarks/.../src makes it visible to ordinary repo-wide Rust discovery: DEFAULT_IGNORED_DIRS skips fixtures but not benchmarks, and is_production_rust_path excludes fixtures, benches, xtask, etc. but not benchmarks. When ripr check --root . --format repo-exposure-json, cargo xtask dogfood, or repo metrics run from this repository root, these 1000 unrelated benchmark functions are treated as ripr production seams, corrupting counts and latency; move the fixture under an ignored surface or add a benchmark-fixture exclusion and validate with the repo-wide scan/report commands.

Useful? React with 👍 / 👎.

Comment thread xtask/src/reports/targeted_rerun.rs Outdated
&& all_pass(cold_full)
&& all_pass(cold_targeted)
&& all_pass(warm_targeted)
&& all_pass(invalidation);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Require invalidation samples before passing

When the explicit cache-reset sample exits successfully but reports /cache/reuse_state: reused_file_facts, this line still allows threshold_pass to become true because it checks only the process status via all_pass(invalidation). That can publish a status: "pass" benchmark while the SPEC-0123 invalidation case did not actually recompute facts; require the invalidation sample to report recomputed_file_facts (and consider pinning cold/warm cache states) before setting the receipt status to pass.

Useful? React with 👍 / 👎.

@EffortlessSteven

Copy link
Copy Markdown
Member Author

Addressed the Gemini review points in the latest head: cache cleanup now uses a Drop guard so early-return paths remove the isolated benchmark cache, and the benchmark status requires the parity sample to be a passing sample in addition to parity.state == matched. Focused tests, Clippy, and the full cargo xtask check-pr pass; the receipt was refreshed on the final head.

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