From cd0be72fc696c7dea8a5991aa4465bb3cb152a32 Mon Sep 17 00:00:00 2001 From: Unknown Date: Mon, 9 Sep 2019 23:02:39 +0200 Subject: [PATCH] Fixed lag from continuous radar scans --- src/main/java/cr0s/warpdrive/Commons.java | 5 ++++- src/main/java/cr0s/warpdrive/data/StarMapRegistry.java | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/cr0s/warpdrive/Commons.java b/src/main/java/cr0s/warpdrive/Commons.java index da159f6f..89863610 100644 --- a/src/main/java/cr0s/warpdrive/Commons.java +++ b/src/main/java/cr0s/warpdrive/Commons.java @@ -818,9 +818,12 @@ public class Commons { private static final ConcurrentHashMap throttle_timePreviousForKey_ms = new ConcurrentHashMap<>(16); public static boolean throttleMe(final String keyword) { + return throttleMe(keyword,WarpDriveConfig.LOGGING_THROTTLE_MS); + } + public static boolean throttleMe(final String keyword, final long delay_ms) { final Long timeLastLog_ms = throttle_timePreviousForKey_ms.getOrDefault(keyword, Long.MIN_VALUE); final long timeCurrent_ms = System.currentTimeMillis(); - if (timeCurrent_ms > timeLastLog_ms + WarpDriveConfig.LOGGING_THROTTLE_MS) { + if (timeCurrent_ms > timeLastLog_ms + delay_ms) { throttle_timePreviousForKey_ms.put(keyword, timeCurrent_ms); return true; } diff --git a/src/main/java/cr0s/warpdrive/data/StarMapRegistry.java b/src/main/java/cr0s/warpdrive/data/StarMapRegistry.java index d4c0fb5e..c201dbaa 100644 --- a/src/main/java/cr0s/warpdrive/data/StarMapRegistry.java +++ b/src/main/java/cr0s/warpdrive/data/StarMapRegistry.java @@ -519,6 +519,9 @@ public class StarMapRegistry { // do not call during tileEntity construction (readFromNBT and validate) private static boolean isExceptionReported = false; private void cleanup() { + if (Commons.throttleMe("Starmap registry cleanup", 180000)) { + return; + } LocalProfiler.start("Starmap registry cleanup"); boolean isValid;