Add server oversleep to timings (#2509)
Now everything except waiting for the next tick should be included in timings
This commit is contained in:
@@ -6,7 +6,7 @@ Subject: [PATCH] Timings v2
|
||||
|
||||
diff --git a/src/main/java/co/aikar/timings/MinecraftTimings.java b/src/main/java/co/aikar/timings/MinecraftTimings.java
|
||||
new file mode 100644
|
||||
index 0000000000..c2d2614181
|
||||
index 0000000000..c6818bc86a
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/co/aikar/timings/MinecraftTimings.java
|
||||
@@ -0,0 +0,0 @@
|
||||
@@ -24,6 +24,7 @@ index 0000000000..c2d2614181
|
||||
+// TODO: Re-implement missing timers
|
||||
+public final class MinecraftTimings {
|
||||
+
|
||||
+ public static final Timing serverOversleep = Timings.ofSafe("Server Oversleep");
|
||||
+ public static final Timing playerListTimer = Timings.ofSafe("Player List");
|
||||
+ public static final Timing commandFunctionsTimer = Timings.ofSafe("Command Functions");
|
||||
+ public static final Timing connectionTimer = Timings.ofSafe("Connection Handler");
|
||||
@@ -724,7 +725,7 @@ index 2b13f4c9f9..47379046dc 100644
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
index cec3794cd4..bc0e483a2a 100644
|
||||
index cec3794cd4..c76f262db9 100644
|
||||
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
@@ -0,0 +0,0 @@ import org.bukkit.craftbukkit.CraftServer;
|
||||
@@ -736,6 +737,17 @@ index cec3794cd4..bc0e483a2a 100644
|
||||
import org.spigotmc.SlackActivityAccountant; // Spigot
|
||||
|
||||
public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTask> implements IMojangStatistics, ICommandListener, AutoCloseable, Runnable {
|
||||
@@ -0,0 +0,0 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
|
||||
});
|
||||
});
|
||||
private long nextTick = SystemUtils.getMonotonicMillis();
|
||||
- private long ab;
|
||||
- private boolean ac;
|
||||
+ private long ab; final long getTickOversleepMaxTime() { return this.ab; } // Paper - OBFHELPER
|
||||
+ private boolean ac; final boolean hasExecutedTask() { return this.ac; } // Paper - OBFHELPER
|
||||
private final IReloadableResourceManager ae;
|
||||
private final ResourcePackRepository<ResourcePackLoader> resourcePackRepository;
|
||||
@Nullable
|
||||
@@ -0,0 +0,0 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
|
||||
}
|
||||
// CraftBukkit end
|
||||
@@ -744,6 +756,23 @@ index cec3794cd4..bc0e483a2a 100644
|
||||
// CraftBukkit start
|
||||
if (this.server != null) {
|
||||
this.server.disablePlugins();
|
||||
@@ -0,0 +0,0 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
|
||||
return this.forceTicks || this.isEntered() || SystemUtils.getMonotonicMillis() < (this.ac ? this.ab : this.nextTick);
|
||||
}
|
||||
|
||||
+ // Paper start
|
||||
+ private boolean canOversleep() {
|
||||
+ return this.hasExecutedTask() && SystemUtils.getMonotonicMillis() < this.getTickOversleepMaxTime();
|
||||
+ }
|
||||
+
|
||||
+ private boolean canSleepForTickNoOversleep() {
|
||||
+ return this.forceTicks || this.isEntered() || SystemUtils.getMonotonicMillis() < this.nextTick;
|
||||
+ }
|
||||
+ // Paper end
|
||||
+
|
||||
private void executeModerately() {
|
||||
this.executeAll();
|
||||
java.util.concurrent.locks.LockSupport.parkNanos("executing tasks", 1000L);
|
||||
@@ -0,0 +0,0 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
|
||||
// CraftBukkit end
|
||||
|
||||
@@ -751,14 +780,24 @@ index cec3794cd4..bc0e483a2a 100644
|
||||
- this.executeAll();
|
||||
+ //this.executeAll(); // Paper - move this into the tick method for timings
|
||||
this.awaitTasks(() -> {
|
||||
return !this.canSleepForTick();
|
||||
- return !this.canSleepForTick();
|
||||
+ return !this.canSleepForTickNoOversleep(); // Paper - move oversleep into full server tick
|
||||
});
|
||||
}
|
||||
|
||||
@@ -0,0 +0,0 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
|
||||
protected void exit() {}
|
||||
|
||||
protected void a(BooleanSupplier booleansupplier) {
|
||||
- SpigotTimings.serverTickTimer.startTiming(); // Spigot
|
||||
+ co.aikar.timings.TimingsManager.FULL_SERVER_TICK.startTiming(); // Paper
|
||||
+ // Paper start - move oversleep into full server tick
|
||||
+ MinecraftTimings.serverOversleep.startTiming();
|
||||
+ this.awaitTasks(() -> {
|
||||
+ return !this.canOversleep();
|
||||
+ });
|
||||
+ MinecraftTimings.serverOversleep.stopTiming();
|
||||
+ // Paper end
|
||||
this.slackActivityAccountant.tickStarted(); // Spigot
|
||||
long i = SystemUtils.getMonotonicNanos();
|
||||
|
||||
@@ -1166,7 +1205,7 @@ index 1d5e4c5127..60c222b12b 100644
|
||||
CrashReport crashreport = CrashReport.a(throwable, "Ticking entity");
|
||||
CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Entity being ticked");
|
||||
diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
|
||||
index 825e72e53a..a28c97a889 100644
|
||||
index 08f824228b..8a7e666473 100644
|
||||
--- a/src/main/java/net/minecraft/server/WorldServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/WorldServer.java
|
||||
@@ -0,0 +0,0 @@
|
||||
|
||||
Reference in New Issue
Block a user