Repository navigation
docs(storage): state the count cap cost as a decode per key past it - #1137
chappie-daemon merged 4 commits into
Conversation
Signed-off-by: Priyanshubhartistm <[email protected]>
🦋 Changeset detectedLatest commit: cb6a70a The changes in this PR will be included in the next version bump. This PR includes changesets to release 0 packagesWhen changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
[Low impact] The PR appears safe to merge; it changes only documentation and comments.
|
Signed-off-by: Priyanshubhartistm <[email protected]>
… one Signed-off-by: Priyanshubhartistm <[email protected]>
Dismissed because a newer commit was pushed; Greptile will re-review the current head.
chappie-daemon
left a comment
There was a problem hiding this comment.
Reviewed against the code, not just the prose.
The correction is the right one. counted_earlier returns early on exactly the boundary the new wording names:
// A first exact criterion is the row's only key in this walk, so nothing earlier answers
// for it and the body is not read.
if earlier.is_empty() && prefix.is_none() {
return Ok(false);
}Every other key past the cap falls through to databases.events.get and rows::decode_event, so "every key the set does not answer, outside the family's first exact criterion" is exact, and both shapes the text names are the two that get there: a later criterion (earlier non-empty) and a #g prefix (prefix some). The qualifier on "below the cap" is right too — Matcher::matches reads only the row header, and decode_event runs there only when carries_other_tag_criteria, which a single proved family never triggers.
Nothing is left uncorrected. A sweep for "repeated key" across both files at this head finds no remaining copy; the four ADR statements and the three comments, including the shortcut: marker and the test's doc comment, all carry the new wording.
The substance is pinned by a test, and it passes. At this head:
cargo test -p nostream-storage --lib a_count_past_its_id_cap_totals_what_the_unbounded_walk_totals
test result: ok. 1 passed; 0 failed
Its {"#t":["zz","a"]} case — one key a row, zero repeats — asserts the capped and uncapped totals are equal, that the capped walk decoded a body, and that the uncapped walk decoded none. That is the refutation of "per repeated key" running as an assertion rather than a claim about the diff.
Provenance of the numbers. The 5.3× / 5.7× ratios are the round-15 table in #1081, one 20,000-row corpus in a release build; there is no committed benchmark behind them, so they are a measurement of that corpus rather than a constant. The direction is what counted_earlier does — 5,000 decodes at 10k rows and 15,000 at 20k is the arithmetic of the cap — and the change states them as they were measured, which is the right way to report them.
Two non-blocking nits, both cosmetic, neither worth a round trip:
0011-lmdb-backend.md:262-263now reads "the walk reads the body of every key the set does not answer, outside the family's first exact criterion, instead and asks whether…". The appositive pushes "instead" ten words from the verb it qualifies, so the sentence stumbles on first read. "…criterion, instead asking whether…" would carry it.0011-lmdb-backend.md:366— "a body decode per key past the cap that the set does not answer" lets "that" attach to "cap" on first pass, before the row is corrected by "and that lies outside". "per key past the cap that the set cannot answer for, and that lies outside…" reads without the garden path.
Approving: docs-only, accurate, evidenced, and CI's Rust Checks passes. Credit to @Priyanshubhartistm for chasing the copies as well as the primary statement — a correction that stops at the first occurrence is how the wrong version comes back.
Description
ADR 0011 and the comments in
crates/nostream-storage/src/lmdb/events.rsstate the cost of the count's id-set cap wrongly: they say it is "a body decode per repeated key past it". The code reads the row's body for every key the set does not answer past the cap, unless the range is the family's first exact criterion, so the cost is not confined to repeated keys.This PR corrects the prose in four places in the ADR and three comments in
events.rs. It changes no code and no behaviour:#gprefix's key), not only a repeated one, and gives the measured cost (5.3× to 5.7× the uncapped walk at 20,000 rows), using the wording the issue proposes.tagfield comment, theshortcut:marker and the test's doc comment.What the issue says is right is left as it is: the set bound (270 352 B), the exactness of the count and the free cap below 5,000 rows.
Related Issue
Fixes #1081
Motivation and Context
The record is wrong in the direction a reader would trust: a reader who believes the cost is per repeated key would expect a filter with no repeated key to pay nothing past the cap, while
{"#t":["zz","a"]}(one key a row, zero repeats) costs 5.7× its uncapped time at 20,000 rows.How Has This Been Tested?
Prose and comment changes only. The Rust validation commands pass (
cargo fmt --all --check, both clippy passes,cargo test --workspace --all-features,cargo build --workspace --all-features --release), and the diff touches no code line.Screenshots (if appropriate):
Types of changes
Checklist: