Browse Source

Refactor: use MaybeCache with count parameter instead of new MaybeCacheMany function

pull/7569/head
Chris Lu 5 days ago
parent
commit
5dfab8dbb8
  1. 2
      weed/filer/reader_at.go
  2. 8
      weed/filer/reader_cache.go

2
weed/filer/reader_at.go

@ -258,7 +258,7 @@ func (c *ChunkReadAt) readChunkSliceAt(ctx context.Context, buffer []byte, chunk
if nextChunkViews != nil && c.prefetchCount > 0 {
// Prefetch multiple chunks ahead for better sequential read throughput
// This keeps the network pipeline full with parallel chunk fetches
c.readerCache.MaybeCacheMany(nextChunkViews, c.prefetchCount)
c.readerCache.MaybeCache(nextChunkViews, c.prefetchCount)
}
}
}

8
weed/filer/reader_cache.go

@ -46,14 +46,10 @@ func NewReaderCache(limit int, chunkCache chunk_cache.ChunkCache, lookupFileIdFn
}
}
func (rc *ReaderCache) MaybeCache(chunkViews *Interval[*ChunkView]) {
rc.MaybeCacheMany(chunkViews, 1)
}
// MaybeCacheMany prefetches up to 'count' chunks ahead in parallel.
// MaybeCache prefetches up to 'count' chunks ahead in parallel.
// This improves read throughput for sequential reads by keeping the
// network pipeline full with parallel chunk fetches.
func (rc *ReaderCache) MaybeCacheMany(chunkViews *Interval[*ChunkView], count int) {
func (rc *ReaderCache) MaybeCache(chunkViews *Interval[*ChunkView], count int) {
if rc.lookupFileIdFn == nil {
return
}

Loading…
Cancel
Save