From f1f16d2337dac86c4b7fc644a5d43ddd8b40a948 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Sat, 29 Nov 2025 01:30:23 -0800 Subject: [PATCH] Use explicit concurrentReaders parameter instead of variadic --- weed/filer/filechunk_group.go | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/weed/filer/filechunk_group.go b/weed/filer/filechunk_group.go index 3dadfbe93..b2e726a00 100644 --- a/weed/filer/filechunk_group.go +++ b/weed/filer/filechunk_group.go @@ -21,18 +21,17 @@ type ChunkGroup struct { } // NewChunkGroup creates a ChunkGroup with configurable concurrency. -// concurrentReaders is optional; if not provided or <= 0, defaults to 16. // concurrentReaders controls: // - Maximum parallel chunk fetches during read operations // - Read-ahead prefetch parallelism // - Number of concurrent section reads for large files -func NewChunkGroup(lookupFn wdclient.LookupFileIdFunctionType, chunkCache chunk_cache.ChunkCache, chunks []*filer_pb.FileChunk, concurrentReaders ...int) (*ChunkGroup, error) { - readers := 16 - if len(concurrentReaders) > 0 && concurrentReaders[0] > 0 { - readers = concurrentReaders[0] +// If concurrentReaders <= 0, defaults to 16. +func NewChunkGroup(lookupFn wdclient.LookupFileIdFunctionType, chunkCache chunk_cache.ChunkCache, chunks []*filer_pb.FileChunk, concurrentReaders int) (*ChunkGroup, error) { + if concurrentReaders <= 0 { + concurrentReaders = 16 } // ReaderCache limit should be at least concurrentReaders to allow parallel prefetching - readerCacheLimit := readers * 2 + readerCacheLimit := concurrentReaders * 2 if readerCacheLimit < 32 { readerCacheLimit = 32 } @@ -40,7 +39,7 @@ func NewChunkGroup(lookupFn wdclient.LookupFileIdFunctionType, chunkCache chunk_ lookupFn: lookupFn, sections: make(map[SectionIndex]*FileChunkSection), readerCache: NewReaderCache(readerCacheLimit, chunkCache, lookupFn), - concurrentReaders: readers, + concurrentReaders: concurrentReaders, } err := group.SetChunks(chunks)