This is an automated email from the ASF dual-hosted git repository. edcoleman pushed a commit to branch 2.1 in repository https://gitbox.apache.org/repos/asf/accumulo.git
The following commit(s) were added to refs/heads/2.1 by this push: new efdc4fc3d7 Remove pool metrics instrumentation from LRU caches (#4345) efdc4fc3d7 is described below commit efdc4fc3d725d9bb2c364db6548c9251ea793a6d Author: EdColeman <d...@etcoleman.com> AuthorDate: Thu Mar 7 14:38:40 2024 -0500 Remove pool metrics instrumentation from LRU caches (#4345) * The LRU metrics use a thread pool with 1 thread to generate cache statistics. The pool size is not configurable. It seems unnecessary to produce detail pool metrics for these caches. * resolve missing isPresent check for weighted size, default to 0 if not present in TinyLfuBlockCache * other minor quality check improvements. (final varibles, unneeded initializations.) --- .../core/file/blockfile/cache/lru/LruBlockCache.java | 14 ++++++++------ .../file/blockfile/cache/tinylfu/TinyLfuBlockCache.java | 4 ++-- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/core/src/main/java/org/apache/accumulo/core/file/blockfile/cache/lru/LruBlockCache.java b/core/src/main/java/org/apache/accumulo/core/file/blockfile/cache/lru/LruBlockCache.java index e3c399ec58..01972f8ffe 100644 --- a/core/src/main/java/org/apache/accumulo/core/file/blockfile/cache/lru/LruBlockCache.java +++ b/core/src/main/java/org/apache/accumulo/core/file/blockfile/cache/lru/LruBlockCache.java @@ -103,7 +103,7 @@ public class LruBlockCache extends SynchronousLoadingBlockCache implements Block /** Statistics thread schedule pool (for heavy debugging, could remove) */ private final ScheduledExecutorService scheduleThreadPool = ThreadPools.getServerThreadPools() - .createScheduledExecutorService(1, "LRUBlockCacheStats", true); + .createScheduledExecutorService(1, "LRUBlockCacheStats", false); /** Current size of cache */ private final AtomicLong size; @@ -391,9 +391,9 @@ public class LruBlockCache extends SynchronousLoadingBlockCache implements Block */ private class BlockBucket implements Comparable<BlockBucket> { - private CachedBlockQueue queue; - private long totalSize = 0; - private long bucketSize; + private final CachedBlockQueue queue; + private long totalSize; + private final long bucketSize; public BlockBucket(long bytesToFree, long blockSize, long bucketSize) { this.bucketSize = bucketSize; @@ -512,7 +512,7 @@ public class LruBlockCache extends SynchronousLoadingBlockCache implements Block * Thread is triggered into action by {@link LruBlockCache#runEviction()} */ private static class EvictionThread extends AccumuloDaemonThread { - private WeakReference<LruBlockCache> cache; + private final WeakReference<LruBlockCache> cache; private boolean running = false; public EvictionThread(LruBlockCache cache) { @@ -532,7 +532,9 @@ public class LruBlockCache extends SynchronousLoadingBlockCache implements Block running = true; try { this.wait(); - } catch (InterruptedException e) {} + } catch (InterruptedException e) { + // empty + } } LruBlockCache cache = this.cache.get(); if (cache == null) { diff --git a/core/src/main/java/org/apache/accumulo/core/file/blockfile/cache/tinylfu/TinyLfuBlockCache.java b/core/src/main/java/org/apache/accumulo/core/file/blockfile/cache/tinylfu/TinyLfuBlockCache.java index beabe5a7ad..04cab1a38c 100644 --- a/core/src/main/java/org/apache/accumulo/core/file/blockfile/cache/tinylfu/TinyLfuBlockCache.java +++ b/core/src/main/java/org/apache/accumulo/core/file/blockfile/cache/tinylfu/TinyLfuBlockCache.java @@ -62,7 +62,7 @@ public final class TinyLfuBlockCache implements BlockCache { private final Policy.Eviction<String,Block> policy; private final int maxSize; private final ScheduledExecutorService statsExecutor = ThreadPools.getServerThreadPools() - .createScheduledExecutorService(1, "TinyLfuBlockCacheStatsExecutor", true); + .createScheduledExecutorService(1, "TinyLfuBlockCacheStatsExecutor", false); public TinyLfuBlockCache(Configuration conf, CacheType type) { cache = Caffeine.newBuilder() @@ -118,7 +118,7 @@ public final class TinyLfuBlockCache implements BlockCache { private void logStats() { double maxMB = ((double) policy.getMaximum()) / ((double) (1024 * 1024)); - double sizeMB = ((double) policy.weightedSize().getAsLong()) / ((double) (1024 * 1024)); + double sizeMB = ((double) policy.weightedSize().orElse(0)) / ((double) (1024 * 1024)); double freeMB = maxMB - sizeMB; log.debug("Cache Size={}MB, Free={}MB, Max={}MB, Blocks={}", sizeMB, freeMB, maxMB, cache.estimatedSize());