Fixed lag from continuous radar scans

This commit is contained in:
Unknown 2019-09-09 23:02:39 +02:00 committed by unknown
parent cf637e6476
commit cd0be72fc6
2 changed files with 7 additions and 1 deletions

View file

@ -818,9 +818,12 @@ public class Commons {
private static final ConcurrentHashMap<String, Long> 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;
}

View file

@ -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;