Skip to content

Measure what a query costs as the corpus grows - #143

Merged
vmillet-dev merged 1 commit into
mainfrom
perf/measure-what-a-query-costs
Sep 16, 2026
Merged

vmillet-dev merged 1 commit into
mainfrom
perf/measure-what-a-query-costs

Conversation

@vmillet-dev

Copy link
Copy Markdown
Owner

Part of #21, and deliberately not closing it: the ticket asks for a measurement before anything is built, so this is the measurement and nothing else. The numbers and the reading are in the issue; the decision between its three fixes is not mine to make.

What it adds

cargo bench --bench corpus_size seeds 1 000, 5 000 and 20 000 notes and times each twice: the whole query, and the same query stopped before view::build and serde. The gap between the two is what a lighter wire shape could take away and what a LIMIT could not — which is the question that decides between the ticket's options.

It also prints the serialised payload per size, because half of what #21 is about is what crosses the bridge, and a size is not a duration.

Why a target of its own

commands keeps one corpus size on purpose — its baseline is the table in docs/architecture.md and has to stay comparable from run to run. And seeding 26 000 notes of ~13 kB would make a plain cargo bench unusable. So: [[bench]] name = "corpus_size", run on its own.

Shape

  • corpus::build() becomes build_of(notes) with build() calling it at NOTES, so every existing group is untouched.
  • run_query moves from commands.rs into corpus.rs: two targets needed it, and a copy in each is the duplication this repository has spent the day removing.
  • ⚠️ #![allow(dead_code)] on corpus.rs, with the reason: each bench target compiles its own copy of the module and uses a part of it — commands never calls build_of, corpus_size never reads note_ids.

#21 asks for a measurement before anything is built, so this is the
measurement and nothing else. The corpus gains a size parameter, the query
runner moves beside it so both benches share one, and a target of its own
seeds 1 000, 5 000 and 20 000 notes — kept out of `commands`, whose baseline
has to stay comparable and whose corpus is one size on purpose.

Each size is timed twice: the whole query, and the same query stopped before
the view is built and serialised. The gap between the two is what a lighter
wire shape could take away and what a LIMIT could not.
@vmillet-dev vmillet-dev added this to the v0.2.0 — Solid ground milestone Sep 16, 2026
@vmillet-dev
vmillet-dev merged commit 9a2f38c into main Sep 16, 2026
11 checks passed
@vmillet-dev
vmillet-dev deleted the perf/measure-what-a-query-costs branch September 16, 2026 14:27
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.

1 participant