Fixed lag from continuous radar scans
This commit is contained in:
parent
cf637e6476
commit
cd0be72fc6
2 changed files with 7 additions and 1 deletions
|
@ -818,9 +818,12 @@ public class Commons {
|
||||||
|
|
||||||
private static final ConcurrentHashMap<String, Long> throttle_timePreviousForKey_ms = new ConcurrentHashMap<>(16);
|
private static final ConcurrentHashMap<String, Long> throttle_timePreviousForKey_ms = new ConcurrentHashMap<>(16);
|
||||||
public static boolean throttleMe(final String keyword) {
|
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 timeLastLog_ms = throttle_timePreviousForKey_ms.getOrDefault(keyword, Long.MIN_VALUE);
|
||||||
final long timeCurrent_ms = System.currentTimeMillis();
|
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);
|
throttle_timePreviousForKey_ms.put(keyword, timeCurrent_ms);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -519,6 +519,9 @@ public class StarMapRegistry {
|
||||||
// do not call during tileEntity construction (readFromNBT and validate)
|
// do not call during tileEntity construction (readFromNBT and validate)
|
||||||
private static boolean isExceptionReported = false;
|
private static boolean isExceptionReported = false;
|
||||||
private void cleanup() {
|
private void cleanup() {
|
||||||
|
if (Commons.throttleMe("Starmap registry cleanup", 180000)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
LocalProfiler.start("Starmap registry cleanup");
|
LocalProfiler.start("Starmap registry cleanup");
|
||||||
|
|
||||||
boolean isValid;
|
boolean isValid;
|
||||||
|
|
Loading…
Reference in a new issue