diff options
author | chickeneer <[email protected]> | 2017-03-10 03:01:46 -0500 |
---|---|---|
committer | Aikar <[email protected]> | 2017-03-10 03:03:49 -0500 |
commit | ff73ad6ddea1718c54f46e6c952be54875a61841 (patch) | |
tree | 861ce89cb6db99a0239af00f89520aa449e536dd | |
parent | 71d0330810e1fca5dd6327782b9d3093aec6f87c (diff) | |
download | Paper-ff73ad6ddea1718c54f46e6c952be54875a61841.tar.gz Paper-ff73ad6ddea1718c54f46e6c952be54875a61841.zip |
Fix tick loop bug - Fixes #624
We were not calculating time after the sleep ,resulting in wrong
calculations. This caused us to go 100ms, 0ms, 100ms, 0 ms repeatedly.
-rw-r--r-- | Spigot-Server-Patches/0020-Further-improve-server-tick-loop.patch | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/Spigot-Server-Patches/0020-Further-improve-server-tick-loop.patch b/Spigot-Server-Patches/0020-Further-improve-server-tick-loop.patch index 3837d52a7b..6b68c79b2a 100644 --- a/Spigot-Server-Patches/0020-Further-improve-server-tick-loop.patch +++ b/Spigot-Server-Patches/0020-Further-improve-server-tick-loop.patch @@ -1,4 +1,4 @@ -From bfa96ef58792ce8ee38410f4338d7860aa503a4b Mon Sep 17 00:00:00 2001 +From f34109ceb110e7cc63f4d4d037245a64ff5a2449 Mon Sep 17 00:00:00 2001 From: Aikar <[email protected]> Date: Tue, 1 Mar 2016 23:09:29 -0600 Subject: [PATCH] Further improve server tick loop @@ -12,7 +12,7 @@ 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 7539bb215..91fb12128 100644 +index 7539bb215..4476799d8 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java @@ -113,16 +113,12 @@ public abstract class MinecraftServer implements Runnable, ICommandListener, IAs @@ -107,13 +107,12 @@ index 7539bb215..91fb12128 100644 + if (wait > 0) { + if (catchupTime < 2E6) { + wait += Math.abs(catchupTime); -+ } -+ if (wait < catchupTime) { ++ } else if (wait < catchupTime) { + catchupTime -= wait; + wait = 0; -+ } else if (catchupTime > 2E6) { ++ } else { + wait -= catchupTime; -+ catchupTime -= catchupTime; ++ catchupTime = 0; + } + } if (wait > 0) { @@ -122,6 +121,7 @@ index 7539bb215..91fb12128 100644 - continue; - } else { - catchupTime = Math.min(1000000000, Math.abs(wait)); ++ curTime = System.nanoTime(); + wait = TICK_TIME - (curTime - lastTick); } @@ -210,5 +210,5 @@ index be2e31dea..6d21c3269 100644 return ( ( tps > 18.0 ) ? ChatColor.GREEN : ( tps > 16.0 ) ? ChatColor.YELLOW : ChatColor.RED ).toString() + ( ( tps > 20.0 ) ? "*" : "" ) + Math.min( Math.round( tps * 100.0 ) / 100.0, 20.0 ); -- -2.11.0.windows.3 +2.11.0 |