Skip to content

Commit 931f505

Browse files
committed
use numRegions to determine the size of the cache lists
1 parent 19fa7e1 commit 931f505

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

x-pack/plugin/blob-cache/src/main/java/org/elasticsearch/blobcache/shared/SharedBlobCacheService.java

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ public void validate(ByteSizeValue value, Map<Setting<?>, Object> settings, bool
254254
Setting.Property.NodeScope
255255
);
256256

257-
private interface Cache<K, T> extends Releasable {
257+
private interface Cache<K, T> {
258258
CacheEntry<T> get(K cacheKey, long fileLength, int region);
259259

260260
int forceEvict(Predicate<K> cacheKeyPredicate);
@@ -342,7 +342,7 @@ public SharedBlobCacheService(
342342
}
343343
this.regionSize = regionSize;
344344
assert regionSize > 0L;
345-
this.cache = new LRUCache(settings);
345+
this.cache = new LRUCache();
346346
try {
347347
sharedBytes = new SharedBytes(
348348
numRegions,
@@ -1174,17 +1174,14 @@ void touch() {
11741174
}
11751175

11761176
private final ConcurrentHashMap<RegionKey<KeyType>, LRUCacheEntry> keyMapping = new ConcurrentHashMap<>();
1177-
private final int maxSize = 10; // TODO: make a setting or even split?
1177+
private final int maxSize;
11781178
private final LRUCacheList front = new LRUCacheList();
11791179
private final LRUCacheList middle = new LRUCacheList();
11801180

1181-
LRUCache(Settings settings) {
1182-
1183-
}
1184-
1185-
@Override
1186-
public void close() {
1187-
1181+
LRUCache() {
1182+
// we split the front and middle lists in half, but require a minimum of 2
1183+
// for front to avoid strange head/tail semantics
1184+
maxSize = Math.min(2, numRegions / 2);
11881185
}
11891186

11901187
@Override

0 commit comments

Comments
 (0)