Skip to content

feat(bench): RFC 0031 — honest total-bytes accounting (count + materialize + registry) - #482

Merged
jensholdgaard merged 2 commits into
mainfrom
rfc0031-honest-bytes
Jul 11, 2026
Merged

feat(bench): RFC 0031 — honest total-bytes accounting (count + materialize + registry)#482
jensholdgaard merged 2 commits into
mainfrom
rfc0031-honest-bytes

Conversation

@jensholdgaard

Copy link
Copy Markdown
Owner

What

Makes the RFC 0031 comparative measurement channel report the honest total bytes Ourios reads from object storage to answer a query — count/pruning scan + row-materialization scan + template-registry (audit-stream) derivation — instead of the count scan alone.

Why

Verified during the run-#7 analysis: QueryStats.bytes_read counts only the count/pruning scan. Two real IO components were silently excluded: the second scan that materializes the ≤ limit returned records, and the RFC 0017 §3.2 audit-stream read that derives the template registry rendering string bodies. Loki's counterpart figures include delivering results, so the comparison was biased in Ourios's favour — the §3.7 anti-strawman discipline cuts both ways. On the 3-record comparative fixture the old channel under-reported ~60× (total 9,886 B = count 166 + materialize 1,555 + registry 8,165); real-corpus skew will differ, but the bias direction is proven. Run #8 (post-merge dispatch) re-baselines the selectivity curve on this honest metric before any §7 margin freeze or §9 fold-in.

How

  • QueryResult gains additive fields (materialize_bytes_read, registry_bytes_read) — it is #[non_exhaustive] for exactly this. QueryStats is untouched: the existing spec test rfc0017_6_typed_row_payload_returned_b1b2_compatible asserts limited.stats == counted.stats, so the count-scan-only semantics of stats.bytes_read (B1/B2 gates, RFC 0016 metrics DTO) are preserved bit-for-bit.
  • Materialization: collect_records now plans its limited frame by hand and reads bytes_scanned off the retained plan (only bytes folded — its row-group counts stay out so the B1 pruned fraction keeps its meaning).
  • Registry: audit_scan::read_all_events returns (events, bytes); local counts file lengths, S3 counts fetched object bytes, so both backends report the same figure for identical data. Public derive_template_registry keeps its signature via a pub(crate) measured split.
  • OuriosAnswer.bytes_read becomes the sum (its doc claim is now true) with the three components exposed; the indicative report prints the per-pair breakdown.
  • RFC 0031 §3.6 gets a dated measurement-fidelity amendment (RFC is in red; this is the in-process §5 ladder).

Invariants / hazards

No hot-path, schema, or miner change. Tests-as-specifications: no existing test weakened; new spec tests pin the additive contract (materialization_and_registry_io_reported_additively in the querier, honest_total_bytes_breaks_down_additively in the bench lib — components 0 when count-only, > 0 with rendered rows, count-scan stats byte-identical either way).

Checks run

cargo fmt --all --check, cargo clippy --all-targets --all-features -- -D warnings (workspace-wide), cargo nextest run -p ourios-querier -p ourios-bench (284 passed / 0 failed / 14 skipped = container-gated), mdbook build for the RFC edit.

Note: merge sequencing — #481 (floor gate) touches adjacent lines in print_indicative_report; whichever lands second gets a trivial rebase.

🤖 Generated with Claude Code

https://claude.ai/code/session_01WQY9wfrfRggqSpMLH8Xj3Y

@coderabbitai

coderabbitai Bot commented Jul 11, 2026

Copy link
Copy Markdown

Warning

Review limit reached

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

Next review available in: 44 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: 6d70e231-d656-4ab7-a6ca-4b988a9b152c

📥 Commits

Reviewing files that changed from the base of the PR and between cf79b3d and 2005950.

📒 Files selected for processing (8)
  • crates/ourios-bench/src/comparative.rs
  • crates/ourios-bench/tests/rfc0031_comparative.rs
  • crates/ourios-querier/src/alias_store.rs
  • crates/ourios-querier/src/audit_scan.rs
  • crates/ourios-querier/src/lib.rs
  • crates/ourios-querier/src/template_registry.rs
  • crates/ourios-querier/tests/it/rfc0017_query_rows.rs
  • docs/rfcs/0031-comparative-evaluation-loki.md
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch rfc0031-honest-bytes

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.

…alize + registry)

The comparative channel's OuriosAnswer.bytes_read reported only the
count/pruning scan (QueryStats.bytes_read), silently excluding two real
IO components a row-returning query pays: the extra scan that
materializes the <= limit rendered records, and the RFC 0017 §3.2
template-registry derivation that reads the tenant's audit stream to
reconstruct string bodies. Loki's counterpart figure includes delivering
results, so the omission biased the L-gate ratios in Ourios's favour —
exactly what the §3.7 anti-strawman discipline forbids.

The fix is additive, not a redefinition: QueryStats.bytes_read keeps its
count-scan-only meaning (B1/B2 gates and the RFC 0016 metrics depend on
it — RFC0017.6's stats-equality still holds), and QueryResult (already
non_exhaustive for this) gains materialize_bytes_read (the retained
materialization plan's bytes_scanned) and registry_bytes_read (bytes
fetched by the audit read — full-object GET on S3, file length locally,
so the two backends' figures agree for identical data). The harness sums
the three into the honest total the gates ratio, and the indicative
report prints the breakdown per pair. RFC 0031 §3.6 carries the
measurement-fidelity amendment (2026-07-12, RFC in red).

On the comparative fixture the breakdown is total=9886 bytes =
count_scan 166 + materialize 1555 + registry 8165 — the old channel
under-reported by ~60x on this (registry-dominated) tiny store.

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

This PR updates the RFC 0031 comparative benchmarking channel to report honest total bytes read by Ourios (count/pruning scan + row materialization scan + template-registry/audit-stream derivation), while preserving the existing count-scan-only semantics of QueryStats::bytes_read for B1/B2 and RFC 0016 metrics compatibility.

Changes:

  • Extend QueryResult with additive IO components (materialize_bytes_read, registry_bytes_read) and plumb them through querier execution paths.
  • Measure and surface audit-stream bytes read by returning (events, bytes) from audit_scan::read_all_events and exposing a measured template-registry derivation.
  • Update the bench harness to sum and report the three components (including a breakdown in the indicative report) and add spec tests pinning the additive contract.

Reviewed changes

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

Show a summary per file
File Description
docs/rfcs/0031-comparative-evaluation-loki.md Documents the measurement-fidelity amendment: bytes_read is now an honest total in the RFC 0031 channel.
crates/ourios-querier/tests/it/rfc0017_query_rows.rs Adds a spec test asserting additive IO components on QueryResult while keeping stats identical to count-only runs.
crates/ourios-querier/src/template_registry.rs Introduces a measured template-registry derivation returning (registry, bytes_read).
crates/ourios-querier/src/lib.rs Threads new QueryResult fields through query execution; measures materialization scan bytes via retained physical plan metrics.
crates/ourios-querier/src/audit_scan.rs Changes audit scan to return both events and bytes read, accounting for local file sizes and remote object fetch sizes.
crates/ourios-querier/src/alias_store.rs Updates alias-map derivation to accommodate the new (events, bytes) audit scan return type.
crates/ourios-bench/tests/rfc0031_comparative.rs Enhances indicative reporting to print the total bytes breakdown (count/materialize/registry).
crates/ourios-bench/src/comparative.rs Updates OuriosAnswer to carry total bytes and per-component fields; adds a test asserting additivity.

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

Comment thread crates/ourios-bench/src/comparative.rs
Comment thread crates/ourios-querier/src/audit_scan.rs Outdated
Comment thread crates/ourios-querier/src/audit_scan.rs Outdated
A wrapped sum silently corrupts the primary gate metric; overflow now
surfaces as an error on both the audit accumulation and the final total.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WQY9wfrfRggqSpMLH8Xj3Y

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 8 out of 8 changed files in this pull request and generated no new comments.

@jensholdgaard
jensholdgaard merged commit afb1fb3 into main Jul 11, 2026
26 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