mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-15 07:01:36 +08:00
Reapply tick loop patch.
This commit is contained in:
parent
13c46dd878
commit
2367cf0a3d
@ -1,14 +1,14 @@
|
||||
From 00045f375cae8ca1e74ef10254c6827b095ecdb3 Mon Sep 17 00:00:00 2001
|
||||
From: md_5 <md_5@live.com.au>
|
||||
Date: Sun, 3 Feb 2013 12:28:17 +1100
|
||||
From 152b956a0d94edd3c7384e084e174f69f53238d9 Mon Sep 17 00:00:00 2001
|
||||
From: md_5 <git@md-5.net>
|
||||
Date: Wed, 22 Jan 2014 19:14:15 +1100
|
||||
Subject: [PATCH] Highly Optimized Tick Loop
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
index 6a01982..0966b4b 100644
|
||||
index 6a01982..7dabffb 100644
|
||||
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
@@ -101,6 +101,12 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
|
||||
@@ -101,6 +101,11 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
|
||||
public java.util.Queue<Runnable> processQueue = new java.util.concurrent.ConcurrentLinkedQueue<Runnable>();
|
||||
public int autosavePeriod;
|
||||
// CraftBukkit end
|
||||
@ -16,23 +16,17 @@ index 6a01982..0966b4b 100644
|
||||
+ private static final int TPS = 20;
|
||||
+ private static final int TICK_TIME = 1000000000 / TPS;
|
||||
+ public static double currentTPS = 0;
|
||||
+ private static long catchupTime = 0;
|
||||
+ // Spigot end
|
||||
|
||||
public MinecraftServer(OptionSet options, Proxy proxy) { // CraftBukkit - signature file -> OptionSet
|
||||
i = this;
|
||||
@@ -422,45 +428,23 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
|
||||
public void run() {
|
||||
try {
|
||||
if (this.init()) {
|
||||
- long i = ap();
|
||||
- long j = 0L;
|
||||
-
|
||||
- this.p.setMOTD(new ChatComponentText(this.motd));
|
||||
- this.p.setServerInfo(new ServerPingServerData("1.7.2", 4));
|
||||
- this.a(this.p);
|
||||
-
|
||||
- while (this.isRunning) {
|
||||
@@ -429,38 +434,25 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
|
||||
this.p.setServerInfo(new ServerPingServerData("1.7.2", 4));
|
||||
this.a(this.p);
|
||||
|
||||
+ // Spigot start
|
||||
+ long lastTick = 0, catchupTime = 0, curTime, wait;
|
||||
while (this.isRunning) {
|
||||
- long k = ap();
|
||||
- long l = k - i;
|
||||
-
|
||||
@ -53,10 +47,8 @@ index 6a01982..0966b4b 100644
|
||||
- if (this.worlds.get(0).everyoneDeeplySleeping()) { // CraftBukkit
|
||||
- this.t();
|
||||
- j = 0L;
|
||||
+ // Spigot start
|
||||
+ for (long lastTick = 0L; this.isRunning;) {
|
||||
+ long curTime = System.nanoTime();
|
||||
+ long wait = TICK_TIME - (curTime - lastTick) - catchupTime;
|
||||
+ curTime = System.nanoTime();
|
||||
+ wait = TICK_TIME - (curTime - lastTick) - catchupTime;
|
||||
+ if (wait > 0) {
|
||||
+ Thread.sleep(wait / 1000000);
|
||||
+ catchupTime = 0;
|
||||
@ -67,15 +59,15 @@ index 6a01982..0966b4b 100644
|
||||
- j -= 50L;
|
||||
- this.t();
|
||||
- }
|
||||
+ catchupTime = Math.min(TICK_TIME * TPS, Math.abs(wait));
|
||||
+ catchupTime = Math.min(1000000000, Math.abs(wait));
|
||||
}
|
||||
-
|
||||
- Thread.sleep(1L);
|
||||
- this.N = true;
|
||||
+ currentTPS = (currentTPS * 0.95) + (1E9 / (curTime - lastTick) * 0.05);
|
||||
+ lastTick = curTime;
|
||||
+ MinecraftServer.currentTick++;
|
||||
+ this.t();
|
||||
this.N = true;
|
||||
}
|
||||
+ // Spigot end
|
||||
} else {
|
||||
|
@ -1,4 +1,4 @@
|
||||
From 67aa884a8f52483111b5a4e2c3327d4163750602 Mon Sep 17 00:00:00 2001
|
||||
From 98e68a83a33a2f4152c4afe7eeae5450739829bc Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Thu, 10 Jan 2013 00:18:11 -0500
|
||||
Subject: [PATCH] Improved Timings System
|
||||
@ -64,7 +64,7 @@ index dc0abc5..3d6aeff 100644
|
||||
|
||||
protected String H() {
|
||||
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
index 0966b4b..d740620 100644
|
||||
index 7dabffb..59f6831 100644
|
||||
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
@@ -10,7 +10,6 @@ import java.util.ArrayList;
|
||||
@ -83,18 +83,19 @@ index 0966b4b..d740620 100644
|
||||
import org.bukkit.craftbukkit.util.Waitable;
|
||||
import org.bukkit.event.server.RemoteServerCommandEvent;
|
||||
import org.bukkit.event.world.WorldSaveEvent;
|
||||
@@ -442,7 +442,10 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
|
||||
@@ -449,8 +449,11 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
|
||||
currentTPS = (currentTPS * 0.95) + (1E9 / (curTime - lastTick) * 0.05);
|
||||
lastTick = curTime;
|
||||
MinecraftServer.currentTick++;
|
||||
+ SpigotTimings.serverTickTimer.startTiming();
|
||||
this.t();
|
||||
this.N = true;
|
||||
+ SpigotTimings.serverTickTimer.stopTiming();
|
||||
+ org.spigotmc.CustomTimingsHandler.tick();
|
||||
}
|
||||
// Spigot end
|
||||
} else {
|
||||
@@ -567,6 +570,7 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
|
||||
@@ -575,6 +578,7 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
|
||||
public void u() {
|
||||
this.methodProfiler.a("levels");
|
||||
|
||||
@ -102,7 +103,7 @@ index 0966b4b..d740620 100644
|
||||
// CraftBukkit start
|
||||
this.server.getScheduler().mainThreadHeartbeat(this.ticks);
|
||||
|
||||
@@ -575,7 +579,10 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
|
||||
@@ -583,7 +587,10 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
|
||||
processQueue.remove().run();
|
||||
}
|
||||
|
||||
@ -113,7 +114,7 @@ index 0966b4b..d740620 100644
|
||||
|
||||
// Send time updates to everyone, it will get the right time from the world the player is in.
|
||||
if (this.ticks % 20 == 0) {
|
||||
@@ -627,7 +634,9 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
|
||||
@@ -635,7 +642,9 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
|
||||
|
||||
this.methodProfiler.b();
|
||||
this.methodProfiler.a("tracker");
|
||||
@ -123,7 +124,7 @@ index 0966b4b..d740620 100644
|
||||
this.methodProfiler.b();
|
||||
this.methodProfiler.b();
|
||||
// } // CraftBukkit
|
||||
@@ -636,14 +645,20 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
|
||||
@@ -644,14 +653,20 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
|
||||
}
|
||||
|
||||
this.methodProfiler.c("connection");
|
||||
@ -300,7 +301,7 @@ index 00c2a18..f1bf467 100644
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
|
||||
index 9f09a3d..74a2d45 100644
|
||||
index a0e4ade..9672508 100644
|
||||
--- a/src/main/java/net/minecraft/server/WorldServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/WorldServer.java
|
||||
@@ -184,10 +184,12 @@ public class WorldServer extends World implements org.bukkit.BlockChangeDelegate
|
||||
|
@ -1,14 +1,14 @@
|
||||
From 438d4bd728376285ad5aeaec80c5d3847d5fedd4 Mon Sep 17 00:00:00 2001
|
||||
From 0783a86b0d7014214d1610a6e3372b143ba38909 Mon Sep 17 00:00:00 2001
|
||||
From: agentk20 <agentkid20@gmail.com>
|
||||
Date: Sat, 3 Aug 2013 19:28:48 +1000
|
||||
Subject: [PATCH] Fully Disable Snooper When Not Required
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
index d740620..cfb7922 100644
|
||||
index 59f6831..0e0de44 100644
|
||||
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
@@ -555,11 +555,11 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
|
||||
@@ -563,11 +563,11 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
|
||||
this.f[this.ticks % 100] = System.nanoTime() - i;
|
||||
this.methodProfiler.b();
|
||||
this.methodProfiler.a("snooper");
|
||||
|
@ -1,22 +1,22 @@
|
||||
From 04ebf9dffc8583903b7c28bf511e007c109d1a04 Mon Sep 17 00:00:00 2001
|
||||
From e33c3e986cae74b9cb85dd3488de76556bda8272 Mon Sep 17 00:00:00 2001
|
||||
From: md_5 <md_5@live.com.au>
|
||||
Date: Sat, 23 Feb 2013 12:33:20 +1100
|
||||
Subject: [PATCH] Watchdog Thread.
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
index cfb7922..1f057b1 100644
|
||||
index 0e0de44..a55160f 100644
|
||||
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
@@ -446,6 +446,7 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
|
||||
this.t();
|
||||
@@ -454,6 +454,7 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
|
||||
this.N = true;
|
||||
SpigotTimings.serverTickTimer.stopTiming();
|
||||
org.spigotmc.CustomTimingsHandler.tick();
|
||||
+ org.spigotmc.WatchdogThread.tick();
|
||||
}
|
||||
// Spigot end
|
||||
} else {
|
||||
@@ -472,6 +473,7 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
|
||||
@@ -480,6 +481,7 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
|
||||
this.a(crashreport);
|
||||
} finally {
|
||||
try {
|
||||
|
@ -1,4 +1,4 @@
|
||||
From f90fa8326368b3ccd386b6a12ba643f0e8e34fcd Mon Sep 17 00:00:00 2001
|
||||
From a9ac8accb027efbd0292d9d4e185a3c017c40054 Mon Sep 17 00:00:00 2001
|
||||
From: md_5 <git@md-5.net>
|
||||
Date: Fri, 13 Dec 2013 11:58:58 +1100
|
||||
Subject: [PATCH] Configurable Amount of Netty Threads
|
||||
@ -6,7 +6,7 @@ Subject: [PATCH] Configurable Amount of Netty Threads
|
||||
This brings back the option that the Spigot version of netty saw. By default Netty will try and use cores*2 threads, however if running multiple servers on the same machine, this can be too many threads. Additionally some people have 16 core servers. If 32 Netty threads are allowed in this setup, then the lock contention, and thus blocking between threads becomes much greater, leading to decreased performance.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
index 1f057b1..eee0119 100644
|
||||
index a55160f..ccf7abd 100644
|
||||
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
@@ -51,7 +51,7 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
|
||||
@ -18,7 +18,7 @@ index 1f057b1..eee0119 100644
|
||||
private final ServerPing p = new ServerPing();
|
||||
private final Random q = new Random();
|
||||
private String serverIp;
|
||||
@@ -112,7 +112,7 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
|
||||
@@ -111,7 +111,7 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
|
||||
i = this;
|
||||
this.c = proxy;
|
||||
// this.universe = file1; // CraftBukkit
|
||||
@ -27,7 +27,7 @@ index 1f057b1..eee0119 100644
|
||||
this.n = new CommandDispatcher();
|
||||
// this.convertable = new WorldLoaderServer(file1); // CraftBukkit - moved to DedicatedServer.init
|
||||
this.S = (new YggdrasilAuthenticationService(proxy, UUID.randomUUID().toString())).createMinecraftSessionService();
|
||||
@@ -1211,7 +1211,7 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
|
||||
@@ -1219,7 +1219,7 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
|
||||
}
|
||||
|
||||
public ServerConnection ag() {
|
||||
|
@ -1,14 +1,14 @@
|
||||
From 832ac75e2e0fc5371db065ebd237e61646ac636e Mon Sep 17 00:00:00 2001
|
||||
From 96112e90b66c38f472a93f5c133af24d6c87a69f Mon Sep 17 00:00:00 2001
|
||||
From: md_5 <git@md-5.net>
|
||||
Date: Wed, 18 Dec 2013 13:39:14 +1100
|
||||
Subject: [PATCH] Log Cause of Unexpected Exceptions
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
index eee0119..868061b 100644
|
||||
index ccf7abd..6410f32 100644
|
||||
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
@@ -454,6 +454,12 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
|
||||
@@ -462,6 +462,12 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
|
||||
}
|
||||
} catch (Throwable throwable) {
|
||||
h.error("Encountered an unexpected exception", throwable);
|
||||
|
@ -1,14 +1,14 @@
|
||||
From 0373bc1b64bf816402795a7b14f73805a2084c99 Mon Sep 17 00:00:00 2001
|
||||
From 021a758c0089cfe0111815a7053e0a4dcfac17b7 Mon Sep 17 00:00:00 2001
|
||||
From: md_5 <git@md-5.net>
|
||||
Date: Sun, 12 Jan 2014 20:56:41 +1100
|
||||
Subject: [PATCH] Try and Debug Crash Reports Crashing
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
index 868061b..c58c73e 100644
|
||||
index 6410f32..6fd430f 100644
|
||||
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
@@ -627,7 +627,13 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
|
||||
@@ -635,7 +635,13 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
|
||||
try {
|
||||
worldserver.doTick();
|
||||
} catch (Throwable throwable) {
|
||||
@ -22,7 +22,7 @@ index 868061b..c58c73e 100644
|
||||
worldserver.a(crashreport);
|
||||
throw new ReportedException(crashreport);
|
||||
}
|
||||
@@ -635,7 +641,13 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
|
||||
@@ -643,7 +649,13 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
|
||||
try {
|
||||
worldserver.tickEntities();
|
||||
} catch (Throwable throwable1) {
|
||||
@ -37,5 +37,5 @@ index 868061b..c58c73e 100644
|
||||
throw new ReportedException(crashreport);
|
||||
}
|
||||
--
|
||||
1.8.4.msysgit.0
|
||||
1.8.3.2
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
From e4ad495ac44e88b0cabbe3d51098af3f5e125ba7 Mon Sep 17 00:00:00 2001
|
||||
From 6e38905c8bd6d8ead1e76ca8581d1842f26ae583 Mon Sep 17 00:00:00 2001
|
||||
From: md_5 <git@md-5.net>
|
||||
Date: Sun, 12 Jan 2014 21:07:18 +1100
|
||||
Subject: [PATCH] Replace AutoSave Mechanism
|
||||
@ -6,10 +6,10 @@ Subject: [PATCH] Replace AutoSave Mechanism
|
||||
The problem here is that MinecraftServer.save(..), will attempt to sleep whilst all pending chunks are written to disk, however due to various and complicated bugs, it will wait for an incorrect amount of chunks, which may cause it to sleep for an overly long amount of time. Instead we will mimic the save-all command in its behaviour, which is both safe and performant.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
index c58c73e..c158e8a 100644
|
||||
index 6fd430f..1225411 100644
|
||||
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
@@ -555,7 +555,16 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
|
||||
@@ -563,7 +563,16 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
|
||||
if ((this.autosavePeriod > 0) && ((this.ticks % this.autosavePeriod) == 0)) { // CraftBukkit
|
||||
this.methodProfiler.a("save");
|
||||
this.t.savePlayers();
|
||||
@ -28,5 +28,5 @@ index c58c73e..c158e8a 100644
|
||||
}
|
||||
|
||||
--
|
||||
1.8.4.msysgit.0
|
||||
1.8.3.2
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user