Skip to content

Commit

Permalink
Avoid lambda creation (or at least make it clear no lambda is created).
Browse files Browse the repository at this point in the history
  • Loading branch information
henningandersen committed Jan 25, 2024
1 parent 2e7ac84 commit ecc3332
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,8 @@ private CacheEntry(T chunk) {

private final BlobCacheMetrics blobCacheMetrics;

private final Runnable evictIncrementer;

private final LongSupplier relativeTimeInMillisSupplier;

public SharedBlobCacheService(
Expand Down Expand Up @@ -373,6 +375,7 @@ public SharedBlobCacheService(

this.blobCacheMetrics = blobCacheMetrics;
this.relativeTimeInMillisSupplier = relativeTimeInMillisSupplier;
this.evictIncrementer = blobCacheMetrics.getEvictedCountNonZeroFrequency()::increment;
}

public static long calculateCacheSize(Settings settings, long totalFsSize) {
Expand Down Expand Up @@ -1252,7 +1255,7 @@ private LFUCacheEntry initChunk(LFUCacheEntry entry) {
// need to evict something
SharedBytes.IO io;
synchronized (SharedBlobCacheService.this) {
io = maybeEvictAndTake(blobCacheMetrics.getEvictedCountNonZeroFrequency()::increment);
io = maybeEvictAndTake(evictIncrementer);
}
if (io == null) {
io = freeRegions.poll();
Expand Down

0 comments on commit ecc3332

Please sign in to comment.