Skip to content

SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.

a little bit more efficient

Chris Lu3dbd51c3c2b2
diff --git a/weed/util/chunk_cache/chunk_cache.go b/weed/util/chunk_cache/chunk_cache.go
index ca26e1f772..325253837a 100644
--- a/weed/util/chunk_cache/chunk_cache.go
+++ b/weed/util/chunk_cache/chunk_cache.go
@@ -58,9 +58,21 @@ func (c *ChunkCache) doGetChunk(fileId string, chunkSize uint64) (data []byte) {
return nil
}
- for _, diskCache := range c.diskCaches {
- data := diskCache.getChunk(fid.Key)
- if len(data) != 0 && len(data) >= int(chunkSize) {
+ if chunkSize < onDiskCacheSizeLimit0 {
+ data = c.diskCaches[0].getChunk(fid.Key)
+ if len(data) >= int(chunkSize) {
+ return data
+ }
+ }
+ if chunkSize < onDiskCacheSizeLimit1 {
+ data = c.diskCaches[1].getChunk(fid.Key)
+ if len(data) >= int(chunkSize) {
+ return data
+ }
+ }
+ {
+ data = c.diskCaches[2].getChunk(fid.Key)
+ if len(data) >= int(chunkSize) {
return data
}
}