From 71490b2325c867be3056b9dba2a87bf62d69cd7f Mon Sep 17 00:00:00 2001 From: Shane Freeder Date: Thu, 9 Aug 2018 14:02:05 +0100 Subject: [PATCH] Fixup improve tick loop patch --- ...021-Further-improve-server-tick-loop.patch | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/Spigot-Server-Patches/0021-Further-improve-server-tick-loop.patch b/Spigot-Server-Patches/0021-Further-improve-server-tick-loop.patch index d9080999a2..0cf127dd31 100644 --- a/Spigot-Server-Patches/0021-Further-improve-server-tick-loop.patch +++ b/Spigot-Server-Patches/0021-Further-improve-server-tick-loop.patch @@ -1,4 +1,4 @@ -From 09cb0d01eeb61e890d63874ea8a5aaafc9df03e2 Mon Sep 17 00:00:00 2001 +From fd2388050096e00efb4c5a9c9db2d604ad1aa693 Mon Sep 17 00:00:00 2001 From: Aikar Date: Tue, 1 Mar 2016 23:09:29 -0600 Subject: [PATCH] Further improve server tick loop @@ -12,9 +12,18 @@ Previous implementation did not calculate TPS correctly. Switch to a realistic rolling average and factor in std deviation as an extra reporting variable diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index d8874c398..6fbf841f0 100644 +index c72bdd29d1..c7b0cdaa20 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java +@@ -76,7 +76,7 @@ public abstract class MinecraftServer implements IAsyncTaskHandler, IMojangStati + private final List l = Lists.newArrayList(); + public final MethodProfiler methodProfiler = new MethodProfiler(); + private ServerConnection m; // Spigot +- private final ServerPing n = new ServerPing(); ++4 private final ServerPing n = new ServerPing(); + private final Random o = new Random(); + public final DataFixer dataConverterManager; + private String serverIp; @@ -142,7 +142,7 @@ public abstract class MinecraftServer implements IAsyncTaskHandler, IMojangStati public org.bukkit.command.ConsoleCommandSender console; public org.bukkit.command.RemoteConsoleCommandSender remoteConsole; @@ -99,7 +108,7 @@ index d8874c398..6fbf841f0 100644 // Spigot start Arrays.fill( recentTps, 20 ); -- long lastTick = System.nanoTime(), catchupTime = 0, curTime, wait, tickSection = lastTick; +- long lastTick = System.nanoTime(), catchupTime = 0, curTime, wait, tickSection = lastTick, tickCount = 1; + long start = System.nanoTime(), lastTick = start - TICK_TIME, catchupTime = 0, curTime, wait, tickSection = start; // Paper - Further improve server tick loop while (this.isRunning) { curTime = System.nanoTime(); @@ -127,7 +136,7 @@ index d8874c398..6fbf841f0 100644 + wait = TICK_TIME - (curTime - lastTick); } -- if ( MinecraftServer.currentTick++ % SAMPLE_INTERVAL == 0 ) +- if ( tickCount++ % SAMPLE_INTERVAL == 0 ) + catchupTime = Math.min(MAX_CATCHUP_BUFFER, catchupTime - wait); + if ( ++MinecraftServer.currentTick % SAMPLE_INTERVAL == 0 ) { @@ -149,7 +158,7 @@ index d8874c398..6fbf841f0 100644 } lastTick = curTime; diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index c2d479dd1..d28205cdf 100644 +index c2d479dd11..d28205cdfc 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -1836,6 +1836,17 @@ public final class CraftServer implements Server { @@ -171,7 +180,7 @@ index c2d479dd1..d28205cdf 100644 { diff --git a/src/main/java/org/spigotmc/TicksPerSecondCommand.java b/src/main/java/org/spigotmc/TicksPerSecondCommand.java -index be2e31dea..6d21c3269 100644 +index be2e31deae..6d21c32692 100644 --- a/src/main/java/org/spigotmc/TicksPerSecondCommand.java +++ b/src/main/java/org/spigotmc/TicksPerSecondCommand.java @@ -1,8 +1,5 @@