mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 16:37:43 +01:00
Add tick loop config options
This commit is contained in:
@@ -33,6 +33,15 @@ verbose
|
||||
* **default**: false
|
||||
* **description**: Sets whether the server should dump all configuration values to the server log on startup.
|
||||
|
||||
* enable-tick-overload
|
||||
- **default**: false
|
||||
- **description**: Enable/disable the vanilla tick overload detection ("Can't keep up! Is the server overloaded?")
|
||||
|
||||
* enable-tps-catchup
|
||||
- **default**: false
|
||||
- **description**: Enable/disable Spigot's TPS catchup (makes everything tick faster than 20 tps after
|
||||
lag spikes, which can cause more lag - also skews /tps reports by ruining the average with above 20 tps entries)
|
||||
|
||||
logger
|
||||
~~~~~~
|
||||
* show-duplicate-entity-uuid-errors
|
||||
|
||||
81
patches/server/0019-Tick-loop-config-options.patch
Normal file
81
patches/server/0019-Tick-loop-config-options.patch
Normal file
@@ -0,0 +1,81 @@
|
||||
From 6732e24262020bd428a3591bbd4eba7bfb0d96b7 Mon Sep 17 00:00:00 2001
|
||||
From: William Blake Galbreath <blake.galbreath@gmail.com>
|
||||
Date: Wed, 22 May 2019 22:30:08 -0500
|
||||
Subject: [PATCH] Tick loop config options
|
||||
|
||||
---
|
||||
.../net/minecraft/server/MinecraftServer.java | 31 +++++++++++++------
|
||||
.../java/net/pl3x/purpur/PurpurConfig.java | 7 +++++
|
||||
2 files changed, 28 insertions(+), 10 deletions(-)
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
index d3316a6ac..21ad507f9 100644
|
||||
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
@@ -852,16 +852,21 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
|
||||
long start = System.nanoTime(), curTime, tickSection = start; // Paper - Further improve server tick loop
|
||||
lastTick = start - TICK_TIME; // Paper
|
||||
while (this.isRunning) {
|
||||
- long i = ((curTime = System.nanoTime()) / (1000L * 1000L)) - this.nextTick; // Paper
|
||||
-
|
||||
- if (i > 5000L && this.nextTick - this.lastOverloadTime >= 30000L) { // CraftBukkit
|
||||
- long j = i / 50L;
|
||||
-
|
||||
- if (server.getWarnOnOverload()) // CraftBukkit
|
||||
- MinecraftServer.LOGGER.warn("Can't keep up! Is the server overloaded? Running {}ms or {} ticks behind", i, j);
|
||||
- this.nextTick += j * 50L;
|
||||
- this.lastOverloadTime = this.nextTick;
|
||||
+ // Purpur start - tick overload
|
||||
+ curTime = System.nanoTime();
|
||||
+ if (net.pl3x.purpur.PurpurConfig.enableTickOverload) {
|
||||
+ long i = ((curTime) / (1000L * 1000L)) - this.nextTick; // Paper
|
||||
+
|
||||
+ if (i > 5000L && this.nextTick - this.lastOverloadTime >= 30000L) { // CraftBukkit
|
||||
+ long j = i / 50L;
|
||||
+
|
||||
+ if (server.getWarnOnOverload()) // CraftBukkit
|
||||
+ MinecraftServer.LOGGER.warn("Can't keep up! Is the server overloaded? Running {}ms or {} ticks behind", i, j);
|
||||
+ this.nextTick += j * 50L;
|
||||
+ this.lastOverloadTime = this.nextTick;
|
||||
+ }
|
||||
}
|
||||
+ // Purpur end - tick overload
|
||||
|
||||
if ( ++MinecraftServer.currentTick % SAMPLE_INTERVAL == 0 )
|
||||
{
|
||||
@@ -892,7 +897,13 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
|
||||
this.a(this::canSleepForTick);
|
||||
this.methodProfiler.exitEnter("nextTickWait");
|
||||
this.ac = true;
|
||||
- this.ab = Math.max(SystemUtils.getMonotonicMillis() + 50L, this.nextTick);
|
||||
+ // Purpur start - tps catchup
|
||||
+ if (net.pl3x.purpur.PurpurConfig.enableTPSCatchup) {
|
||||
+ this.ab = Math.max(SystemUtils.getMonotonicMillis() + 50L, this.nextTick);
|
||||
+ } else {
|
||||
+ this.ab = this.nextTick = curTime / 1000000L + 50L;
|
||||
+ }
|
||||
+ // Purpur end - tps catchup
|
||||
this.sleepForTick();
|
||||
this.methodProfiler.exit();
|
||||
this.methodProfiler.b();
|
||||
diff --git a/src/main/java/net/pl3x/purpur/PurpurConfig.java b/src/main/java/net/pl3x/purpur/PurpurConfig.java
|
||||
index d7236ebd6..a23f5d798 100644
|
||||
--- a/src/main/java/net/pl3x/purpur/PurpurConfig.java
|
||||
+++ b/src/main/java/net/pl3x/purpur/PurpurConfig.java
|
||||
@@ -103,6 +103,13 @@ public class PurpurConfig {
|
||||
return config.getString(path, config.getString(path));
|
||||
}
|
||||
|
||||
+ public static boolean enableTickOverload = false;
|
||||
+ public static boolean enableTPSCatchup = false;
|
||||
+ private static void tickLoopSettings() {
|
||||
+ enableTickOverload = getBoolean("settings.enable-tick-overload", enableTickOverload);
|
||||
+ enableTPSCatchup = getBoolean("settings.enable-tps-catchup", enableTPSCatchup);
|
||||
+ }
|
||||
+
|
||||
public static boolean showDuplicateEntityUUIDErrors = true;
|
||||
public static boolean showUnknownAttributeWarnings = true;
|
||||
private static void loggerSettings() {
|
||||
--
|
||||
2.20.1
|
||||
|
||||
Reference in New Issue
Block a user