Move watchdog and timings code to tick method, not tick loop itself.

This commit is contained in:
md_5 2014-01-22 19:23:59 +11:00
parent 29c6c774dd
commit 526b404545
7 changed files with 45 additions and 49 deletions

View file

@ -1,4 +1,4 @@
From 3d0e03d41e52731cea8e9ea8b6f1eca63a4b07ba Mon Sep 17 00:00:00 2001
From 5281adb89f494f0ae890612a90cb218e69ea7af0 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 6a01982..94fabdb 100644
index 6a01982..2519af6 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,19 +83,15 @@ index 6a01982..94fabdb 100644
import org.bukkit.craftbukkit.util.Waitable;
import org.bukkit.event.server.RemoteServerCommandEvent;
import org.bukkit.event.world.WorldSaveEvent;
@@ -458,8 +458,11 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
}
}
@@ -531,6 +531,7 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
protected void s() {}
+ SpigotTimings.serverTickTimer.startTiming();
Thread.sleep(1L);
this.N = true;
+ SpigotTimings.serverTickTimer.stopTiming();
+ org.spigotmc.CustomTimingsHandler.tick();
}
} else {
this.a((CrashReport) null);
@@ -583,6 +586,7 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
protected void t() throws ExceptionWorldConflict { // CraftBukkit - added throws
+ SpigotTimings.serverTickTimer.startTiming(); // Spigot
long i = System.nanoTime();
AxisAlignedBB.a().a();
@@ -583,6 +584,7 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
public void u() {
this.methodProfiler.a("levels");
@ -103,7 +99,7 @@ index 6a01982..94fabdb 100644
// CraftBukkit start
this.server.getScheduler().mainThreadHeartbeat(this.ticks);
@@ -591,7 +595,10 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
@@ -591,7 +593,10 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
processQueue.remove().run();
}
@ -114,7 +110,7 @@ index 6a01982..94fabdb 100644
// Send time updates to everyone, it will get the right time from the world the player is in.
if (this.ticks % 20 == 0) {
@@ -643,7 +650,9 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
@@ -643,7 +648,9 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
this.methodProfiler.b();
this.methodProfiler.a("tracker");
@ -124,7 +120,7 @@ index 6a01982..94fabdb 100644
this.methodProfiler.b();
this.methodProfiler.b();
// } // CraftBukkit
@@ -652,14 +661,20 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
@@ -652,16 +659,24 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
}
this.methodProfiler.c("connection");
@ -144,7 +140,11 @@ index 6a01982..94fabdb 100644
+ SpigotTimings.tickablesTimer.stopTiming(); // Spigot
this.methodProfiler.b();
+ SpigotTimings.serverTickTimer.stopTiming(); // Spigot
+ org.spigotmc.CustomTimingsHandler.tick(); // Spigot
}
public boolean getAllowNether() {
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
index 29335ea..d0ea17a 100644
--- a/src/main/java/net/minecraft/server/PlayerConnection.java

View file

@ -1,14 +1,14 @@
From bbc36e46a3a0dd6cff639c505a75b973de93c8ed Mon Sep 17 00:00:00 2001
From 6ab5656c1a121d61481d6fd9ed9b9fe4ed1e3397 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 94fabdb..7b6e83c 100644
index 2519af6..b082ad2 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -571,11 +571,11 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
@@ -569,11 +569,11 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
this.f[this.ticks % 100] = System.nanoTime() - i;
this.methodProfiler.b();
this.methodProfiler.a("snooper");

View file

@ -1,22 +1,14 @@
From 6e7e1bc596979eeb5c12bd2dbad8243610597206 Mon Sep 17 00:00:00 2001
From c746e94351236fc5cc57da30acf90fced3e22fa8 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 7b6e83c..839c2b1 100644
index b082ad2..1e83999 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -463,6 +463,7 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
this.N = true;
SpigotTimings.serverTickTimer.stopTiming();
org.spigotmc.CustomTimingsHandler.tick();
+ org.spigotmc.WatchdogThread.tick();
}
} else {
this.a((CrashReport) null);
@@ -488,6 +489,7 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
@@ -485,6 +485,7 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
this.a(crashreport);
} finally {
try {
@ -24,6 +16,14 @@ index 7b6e83c..839c2b1 100644
this.stop();
this.isStopped = true;
} catch (Throwable throwable1) {
@@ -675,6 +676,7 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
SpigotTimings.tickablesTimer.stopTiming(); // Spigot
this.methodProfiler.b();
+ org.spigotmc.WatchdogThread.tick(); // Spigot
SpigotTimings.serverTickTimer.stopTiming(); // Spigot
org.spigotmc.CustomTimingsHandler.tick(); // Spigot
}
diff --git a/src/main/java/org/spigotmc/RestartCommand.java b/src/main/java/org/spigotmc/RestartCommand.java
new file mode 100644
index 0000000..a8840c9

View file

@ -1,14 +1,14 @@
From 8d4743eb93c2bf94b875c691c253318259292b97 Mon Sep 17 00:00:00 2001
From 4122933db23b8aa16409e40caac5858750e577ce 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 b59a6d8..c520fe7 100644
index 94da13d..3f04557 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -470,6 +470,12 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
@@ -466,6 +466,12 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
}
} catch (Throwable throwable) {
h.error("Encountered an unexpected exception", throwable);

View file

@ -1,14 +1,14 @@
From 9f4f2410d074dccc2c47ee383af5db569080954e Mon Sep 17 00:00:00 2001
From 55c88983e542cb807461ce06e8d892090b9a3c61 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 c520fe7..eb7d918 100644
index 3f04557..7616d7b 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -643,7 +643,13 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
@@ -640,7 +640,13 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
try {
worldserver.doTick();
} catch (Throwable throwable) {
@ -22,7 +22,7 @@ index c520fe7..eb7d918 100644
worldserver.a(crashreport);
throw new ReportedException(crashreport);
}
@@ -651,7 +657,13 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
@@ -648,7 +654,13 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
try {
worldserver.tickEntities();
} catch (Throwable throwable1) {

View file

@ -1,4 +1,4 @@
From ebd2fb5ffe43e048d383ee3d2be17c8bac908656 Mon Sep 17 00:00:00 2001
From 9d257eb2927d480f108701500d0a300d1ecd617d 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 eb7d918..85e9e53 100644
index 7616d7b..588ce0a 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -571,7 +571,16 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
@@ -568,7 +568,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();

View file

@ -1,11 +1,11 @@
From 704af76ef5f2f961623aa145c110df9e651fe2cf Mon Sep 17 00:00:00 2001
From a6907b6a5936948036e02fdc6ce81f554bb787e9 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 85e9e53..1225411 100644
index 588ce0a..0ca1bb6 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -101,6 +101,11 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
@ -20,7 +20,7 @@ index 85e9e53..1225411 100644
public MinecraftServer(OptionSet options, Proxy proxy) { // CraftBukkit - signature file -> OptionSet
i = this;
@@ -429,42 +434,29 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
@@ -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);
@ -62,16 +62,12 @@ index 85e9e53..1225411 100644
+ catchupTime = Math.min(1000000000, Math.abs(wait));
}
-
- Thread.sleep(1L);
+ currentTPS = (currentTPS * 0.95) + (1E9 / (curTime - lastTick) * 0.05);
+ lastTick = curTime;
+ MinecraftServer.currentTick++;
SpigotTimings.serverTickTimer.startTiming();
- Thread.sleep(1L);
+ this.t();
this.N = true;
SpigotTimings.serverTickTimer.stopTiming();
org.spigotmc.CustomTimingsHandler.tick();
org.spigotmc.WatchdogThread.tick();
}
+ // Spigot end
} else {