Skip to content

A feature range read decodes each point where it sits in the cached block - #3161

Open
matrixarkai wants to merge 1 commit into
mainfrom
perf/a-feature-range-read-decodes-each-point-where-it-sits
Open

matrixarkai wants to merge 1 commit into
mainfrom
perf/a-feature-range-read-decodes-each-point-where-it-sits

Conversation

@matrixarkai

@matrixarkai matrixarkai commented Nov 15, 2026 •

Copy link
Copy Markdown
Owner

FeatureQuery and FeatureQueryFiltered copied each block out of the cache, decoded all of it into a Vec<FeaturePoint> (a value Vec per point of the block, wanted or not), kept that in a table keyed by the block's address, and cloned the wanted point out of it. The filtered read did all of that for every point in the window and then dropped the points the filters refused. Each point is now read where it sits in the cached block's bytes (a cursor walks an ascending block once; any other shape is read point by point as before), and a value is copied only into a point the answer keeps. This is the same treatment SequenceQuery got in #3099.

The answers do not change: the window is still capped at count points BEFORE the filters (a cap that cuts through refused points answers fewer than count), a torn or forged block is refused as before, the first of a repeated instant wins, and an unreadable row is counted once per read. No stored or wire byte changes.

Measured (counting allocator, release, alloc-probe, 40 queries over a series appended in 100-point blocks; before = the replaced reader selected by a temporary switch in a scratch build of the same tree):

read series allocs/op before after
range of 10 points 100 / 1,000 133.5 / 133.3 31.5 / 31.3 (-76%)
whole series 100 228.5 126.5
whole series 1,000 2,081.3 1,041.3 (-50%; bytes 169,966 -> 115,531)
filtered, keeps 1 point 1,000 2,055.0 16.0
filtered, keeps 20% 1,000 2,061.0 221.0
filtered, keeps none 1,000 2,054.0 14.0

The unfiltered whole-series read is now one allocation per returned point (the value the answer keeps); the filtered reads allocate for what passes and for nothing else.

The existing sequence guard changes (a_sequence_query_does_not_allocate_per_row): its control was the range read, which it required to cost at least twice a sequence read. The range read is now cheaper, so that ratio no longer holds; the guard now requires the sequence read to cost less than the range read that keeps a value per point, and its other two assertions are unchanged.

Plant: #3170 restores the old arms under the same guards; the guard must fail with the old counts. Guards, pinned by exact name in rust-ci.yml: the_cursor_answers_what_the_decoder_answers (the walker against the strict decoder over ascending, sparse, backward, repeated and shuffled instants, every truncation of a block, trailing bytes, a forged count, a repeated or descending instant, the JSON shape, an unframed value), a_range_read_answers_what_was_appended (both reads against a model, over one block of many points, one-point blocks, replaced instants, windows, caps, four filters, a trimmed series and a reload), and the probe a_feature_range_read_does_not_allocate_per_point_of_the_block, with the unfiltered read's one-per-point slope as its control.

Not measured: instructions (the cursor adds a validation walk per block, linear, where the old decode was linear too); wall time. The thresholds of the new probe were set from the measured slopes above, not yet read back from a CI run of this branch. Net about 150 lines of code, 420 of test.

🤖 Generated with Claude Code

@matrixarkai
matrixarkai force-pushed the perf/a-feature-range-read-decodes-each-point-where-it-sits branch from 99c3906 to d42a4e2 Compare November 15, 2026 23:46
@matrixarkai
matrixarkai force-pushed the perf/a-feature-range-read-decodes-each-point-where-it-sits branch from f261e72 to 512d30a Compare November 16, 2026 02:53
@matrixarkai
matrixarkai marked this pull request as ready for review November 16, 2026 02:56
…lock

FeatureQuery and FeatureQueryFiltered copied each block out of the cache, decoded all of it
into a vector of points, and cloned the wanted point out; the filtered read did that for every
point in the window and dropped the ones the filters refused. Points are now read from the
cached block's bytes, a block is walked once, and a value is copied only into a point the
answer keeps. The window is still capped before the filters. The sequence read's guard now
compares against a range read that keeps one value per point, since the range read no longer
builds a point per point of the block.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@matrixarkai
matrixarkai force-pushed the perf/a-feature-range-read-decodes-each-point-where-it-sits branch from 512d30a to cc895a8 Compare November 16, 2026 04:29
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