lru print-stats option

This commit is contained in:
2024-07-28 12:29:53 +02:00
parent 4446aedb17
commit ff69827baf
2 changed files with 21 additions and 15 deletions

View File

@@ -20,6 +20,8 @@ public class JObjectLRU {
JObjectSizeEstimator jObjectSizeEstimator;
@ConfigProperty(name = "dhfs.objects.lru.limit")
long sizeLimit;
@ConfigProperty(name = "dhfs.objects.lru.print-stats")
boolean printStats;
private long _curSize = 0;
private long _evict = 0;
@@ -28,29 +30,32 @@ public class JObjectLRU {
private final AtomicLong _lastDrain = new AtomicLong(0);
private final LinkedHashMap<JObject<?>, Long> _cache = new LinkedHashMap<>();
private ExecutorService _statusExecutor;
private ExecutorService _statusExecutor = null;
@Startup
void init() {
_statusExecutor = Executors.newSingleThreadExecutor();
_statusExecutor.submit(() -> {
try {
while (true) {
Thread.sleep(1000);
if (_curSize > 0)
Log.info("Cache status: size="
+ _curSize / 1024 / 1024 + "MB"
+ " evicted=" + _evict);
_evict = 0;
if (printStats) {
_statusExecutor = Executors.newSingleThreadExecutor();
_statusExecutor.submit(() -> {
try {
while (true) {
Thread.sleep(1000);
if (_curSize > 0)
Log.info("Cache status: size="
+ _curSize / 1024 / 1024 + "MB"
+ " evicted=" + _evict);
_evict = 0;
}
} catch (InterruptedException ignored) {
}
} catch (InterruptedException ignored) {
}
});
});
}
}
@Shutdown
void shutdown() {
_statusExecutor.shutdownNow();
if (_statusExecutor != null)
_statusExecutor.shutdownNow();
}
public void notifyAccess(JObject<?> obj) {

View File

@@ -23,6 +23,7 @@ dhfs.files.write_last_chunk_limit=1.5
dhfs.objects.writeback.delay=100
dhfs.objects.writeback.limit=134217728
dhfs.objects.lru.limit=134217728
dhfs.objects.lru.print-stats=false
dhfs.objects.writeback.watermark-high=0.6
dhfs.objects.writeback.watermark-low=0.4
dhfs.objects.writeback.threads=4