9
0
mirror of https://github.com/VolmitSoftware/Iris.git synced 2025-12-23 09:09:15 +00:00

Stop tracking cache hit ratios

This commit is contained in:
Daniel Mills
2021-07-17 00:29:47 -04:00
parent da1895125a
commit 92f5783f35
2 changed files with 1 additions and 23 deletions

View File

@@ -254,15 +254,6 @@ public class Iris extends VolmitPlugin implements Listener {
configWatcher.checkModified();
Iris.info("Hotloaded settings.json");
}
int ev = CachedStream2D.evictions.get();
if(IrisSettings.get().getGeneral().isDebug())
{
Iris.debug("Cache Hit Ratio: " + C.RED + Form.pc((double)CachedStream2D.cacheHits.get()/ (double)(CachedStream2D.cacheMisses.get() + CachedStream2D.cacheHits.get()), 2) + " " + C.LIGHT_PURPLE + " Evictions: " + C.AQUA + Form.f(ev/2) + "/s" + C.LIGHT_PURPLE + " Cache Size: " + C.RED + Form.f(CachedStream2D.cacheMisses.get() - CachedStream2D.evictions.get()));
CachedStream2D.cacheMisses.addAndGet(-CachedStream2D.evictions.get());
CachedStream2D.cacheHits.addAndGet(-CachedStream2D.evictions.get());
CachedStream2D.evictions.set(0);
}
}
public void onDisable() {

View File

@@ -29,9 +29,6 @@ import java.util.concurrent.atomic.AtomicInteger;
public class CachedStream2D<T> extends BasicStream<T> implements ProceduralStream<T> {
private final ProceduralStream<T> stream;
private final ConcurrentLinkedHashMap<Long, T> cache;
public static final AtomicInteger cacheHits = new AtomicInteger();
public static final AtomicInteger cacheMisses = new AtomicInteger();
public static final AtomicInteger evictions = new AtomicInteger();
public CachedStream2D(ProceduralStream<T> stream, int size) {
super();
@@ -40,7 +37,6 @@ public class CachedStream2D<T> extends BasicStream<T> implements ProceduralStrea
.initialCapacity(size)
.maximumWeightedCapacity(size)
.concurrencyLevel(32)
.listener((k, v) -> evictions.incrementAndGet())
.build();
}
@@ -61,16 +57,7 @@ public class CachedStream2D<T> extends BasicStream<T> implements ProceduralStrea
return stream.get((int) x, (int) z);
}
return cache.compute(Cache.key((int) x, (int) z), (k, v) -> {
if(v != null )
{
cacheHits.incrementAndGet();
return v;
}
cacheMisses.incrementAndGet();
return stream.get((int) x, (int) z);
});
return cache.compute(Cache.key((int) x, (int) z), (k, v) -> v != null ? v : stream.get((int) x, (int) z));
}
@Override