Design observable IndexedReader caching and hinted prefetch - #21
Conversation
|
Taking your three review questions in order. Caller-hinted prefetch versus a batch range API. I would start with the batch API and treat hinting as the streaming special case, not the reverse. A batch call states the whole working set, so the implementation can order reads by compressed offset, deduplicate overlapping canonical chunks, and size the pool against known work rather than guessing from a queue of advisory hints. It also makes the usefulness telemetry trivially interpretable, since requested and delivered are the same set. Hinting only wins when the caller genuinely cannot know the next range, which for the motivating case of a reader walking a list of records is rarely true. If both land eventually, the batch API is the one whose contract does not need a usefulness metric to explain itself. Dedicated telemetry types versus widening Canonical chunks, cancellation, admission, One thing I would add to the gate rather than to the design. The document stages caching before prefetch and stops if caching does not pay, which is right. I would also require the disabled path to be measured, not assumed, in the same run that measures the enabled one. On #22, I reviewed and built it and left detailed comments there. The one cross-cutting note is that its flaky neighbour |
|
Release decision: this work is explicitly deferred to 0.3.0. Version 0.2.0 will ship the existing verified The design remains useful and this draft should stay open as the 0.3.0 design This deferral is intentional and is not a blocker for 0.2.0. |
Summary
This is the focused, design-first successor to the decoded-window cache and seek-prefetch work in #5.
The feature is warranted for repeated, overlapping, and caller-known random ranges, but not with #5's automatic two-window policy or ad-hoc thread creation. This draft specifies an explicit decoded cache and caller-hinted prefetch with a lazy bounded worker pool, dynamic zero-to-budget control, usefulness telemetry, and unchanged zero-thread defaults.
Key decisions
IndexedReader::newremains cache-free and creates no background thread.reader_from_index.Gate before implementation
The document deliberately stages synchronous caching before worker prefetch. Work stops if repeated-range caching does not produce a representative win without changing the default path. Background prefetch must then improve at least one real multi-range trace while respecting worker/RSS bounds and leaving disabled behavior statistically unchanged.
Review focus
DecoderStatssemantics?into_innerownership rules sufficient?This PR currently contains the complete design and implementation/validation plan. Implementation will follow on this branch after design review.