@@ -132,11 +132,10 @@ struct RangeCacheEntry {
132132 }
133133};
134134
135- // / A read cache designed to hide IO latencies when reading.
136- // / Prefetching strategy: When a range is read, the cache will prefetch up to
137- // / `pre_buffer_range_count` additional adjacent ranges ahead of the requested offset. This helps
138- // / hide I/O latency for sequential access. Example: If you read range [0, 100), and
139- // / pre_buffer_range_count=2, the next two configured ranges will also be prefetched.
135+ // / A read cache designed to hide IO latency when reading.
136+ // / Prefetching strategy: a Read() (or Warmup()) at an offset publishes and fetches the registered
137+ // / ranges from that offset forward until their cumulative size exceeds `pre_buffer_limit`, so a
138+ // / sequential read runs ahead of the caller instead of fetching one range at a time.
140139// /
141140// / The cache never evicts: every published range stays cached until
142141// / ReleaseBuffers() or Reset(). It is meant to hold the prefetched ranges of
@@ -163,19 +162,15 @@ class PAIMON_EXPORT ReadAheadCache {
163162
164163 // / Register byte ranges to prefetch, merging them into the ranges already registered.
165164 // /
166- // / This is the cache's only registration entry point, and it may be called repeatedly and
167- // / concurrently with Read(): the ranges known up front - a read plan's whole extent - are
168- // / registered before any Read(), and the ranges that only become known WHILE reading - a
169- // / late-materialization payload pass learns which pages it needs only after the probe pass has
170- // / evaluated the predicate - are registered as they are discovered. Read() finds its covering
171- // / entries by walking a disjoint, offset-ordered list, so of a new range only the part no
172- // / registered range covers is added; the overlapping part is dropped, as those bytes are
173- // / already being fetched. A registration is cut into ranges of at most `range_size_limit`
174- // / bytes, one prefetch IO each, so a large pass is fetched concurrently instead of in one long
175- // / request.
176- // /
177- // / Deciding WHICH ranges to register - and in particular not reporting the ranges of a read
178- // / that has already ended - is the caller's concern; the cache registers whatever it is given.
165+ // / The cache's only registration entry point; safe to call repeatedly and concurrently with
166+ // / Read(). Ranges known up front are registered before any Read(); ranges that only become
167+ // / known while reading (a late-materialization payload pass learns its pages after the probe
168+ // / pass) are registered as they are discovered. The list stays disjoint and offset-ordered, so
169+ // / only the part of a new range that no registered range covers is added - the overlap is
170+ // / dropped, as those bytes are already being fetched - and each registration is cut into ranges
171+ // / of at most `range_size_limit` bytes (one prefetch IO each) so a large pass is fetched
172+ // / concurrently. Which ranges to register, and not reporting those of an ended read, is the
173+ // / caller's concern.
179174 // /
180175 // / @param ranges The byte ranges to register.
181176 // / @return The offset of the first newly registered range, or nullopt when nothing was added.
@@ -195,36 +190,33 @@ class PAIMON_EXPORT ReadAheadCache {
195190 // / filled; false on cache miss (`dest` is left untouched).
196191 Result<bool > Read (const ByteRange& range, char * dest);
197192
198- // / Start fetching the first batch of pending ranges immediately.
199- // / AddRanges() only registers the ranges; without Warmup() the first fetch starts
200- // / when the first Read() arrives, racing the caller's own miss fetch.
193+ // / Start fetching from the first registered range forward immediately. AddRanges() only
194+ // / registers the ranges; without Warmup() the first fetch starts when the first Read() arrives,
195+ // / racing the caller's own miss fetch.
201196 void Warmup ();
202197
203198 // / Start fetching the registered ranges from `from_offset` forward, bounded by the
204199 // / pre-buffer limit. Warmup() is this call made from the first registered range.
205200 // / @param from_offset The offset to start fetching from, typically one AddRanges() returned.
206201 void Warmup (uint64_t from_offset);
207202
208- // / Collect the counters of the Read() calls, of the block cache, of the IOs
209- // / and of the late registrations into the given metrics as counters named
210- // / after `ReadAheadCacheMetrics`. Only reads issued through Read() are
211- // / counted as hits, block hits or misses; the fetches the cache dispatches
212- // / are counted in the io counters instead.
203+ // / Collect the counters of the Read() calls, of the block cache and of the IOs into the given
204+ // / metrics as counters named after `ReadAheadCacheMetrics`. Only reads issued through Read()
205+ // / are counted as hits, block hits or misses; the fetches the cache dispatches are counted in
206+ // / the io counters instead.
213207 // / @param metrics The metrics to write the counters into. A null
214208 // / pointer or a null shared pointer is a no-op.
215209 void CollectMetrics (std::shared_ptr<Metrics>* metrics) const ;
216210
217- // / Reset the cache to its initial state, clearing all cached data and configuration.
218- // /
219- // / This method waits for all ongoing asynchronous read operations to complete,
220- // / clears all cached entries, and resets the internal state so a fresh set of ranges can be
221- // / registered again with AddRanges().
211+ // / Drop the prefetched entries and zero all counters, so a fresh set of ranges can be
212+ // / registered with AddRanges(). Waits for the in-flight fetches before their buffers go away.
222213 // /
223- // / The block cache is kept: it caches the file rather than the registered
224- // / ranges, and a reader reusing the cache reads the same file again.
214+ // / The block cache is kept - it caches the file rather than the registered ranges, and a reader
215+ // / reusing the cache reads the same file again - but its counters are zeroed too. Unlike
216+ // / ReleaseBuffers(), the counters do not survive.
225217 void Reset ();
226218
227- // / Release all cached buffers and pending ranges while keeping the hit/miss
219+ // / Release all cached buffers and registered ranges while keeping the hit/miss
228220 // / counters intact.
229221 // /
230222 // / Unlike Reset(), the counters recorded by Read() remain readable through
0 commit comments