feat(bench): RFC 0031 — storage-side Loki bytes (conservative metric) - #479
Conversation
Run #5's 146.9x carried a metric asymmetry: Loki's summary.totalBytesProcessed counts DECOMPRESSED engine-side bytes, while Ourios's bytes_read counts COMPRESSED bytes fetched from storage — so the ratio overstated Loki's storage reads by the chunk compression ratio. - parse_loki_fetched_bytes: recursively sums compressedBytes / headChunkBytes across the stats tree (querier + ingester, store + head) — resilient to section layout across Loki versions. Zeros are legitimate (head-chunk-served queries); a missing stats block errors (same honesty rule as the processed parser). - The indicative report now prints BOTH figures and BOTH gate ratios, with the storage-side one (compressed + head-chunk) marked PRIMARY — the conservative, apples-to-apples number the §9 entry should carry. head_chunk bytes (memory-served, uncompressed) are reported in the sum rather than ignored: dropping them would understate Loki's data touched on head-served queries. - Report block extracted to print_indicative_report (too_many_lines). Unit-tested (section summing, empty-stats zeros, missing-stats error); report validated via the next dispatch run. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Warning Review limit reached
Next review available in: 53 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the 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 configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAdds recursive parsing of Loki storage-side byte statistics and threads the resulting values through the RFC0031 comparative harness, report calculations, public exports, and unit tests. ChangesLoki byte accounting
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant Loki
participant QueryParser
participant ComparativeRunner
participant IndicativeReport
Loki->>QueryParser: Return query_range JSON
QueryParser->>QueryParser: Parse lines, totalBytesProcessed, and fetched bytes
QueryParser->>ComparativeRunner: Return three measurements
ComparativeRunner->>IndicativeReport: Pass Loki and Ourios byte values
IndicativeReport->>IndicativeReport: Compute storage-side and processed-byte comparisons
Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Pull request overview
This PR refines the RFC 0031 comparative benchmark to report Loki “storage-side” bytes (compressed chunk bytes + head-chunk bytes) in addition to Loki’s engine-level totalBytesProcessed, so the benchmark can present a conservative apples-to-apples ratio against Ourios bytes_read.
Changes:
- Add
parse_loki_fetched_bytesandLokiFetchedBytesto extract and sumcompressedBytes/headChunkBytesrecursively fromdata.stats. - Update the RFC0031 comparative test to capture both Loki byte figures and print a “PRIMARY” gate based on the storage-side number.
- Extract the indicative report formatting into a helper (
print_indicative_report) to reduce clutter.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| crates/ourios-bench/tests/rfc0031_comparative.rs | Captures both Loki byte metrics and prints a report with primary gating on the conservative storage-side bytes. |
| crates/ourios-bench/src/lib.rs | Re-exports the new Loki fetched-bytes parsing API for use by benchmarks/tests. |
| crates/ourios-bench/src/comparative.rs | Introduces LokiFetchedBytes + parse_loki_fetched_bytes and adds unit tests for cross-section summing and missing-stats behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
🧹 Nitpick comments (1)
crates/ourios-bench/src/comparative.rs (1)
441-498: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueLGTM!
The recursive parser is clean: it correctly sums only
compressedBytes/headChunkBytes, ignoresdecompressedBytesand other fields, treats zero as valid, and errors on missingdata.stats. The doc comments explain the non-obvious "why" behind the conservative measurement choice. The test covers multi-section summation, empty stats, and missing stats.One optional note:
sum_stats_fieldsuses plain+=for accumulation, whilereference.rsusessaturating_addfor itscompressed_bytes(). Overflow is practically impossible for byte counts, butsaturating_addwould be consistent with the existing pattern and would prevent silent wrapping in release builds.♻️ Optional: use saturating_add for consistency with reference.rs
fn sum_stats_fields(node: &serde_json::Value, acc: &mut LokiFetchedBytes) { let Some(map) = node.as_object() else { return; }; for (key, value) in map { match (key.as_str(), value.as_u64()) { - ("compressedBytes", Some(n)) => acc.compressed_bytes += n, - ("headChunkBytes", Some(n)) => acc.head_chunk_bytes += n, + ("compressedBytes", Some(n)) => acc.compressed_bytes = acc.compressed_bytes.saturating_add(n), + ("headChunkBytes", Some(n)) => acc.head_chunk_bytes = acc.head_chunk_bytes.saturating_add(n), _ => sum_stats_fields(value, acc), } } }🤖 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/comparative.rs` around lines 441 - 498, Update sum_stats_fields to use saturating_add when accumulating compressed_bytes and head_chunk_bytes, matching the existing overflow-safe pattern in reference.rs while preserving the current recursive traversal and field selection.
🤖 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.
Nitpick comments:
In `@crates/ourios-bench/src/comparative.rs`:
- Around line 441-498: Update sum_stats_fields to use saturating_add when
accumulating compressed_bytes and head_chunk_bytes, matching the existing
overflow-safe pattern in reference.rs while preserving the current recursive
traversal and field selection.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 9d1a1836-13df-493a-bd29-f7053441f28a
📒 Files selected for processing (3)
crates/ourios-bench/src/comparative.rscrates/ourios-bench/src/lib.rscrates/ourios-bench/tests/rfc0031_comparative.rs
'stats': null passed the existence check and silently yielded zeros — now filtered to objects only, so it errors per the doc. Tested. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
What
Run #5's headline (146.9×) carried a metric asymmetry worth fixing before anything lands in
benchmarks.md: Loki'ssummary.totalBytesProcessedcounts decompressed engine-side bytes, while Ourios'sbytes_readcounts compressed bytes fetched from storage — overstating Loki's storage reads by the chunk compression ratio.parse_loki_fetched_bytes— recursively sumscompressedBytes/headChunkBytesacross the stats tree (querier + ingester, store + head sections), resilient to layout differences across Loki versions. Zeros are legitimate (head-chunk-served queries); a missing stats block errors (the harness's standing honesty rule).too_many_lines).Why this matters
Self-critique before anyone else does it: the honest recorded claim should survive an adversarial reader asking "did you compare compressed to decompressed?" The answer will now be printed in the run itself. Expectation: the conservative ratio lands meaningfully lower than 146.9× (likely ~20–40× depending on chunk compression) — still comfortably past the provisional 10× margin if the thesis holds.
Note for the §9 fold-in: RFC 0031 §3.6 names
totalBytesProcessedas the Loki-side metric — the §9 entry PR should carry a one-line §3.6 amendment recording the storage-side refinement.After merge
Re-dispatch → run #6 produces the refined, defensible pair of numbers.
🤖 Generated with Claude Code
Summary by CodeRabbit