Skip to content

fix(bench): skip template-snapshot capture in the query-store builds - #351

Merged
jensholdgaard merged 5 commits into
mainfrom
bench-skip-snapshots-in-store-builds
Jul 4, 2026
Merged

fix(bench): skip template-snapshot capture in the query-store builds#351
jensholdgaard merged 5 commits into
mainfrom
bench-skip-snapshots-in-store-builds

Conversation

@jensholdgaard

@jensholdgaard jensholdgaard commented Jul 4, 2026

Copy link
Copy Markdown
Owner

Found live on the baseline box during the first 10–100 GiB scale run (HDFS_v2, 16 GiB): the B2 store build ran at ~3 KB/s — extrapolated ~57 days. Three gdb stack samples all landed in the bench harness's per-record snapshot capture: every new (template_id, template_version) pair calls MinerCluster::templates_for, which walks and clones the entire template set, and HDFS_v2's node logs drive template widening (a version bump) every few lines → quadratic in practice.

Two facts make the fix surgical:

  • The query-store builds (build_query_store / build_b1_store) never read the snapshots — their callbacks ignore the argument. Only C1 (reconstruction) consumes them.
  • Production ingest never calls templates_for per record — this is bench-harness overhead, not a miner pathology. (Worth stating clearly since miner correctness/perf is hazard docs: add verification process spec #1: the stacks exonerate the miner itself.)

run_streaming gains a capture_snapshots flag; build_store passes false; the gates path (run()) passes true — C1/A1/C2 behavior unchanged.

Follow-up worth tracking (not this PR): C1 itself pays the same walk on churny corpora; an incremental templates_for_id(template_id) on the miner would make gate runs scale too.

Verification: full ourios-bench suite green, fmt + clippy -D warnings clean. The scale run resumes on the already-provisioned box once this merges (corpus staged, ~5 min rebuild).

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added an option to control whether snapshot data is captured during streaming runs.
    • Streaming runs now consistently enable snapshot capture where needed, while other paths can skip it.

Stack-sampled on the baseline box mid-run: the B2 store build over
LogHub HDFS_v2 (16 GiB) sat in harness snapshot capture ->
MinerCluster::templates_for -> full template-set clone. Every new
(template_id, template_version) pair pays that walk, and HDFS_v2's
widening churn produces version bumps every few lines — quadratic,
measured at ~3 KB/s (a ~57-day build). The store builds never read
the snapshots (their callbacks ignore the argument); only C1 does.
run_streaming now takes capture_snapshots and build_store passes
false — the gates path is unchanged (run() passes true).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@jensholdgaard
jensholdgaard requested a review from Copilot July 4, 2026 10:38
@coderabbitai

coderabbitai Bot commented Jul 4, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

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

Next review available in: 42 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: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: e4642f49-92fa-4b81-8559-d6c34bc17fa3

📥 Commits

Reviewing files that changed from the base of the PR and between c8f27df and 7248d1f.

📒 Files selected for processing (2)
  • crates/ourios-bench/src/harness.rs
  • crates/ourios-bench/src/store.rs
📝 Walkthrough

Walkthrough

A capture_snapshots boolean parameter is added to run_streaming in the bench harness, gating whether per-record snapshots are computed. The run function enables it; build_store disables it. No other behavior changes.

Changes

Snapshot Capture Gating

Layer / File(s) Summary
Add capture_snapshots parameter and gating logic
crates/ourios-bench/src/harness.rs
run_streaming signature gains a capture_snapshots: bool parameter; the want_snapshot predicate now also requires this flag to be true, in addition to existing lossiness and body-kind exclusions.
Update call sites
crates/ourios-bench/src/harness.rs, crates/ourios-bench/src/store.rs
run passes true to enable snapshot capture; build_store passes false to disable it, without changing callback handling.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Possibly related PRs

  • jensholdgaard/ourios#92: Introduces the build_query_store mining pipeline that relies on the same run_streaming invocation being modified here.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: skipping template-snapshot capture for query-store builds.
Description check ✅ Passed The description covers the problem, fix, scope, and verification, though it omits the template's Related and Checklist sections.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch bench-skip-snapshots-in-store-builds

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.

Copilot AI 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.

Pull request overview

This PR removes a major benchmark-harness performance bottleneck by making per-record template snapshot capture optional, and disabling it for query-store/B1/B2 store builds where snapshots are not consumed.

Changes:

  • Extend harness::run_streaming with a capture_snapshots flag and gate snapshot capture behind it.
  • Update the eager gates path (run()) to preserve existing snapshot behavior (capture_snapshots = true).
  • Update the store-build path to skip snapshot capture (capture_snapshots = false) to avoid quadratic behavior on churny corpora.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
crates/ourios-bench/src/store.rs Disables snapshot capture for store builds by passing capture_snapshots = false to the streaming harness.
crates/ourios-bench/src/harness.rs Adds capture_snapshots to run_streaming and uses it to skip template snapshot capture work when not needed.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🧹 Nitpick comments (1)
crates/ourios-bench/src/harness.rs (1)

130-134: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Consider replacing the two adjacent bool params with a small options type.

capture_audit and capture_snapshots are now two same-typed positional bools next to each other; both call sites (run_streaming(stream, false, false, ...) in store.rs, run_streaming(..., capture_audit, true, ...) here) rely on remembering argument order with no compiler backing. Clippy's own fn_params_excessive_bools pedantic lint (denied per this crate's guidelines) exists precisely because such signatures are "confusing and error prone" — the function is now one more bool away from tripping it at the default threshold of 3.

♻️ Suggested direction
-pub(crate) fn run_streaming<T, I, F>(
-    corpus: I,
-    capture_audit: bool,
-    capture_snapshots: bool,
-    mut on_record: F,
-) -> Result<HarnessResult, BenchError>
+pub(crate) struct StreamingOptions {
+    pub capture_audit: bool,
+    pub capture_snapshots: bool,
+}
+
+pub(crate) fn run_streaming<T, I, F>(
+    corpus: I,
+    opts: StreamingOptions,
+    mut on_record: F,
+) -> Result<HarnessResult, BenchError>
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/ourios-bench/src/harness.rs` around lines 130 - 134, The run_streaming
API in harness.rs uses two adjacent positional bools, capture_audit and
capture_snapshots, which is confusing and fragile at its call sites. Replace
them with a small options type (or equivalent grouped config) and update
run_streaming plus its callers in store.rs and the current caller to pass named
configuration instead of relying on bool order. Keep the change localized around
run_streaming so the intent is explicit and the signature no longer depends on
remembering argument positions.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@crates/ourios-bench/src/harness.rs`:
- Around line 190-201: `harness.rs` does not currently cover the
`capture_snapshots = false` path in `run_streaming`, so add a direct test that
calls `run_streaming(..., false, false, ...)` with a non-lossy record that has a
real `template_id` and string body, then assert the callback receives `None` for
the snapshot. Use the existing `run_streaming` and `want_snapshot` logic in the
harness to locate the change and mirror the current `run()`-based test setup.

---

Nitpick comments:
In `@crates/ourios-bench/src/harness.rs`:
- Around line 130-134: The run_streaming API in harness.rs uses two adjacent
positional bools, capture_audit and capture_snapshots, which is confusing and
fragile at its call sites. Replace them with a small options type (or equivalent
grouped config) and update run_streaming plus its callers in store.rs and the
current caller to pass named configuration instead of relying on bool order.
Keep the change localized around run_streaming so the intent is explicit and the
signature no longer depends on remembering argument positions.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 0b662ea1-0022-4889-b6be-8831e447a81d

📥 Commits

Reviewing files that changed from the base of the PR and between 2655bac and c8f27df.

📒 Files selected for processing (2)
  • crates/ourios-bench/src/harness.rs
  • crates/ourios-bench/src/store.rs

Comment thread crates/ourios-bench/src/harness.rs
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

Copilot AI 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.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

Comment thread crates/ourios-bench/src/store.rs Outdated
Comment thread crates/ourios-bench/src/harness.rs
Comment thread crates/ourios-bench/src/harness.rs
…e snapshot test

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

Copilot AI 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.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Comment thread crates/ourios-bench/src/harness.rs
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

Copilot AI 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.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

@jensholdgaard
jensholdgaard merged commit 6e05cb8 into main Jul 4, 2026
21 checks passed
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.

2 participants