aboutsummaryrefslogtreecommitdiff
path: root/weed/filer/reader_cache.go
AgeCommit message (Collapse)AuthorFilesLines
2025-11-29mount: improve read throughput with parallel chunk fetching (#7569)Chris Lu1-3/+10
* mount: improve read throughput with parallel chunk fetching This addresses issue #7504 where a single weed mount FUSE instance does not fully utilize node network bandwidth when reading large files. Changes: - Add -concurrentReaders mount option (default: 16) to control the maximum number of parallel chunk fetches during read operations - Implement parallel section reading in ChunkGroup.ReadDataAt() using errgroup for better throughput when reading across multiple sections - Enhance ReaderCache with MaybeCacheMany() to prefetch multiple chunks ahead in parallel during sequential reads (now prefetches 4 chunks) - Increase ReaderCache limit dynamically based on concurrentReaders to support higher read parallelism The bottleneck was that chunks were being read sequentially even when they reside on different volume servers. By introducing parallel chunk fetching, a single mount instance can now better saturate available network bandwidth. Fixes: #7504 * fmt * Address review comments: make prefetch configurable, improve error handling Changes: 1. Add DefaultPrefetchCount constant (4) to reader_at.go 2. Add GetPrefetchCount() method to ChunkGroup that derives prefetch count from concurrentReaders (1/4 ratio, min 1, max 8) 3. Pass prefetch count through NewChunkReaderAtFromClient 4. Fix error handling in readDataAtParallel to prioritize errgroup error 5. Update all callers to use DefaultPrefetchCount constant For mount operations, prefetch scales with -concurrentReaders: - concurrentReaders=16 (default) -> prefetch=4 - concurrentReaders=32 -> prefetch=8 (capped) - concurrentReaders=4 -> prefetch=1 For non-mount paths (WebDAV, query engine, MQ), uses DefaultPrefetchCount. * fmt * Refactor: use variadic parameter instead of new function name Use NewChunkGroup with optional concurrentReaders parameter instead of creating a separate NewChunkGroupWithConcurrency function. This maintains backward compatibility - existing callers without the parameter get the default of 16 concurrent readers. * Use explicit concurrentReaders parameter instead of variadic * Refactor: use MaybeCache with count parameter instead of new MaybeCacheMany function * Address nitpick review comments - Add upper bound (128) on concurrentReaders to prevent excessive goroutine fan-out - Cap readerCacheLimit at 256 accordingly - Fix SetChunks: use Lock() instead of RLock() since we are writing to group.sections
2025-07-31Fixed weed mount reads with jwt.signing.read.key (#7061)Maxim Kostyukov1-1/+1
2025-05-28Add context with request (#6824)Aleksey Kosov1-2/+3
2024-09-14fix file read crash (#6021)Bruce1-1/+2
2024-09-11Feature limit caching to prescribed number of bytes per file (#6009)Eugeniy E. Mikhailov1-1/+6
* feature: we can check if a fileId is already in the cache We using this to protect cache from adding the same needle to the cache over and over. * fuse mount: Do not start dowloader if needle is already in the cache * added maxFilePartSizeInCache property to ChunkCache If file very large only first maxFilePartSizeInCache bytes are going to be put to the cache (subject to the needle size constrains). * feature: for large files put in cache no more than prescribed number of bytes Before this patch only the first needle of a large file was intended for caching. This patch uses maximum prescribed amount of bytes to be put in cache. This allows to bypass default 2MB maximum for a file part stored in the cache. * added dummy mock methods to satisfy interfaces of ChunkCache
2024-09-10weed mount cachingchrislu1-2/+2
2024-09-04Revert "weed mount, weed dav add option to force cache"chrislu1-2/+2
This reverts commit 7367b976b05bfa69158a60f205dec970c48f50f0.
2024-09-04weed mount, weed dav add option to force cachechrislu1-2/+2
2024-07-16Added tls for http clients (#5766)vadimartynov1-2/+2
* Added global http client * Added Do func for global http client * Changed the code to use the global http client * Fix http client in volume uploader * Fixed pkg name * Fixed http util funcs * Fixed http client for bench_filer_upload * Fixed http client for stress_filer_upload * Fixed http client for filer_server_handlers_proxy * Fixed http client for command_fs_merge_volumes * Fixed http client for command_fs_merge_volumes and command_volume_fsck * Fixed http client for s3api_server * Added init global client for main funcs * Rename global_client to client * Changed: - fixed NewHttpClient; - added CheckIsHttpsClientEnabled func - updated security.toml in scaffold * Reduce the visibility of some functions in the util/http/client pkg * Added the loadSecurityConfig function * Use util.LoadSecurityConfiguration() in NewHttpClient func
2024-02-29go fmtchrislu1-10/+10
2024-02-25Merge branch 'master' into mq-subscribechrislu1-1/+1
2024-02-19fix unaligned 64-bit atomic operation in weed mount on arm when readi… (#5308)Chris Lu1-1/+1
fix unaligned 64-bit atomic operation in weed mount on arm when reading a file fix #5306
2024-01-13refactoringchrislu1-1/+2
2023-01-16use one readerCache for the whole filechrislu1-1/+1
2023-01-14avoid index out of slice rangechrislu1-1/+1
2023-01-02more solid weed mount (#4089)Chris Lu1-3/+4
* compare chunks by timestamp * fix slab clearing error * fix test compilation * move oldest chunk to sealed, instead of by fullness * lock on fh.entryViewCache * remove verbose logs * revert slat clearing * less logs * less logs * track write and read by timestamp * remove useless logic * add entry lock on file handle release * use mem chunk only, swap file chunk has problems * comment out code that maybe used later * add debug mode to compare data read and write * more efficient readResolvedChunks with linked list * small optimization * fix test compilation * minor fix on writer * add SeparateGarbageChunks * group chunks into sections * turn off debug mode * fix tests * fix tests * tmp enable swap file chunk * Revert "tmp enable swap file chunk" This reverts commit 985137ec472924e4815f258189f6ca9f2168a0a7. * simple refactoring * simple refactoring * do not re-use swap file chunk. Sealed chunks should not be re-used. * comment out debugging facilities * either mem chunk or swap file chunk is fine now * remove orderedMutex as *semaphore.Weighted not found impactful * optimize size calculation for changing large files * optimize performance to avoid going through the long list of chunks * still problems with swap file chunk * rename * tiny optimization * swap file chunk save only successfully read data * fix * enable both mem and swap file chunk * resolve chunks with range * rename * fix chunk interval list * also change file handle chunk group when adding chunks * pick in-active chunk with time-decayed counter * fix compilation * avoid nil with empty fh.entry * refactoring * rename * rename * refactor visible intervals to *list.List * refactor chunkViews to *list.List * add IntervalList for generic interval list * change visible interval to use IntervalList in generics * cahnge chunkViews to *IntervalList[*ChunkView] * use NewFileChunkSection to create * rename variables * refactor * fix renaming leftover * renaming * renaming * add insert interval * interval list adds lock * incrementally add chunks to readers Fixes: 1. set start and stop offset for the value object 2. clone the value object 3. use pointer instead of copy-by-value when passing to interval.Value 4. use insert interval since adding chunk could be out of order * fix tests compilation * fix tests compilation
2022-08-26nano level precisionchrislu1-2/+2
2022-08-26Fix a few data races when reading files in mount (#3527)Patrick Schmidt1-19/+26
2022-08-24Fix race conditions during in-flight size checks (#3505)Patrick Schmidt1-1/+1
2022-08-21Fix hanging reads in chunk cacher (#3473)Patrick Schmidt1-33/+34
Sometimes when an unexpected error occurs the cacher would set an error and return. However, it would not broadcast the condition signal in that case, therefore leaving the goroutine that runs readChunkAt stuck forever. I figured that the condition is unnecessary because readChunkAt is acquiring a lock that is still held by the cacher goroutine anyway. Callees of startCaching have to wait for a WaitGroup which makes sure that readChunkAt can't acquire the lock before startCaching. This way readChunkAt can execute normally and check for the error.
2022-07-29move to https://github.com/seaweedfs/seaweedfschrislu1-3/+3
2022-07-15mount: fix bug during busy writeschrislu1-1/+10
fix https://github.com/chrislusf/seaweedfs/issues/3315
2022-07-13Avoid fatal error: sync: Unlock of unlocked RWMutexchrislu1-3/+3
fix https://github.com/chrislusf/seaweedfs/issues/3306
2022-07-08mount: fix racing conditionschrislu1-0/+7
prevent wrong reading when the SingleChunkCacher is started, but not finished yet
2022-03-04mount: avoid possible index out of bounds errorchrislu1-1/+5
2022-02-26prefetch other chunks when stream readingchrislu1-26/+30
2022-02-26remove logschrislu1-3/+0
2022-02-26better control for reader cachingchrislu1-0/+187