feat(metrics): expose prefix bloom skip counter for testability#70
Conversation
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughThis change introduces a new metric counter to track prefix bloom filter skips—instances where a prefix bloom filter returns false, indicating a segment lacks the target prefix. The counter is exposed via public API, and the metrics infrastructure is conditionally threaded through the prefix-scan code path via Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
|
@coderabbitai re-review |
|
🧠 Learnings used✅ Actions performedFull review triggered. |
There was a problem hiding this comment.
Pull request overview
This PR adds a new metrics counter to make prefix-bloom segment skipping observable (and therefore testable) from integration tests when the metrics feature is enabled.
Changes:
- Add a
prefix_bloom_skipscounter toMetrics, incremented whenmaybe_contains_prefixreturnsOk(false). - Thread an
Arc<Metrics>throughIterStateso prefix scans can record skip events on the tree’s shared metrics instance. - Add
#[cfg(feature = "metrics")]integration tests asserting the counter behavior.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/metrics.rs |
Adds the prefix_bloom_skips counter and a public accessor. |
src/range.rs |
Increments the new counter when a segment is skipped via prefix bloom Ok(false). |
src/tree/mod.rs |
Wires Arc<Metrics> into iterator state (shared for create_prefix). |
tests/tree_prefix_bloom.rs |
Adds metrics-gated integration tests for the new counter. |
6e2c01e to
d4d541b
Compare
|
@coderabbitai re-review |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: Length of output: 57941
|
d4d541b to
d9bf994
Compare
Add `prefix_bloom_skips` counter to `Metrics` struct, incremented in
`TreeIter::create_range` each time `maybe_contains_prefix` returns
`Ok(false)` and a segment is skipped. This allows integration tests to
assert that the bloom-skip code path actually fired, catching regressions
that silently disable bloom filtering while still returning correct results.
- Add `prefix_bloom_skips: AtomicUsize` field to `Metrics` (feature-gated)
- Add `pub fn prefix_bloom_skips()` accessor
- Wire `Arc<Metrics>` through `IterState` for `Tree::create_prefix` path
- Add two `#[cfg(feature = "metrics")]` integration tests:
- `prefix_bloom_skip_metrics`: asserts counter > 0 after scanning
24 non-existent prefixes inside a wide key_range
- `prefix_bloom_skip_metrics_zero_without_extractor`: asserts counter
stays at 0 when no prefix extractor is configured
Closes #59
Change `IterState::metrics` from `Arc<Metrics>` to `Option<Arc<Metrics>>` so non-prefix iterators skip the heap allocation. Only `create_prefix` passes `Some(metrics)` — all other range iterators use `None`. Rewrite probabilistic smoke-test rationale in prefix_bloom_skip_metrics.
Clarify that BlobTree prefix scans do not currently record this metric, since only Tree::create_prefix wires the metrics handle.
Clarify IterState.metrics doc to decouple None semantics from prefix usage. Add table_count assertion in prefix_bloom_skip_metrics test to fail early if flush layout changes break the single-table assumption.
Wrap the 24-prefix scan in a retry loop (up to 20 attempts) so the test tolerates rare all-false-positive bloom runs without flaking.
fa9f234 to
d5127fe
Compare
|
@coderabbitai re-review |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: Length of output: 70317
Single-table vs. multi-table run metric coverage The This isn't a correctness bug (the test deliberately enforces Everything else looks good:
[approve] 🧠 Learnings used |
Single-table run path is the only instrumented path; multi-table runs and BlobTree prefix scans are not yet counted.
Extend prefix_bloom_skips counter to the multi-table run filter in TreeIter::create_range, not just the single-table path. Update docs to reflect both paths are now instrumented (BlobTree excluded).
Summary
prefix_bloom_skipscounter toMetricsstruct (feature-gated undermetrics), incremented whenmaybe_contains_prefixreturnsOk(false)inTreeIter::create_rangeOption<Arc<Metrics>>throughIterStatesoTree::create_prefixtracks skips on the tree's shared metrics instance without allocating for non-prefix iterators#[cfg(feature = "metrics")]integration tests validating the counter increments and stays zero without an extractorBlobTreeprefix scans do not currently record this metricTest Plan
cargo test— all tests pass withoutmetricsfeaturecargo test --features metrics— all 18 prefix bloom tests pass including 2 metrics testscargo clippy --all-features— zero warningsCloses #59