[Feature] Prefetch the late-materialization payload ranges instead of reading them on demand
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 38/100
- Issue type
- Feature
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- cpp
- Domain
- data-engineering, performance
Research direction
Start by tracing PrefetchFileBatchReader::PreBufferRange(), ReadAheadCache::Init(), Read(), Reset(), and Close(), then inspect the public APIs under include/paimon/. Follow how LateMaterializingFileBatchReader determines payload ranges and how the existing cache metrics are recorded. Done means late ranges are safely registered and warmed across rounds, stale registrations are dropped, concurrency and overlap rules hold, and the new metrics account for registered and dropped bytes.
Written by the indexing model from the issue text.
Description
Search before asking
- I searched in the issues and found nothing similar.
Motivation
Late materialization reads a data file in two passes: a probe pass over the predicate fields, then a payload pass over the remaining fields for the matched rows only. The shared read-ahead cache is fed once per read-range generation through PrefetchFileBatchReader::PreBufferRange(), before any read starts. At that point the payload pass cannot know which pages hold the matched rows — that depends on the probe result — so PreBufferRange() only reports the probe ranges (there was an explicit TODO for exactly this). The payload pass is therefore never prefetched: every payload read misses the cache and waits for its own underlying IO, serialized against the decode, on the pass that touches the wide columns.
Solution
Let a reader report byte ranges that only become known after reading has started, and let the shared cache register them mid-read.
- New
ReadAheadCache::AddRanges(ranges, expected_round)registers ranges into an already-initialized cache and is safe to call repeatedly and concurrently withRead(). It merges the new ranges into the disjoint, offset-ordered pending list, registering only the parts no registered range covers and dropping the overlap (the round that registered it is already fetching those bytes), then rebuilds the per-range cached flags so an already-fetched range is not fetched twice. The registered part is cut at a newCacheConfigknoblate_range_size_limit(default 8 MiB, smaller than the 32 MiBrange_size_limit) so a large pass is fetched by several concurrent requests rather than one long one; a newWarmup(from_offset)starts fetching from the first newly-registered range instead of from the head. - A registration round bounds the lifetime: every
Init()opens a round identified byRegistrationRound(), andAddRanges()drops everything whenexpected_roundis not the open round, so a pass that outlived its generation — the cache was reset for a new read-range generation, or released byClose()— registers nothing instead of prefetching bytes nobody reads. The round counter is monotonic acrossReset()so a stale round is never mistaken for a new one. - New
PrefetchFileBatchReader::PreBufferSinkandSetPreBufferSink():PrefetchFileBatchReaderImplinstalls a sink on each sub-reader that tags the reported ranges with the current round, callsAddRanges, and warms up from the first new range.LateMaterializingFileBatchReaderreports the payload ranges through the sink once the probe pass has refined the inner reader's target pages, and surfaces a failure to compute them (they come from the file metadata) rather than swallowing it. - New metrics
read-ahead-cache.late.registered/.registered-bytes/.dropped/.dropped-bytes, counted after coalescing and splitting, soregistered-bytesanddropped-bytestogether account for every reported byte.
Anything else?
Adds public API under include/paimon/: PrefetchFileBatchReader::PreBufferSink / SetPreBufferSink() and CacheConfig::GetLateRangeSizeLimit() / SetLateRangeSizeLimit(). ReadAheadCache::AddRanges / RegistrationRound / Warmup(offset) and the new counter names live in the internal header. No storage format or protocol change.
Are you willing to submit a PR?
- I'm willing to submit a PR!
- Dominant language
- C++
- Stars
- 65
- Forks
- 29
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 78
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from apache/paimon-cpp
-
enhancement
apache/paimon-cpp#381 · 1 assignee ·
-
Difficulty 4/5 3-5 days Newbie friendliness 30/100
apache/paimon-cpp#375 · 1 assignee ·
-
enhancement
Difficulty 5/5 Over a week Newbie friendliness 45/100
apache/paimon-cpp#361 · 1 assignee ·
-
enhancement
Difficulty 4/5 3-5 days Newbie friendliness 45/100
apache/paimon-cpp#325 · 1 assignee ·
-
enhancement
Difficulty 5/5 Over a week Newbie friendliness 35/100
apache/paimon-cpp#319 · 1 reaction · 1 assignee ·
All issues in apache/paimon-cpp
Similar issues
-
ai_reviewed
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
ydb-platform/ydb#53869 · 3 comments ·
-
bug cert blocker needs triage
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
project-chip/connectedhomeip#74373 ·
-
upstream update
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
conan-io/conan-center-index#31035 ·
-
Bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
documentation
Difficulty 1/5 Under an hour Newbie friendliness 85/100
vllm-project/vllm-ascend#17329 ·