mirror of
https://github.com/minio/minio.git
synced 2025-04-21 11:04:20 -04:00
cache: remove cache space constraint (#6635)
relax cache constraint of requiring 100 times size of object being cached for better cache utilization.
This commit is contained in:
parent
23b166b318
commit
557f382477
@ -38,8 +38,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// disk cache needs to have cacheSizeMultiplier * object size space free for a cache entry to be created.
|
// disk cache needs to have object size space free for a cache entry to be created.
|
||||||
cacheSizeMultiplier = 100
|
|
||||||
cacheTrashDir = "trash"
|
cacheTrashDir = "trash"
|
||||||
cacheCleanupInterval = 10 // in minutes
|
cacheCleanupInterval = 10 // in minutes
|
||||||
)
|
)
|
||||||
@ -231,8 +230,7 @@ func (c cacheObjects) GetObjectNInfo(ctx context.Context, bucket, object string,
|
|||||||
// We don't cache partial objects.
|
// We don't cache partial objects.
|
||||||
return c.GetObjectNInfoFn(ctx, bucket, object, rs, h, writeLock, opts)
|
return c.GetObjectNInfoFn(ctx, bucket, object, rs, h, writeLock, opts)
|
||||||
}
|
}
|
||||||
if !dcache.diskAvailable(objInfo.Size * cacheSizeMultiplier) {
|
if !dcache.diskAvailable(objInfo.Size) {
|
||||||
// cache only objects < 1/100th of disk capacity
|
|
||||||
return c.GetObjectNInfoFn(ctx, bucket, object, rs, h, writeLock, opts)
|
return c.GetObjectNInfoFn(ctx, bucket, object, rs, h, writeLock, opts)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -308,8 +306,7 @@ func (c cacheObjects) GetObject(ctx context.Context, bucket, object string, star
|
|||||||
// We don't cache partial objects.
|
// We don't cache partial objects.
|
||||||
return GetObjectFn(ctx, bucket, object, startOffset, length, writer, etag, opts)
|
return GetObjectFn(ctx, bucket, object, startOffset, length, writer, etag, opts)
|
||||||
}
|
}
|
||||||
if !dcache.diskAvailable(objInfo.Size * cacheSizeMultiplier) {
|
if !dcache.diskAvailable(objInfo.Size) {
|
||||||
// cache only objects < 1/100th of disk capacity
|
|
||||||
return GetObjectFn(ctx, bucket, object, startOffset, length, writer, etag, opts)
|
return GetObjectFn(ctx, bucket, object, startOffset, length, writer, etag, opts)
|
||||||
}
|
}
|
||||||
// Initialize pipe.
|
// Initialize pipe.
|
||||||
@ -656,7 +653,7 @@ func (c cacheObjects) PutObject(ctx context.Context, bucket, object string, r *h
|
|||||||
size := r.Size()
|
size := r.Size()
|
||||||
|
|
||||||
// fetch from backend if there is no space on cache drive
|
// fetch from backend if there is no space on cache drive
|
||||||
if !dcache.diskAvailable(size * cacheSizeMultiplier) {
|
if !dcache.diskAvailable(size) {
|
||||||
return putObjectFn(ctx, bucket, object, r, metadata, opts)
|
return putObjectFn(ctx, bucket, object, r, metadata, opts)
|
||||||
}
|
}
|
||||||
// fetch from backend if cache exclude pattern or cache-control
|
// fetch from backend if cache exclude pattern or cache-control
|
||||||
@ -748,9 +745,9 @@ func (c cacheObjects) PutObjectPart(ctx context.Context, bucket, object, uploadI
|
|||||||
return putObjectPartFn(ctx, bucket, object, uploadID, partID, data, opts)
|
return putObjectPartFn(ctx, bucket, object, uploadID, partID, data, opts)
|
||||||
}
|
}
|
||||||
|
|
||||||
// make sure cache has at least cacheSizeMultiplier * size available
|
// make sure cache has at least size space available
|
||||||
size := data.Size()
|
size := data.Size()
|
||||||
if !dcache.diskAvailable(size * cacheSizeMultiplier) {
|
if !dcache.diskAvailable(size) {
|
||||||
select {
|
select {
|
||||||
case dcache.purgeChan <- struct{}{}:
|
case dcache.purgeChan <- struct{}{}:
|
||||||
default:
|
default:
|
||||||
|
@ -31,7 +31,7 @@ minio server -h
|
|||||||
- The cache drives are required to be a filesystem mount point with [`atime`](http://kerolasa.github.io/filetimes.html) support to be enabled on the drive. Alternatively writable directories with atime support can be specified in MINIO_CACHE_DRIVES
|
- The cache drives are required to be a filesystem mount point with [`atime`](http://kerolasa.github.io/filetimes.html) support to be enabled on the drive. Alternatively writable directories with atime support can be specified in MINIO_CACHE_DRIVES
|
||||||
- Expiration of each cached entry takes user provided expiry as a hint, and defaults to 90 days if not provided.
|
- Expiration of each cached entry takes user provided expiry as a hint, and defaults to 90 days if not provided.
|
||||||
- Garbage collection sweep of the expired cache entries happens whenever cache usage is > 80% of drive capacity, GC continues until sufficient disk space is reclaimed.
|
- Garbage collection sweep of the expired cache entries happens whenever cache usage is > 80% of drive capacity, GC continues until sufficient disk space is reclaimed.
|
||||||
- An object is only cached when drive has sufficient disk space, upto 100 times the size of the object.
|
- An object is only cached when drive has sufficient disk space.
|
||||||
|
|
||||||
## Behavior
|
## Behavior
|
||||||
Disk caching caches objects for both **uploaded** and **downloaded** objects i.e
|
Disk caching caches objects for both **uploaded** and **downloaded** objects i.e
|
||||||
|
Loading…
x
Reference in New Issue
Block a user