2017-11-07 17:30:57 +11:00
From d99887158d92d36299f5c9ce35008befef50374c Mon Sep 17 00:00:00 2001
2017-10-28 16:17:34 +11:00
From: md_5 <git@md-5.net>
Date: Sat, 28 Oct 2017 16:17:07 +1100
2014-07-07 18:59:02 -04:00
Subject: [PATCH] Spigot Timings
2013-02-26 12:21:40 -05:00
2014-07-07 18:59:02 -04:00
Overhauls the Timings System adding performance tracking all around the Minecraft Server
2013-02-26 12:21:40 -05:00
2014-07-07 18:59:02 -04:00
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
2017-10-28 16:17:34 +11:00
index 1c1499a9..779f5714 100644
2014-07-07 18:59:02 -04:00
--- a/src/main/java/net/minecraft/server/Chunk.java
+++ b/src/main/java/net/minecraft/server/Chunk.java
2016-06-23 10:37:05 +10:00
@@ -842,6 +842,7 @@ public class Chunk {
2014-07-07 18:59:02 -04:00
2016-06-23 10:37:05 +10:00
// CraftBukkit start
public void loadNearby(IChunkProvider ichunkprovider, ChunkGenerator chunkgenerator, boolean newChunk) {
2014-07-07 18:59:02 -04:00
+ world.timings.syncChunkLoadPostTimer.startTiming(); // Spigot
2016-06-23 10:37:05 +10:00
Server server = world.getServer();
if (server != null) {
/*
@@ -892,6 +893,7 @@ public class Chunk {
2016-03-05 16:38:55 +11:00
chunk4.a(chunkgenerator);
}
2014-07-07 18:59:02 -04:00
}
+ world.timings.syncChunkLoadPostTimer.stopTiming(); // Spigot
2016-03-05 16:38:55 +11:00
2014-07-07 18:59:02 -04:00
}
2013-02-26 12:21:40 -05:00
diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java
2017-10-28 16:17:34 +11:00
index a9c9d714..d2546b5d 100644
2013-02-26 12:21:40 -05:00
--- a/src/main/java/net/minecraft/server/ChunkProviderServer.java
+++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java
2016-11-17 12:41:12 +11:00
@@ -153,6 +153,7 @@ public class ChunkProviderServer implements IChunkProvider {
2014-11-26 08:27:08 +11:00
// CraftBukkit end
2013-02-26 12:21:40 -05:00
if (chunk == null) {
2014-07-07 18:59:02 -04:00
+ world.timings.syncChunkLoadTimer.startTiming(); // Spigot
2016-03-01 08:33:06 +11:00
long k = ChunkCoordIntPair.a(i, j);
2016-05-10 21:48:25 +10:00
try {
2016-11-17 12:41:12 +11:00
@@ -170,6 +171,7 @@ public class ChunkProviderServer implements IChunkProvider {
2016-07-15 20:11:38 +10:00
this.chunks.put(k, chunk);
2016-06-23 10:37:05 +10:00
chunk.addEntities();
chunk.loadNearby(this, this.chunkGenerator, true); // CraftBukkit
2014-07-07 18:59:02 -04:00
+ world.timings.syncChunkLoadTimer.stopTiming(); // Spigot
2013-02-26 12:21:40 -05:00
}
2014-02-12 13:48:26 +00:00
return chunk;
2014-07-07 18:59:02 -04:00
diff --git a/src/main/java/net/minecraft/server/ChunkRegionLoader.java b/src/main/java/net/minecraft/server/ChunkRegionLoader.java
2017-10-28 16:17:34 +11:00
index 6823819b..e0e4c9a0 100644
2014-07-07 18:59:02 -04:00
--- a/src/main/java/net/minecraft/server/ChunkRegionLoader.java
+++ b/src/main/java/net/minecraft/server/ChunkRegionLoader.java
2017-08-11 19:46:40 +01:00
@@ -34,7 +34,9 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver {
2014-07-07 18:59:02 -04:00
// CraftBukkit start - Add async variant, provide compatibility
2016-05-10 21:48:25 +10:00
@Nullable
2015-02-28 11:36:22 +00:00
public Chunk a(World world, int i, int j) throws IOException {
2014-07-07 18:59:02 -04:00
+ world.timings.syncChunkLoadDataTimer.startTiming(); // Spigot
2014-11-26 08:27:08 +11:00
Object[] data = loadChunk(world, i, j);
2014-07-07 18:59:02 -04:00
+ world.timings.syncChunkLoadDataTimer.stopTiming(); // Spigot
if (data != null) {
Chunk chunk = (Chunk) data[0];
NBTTagCompound nbttagcompound = (NBTTagCompound) data[1];
2017-08-11 19:46:40 +01:00
@@ -395,7 +397,7 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver {
2015-03-22 19:50:13 +00:00
public void loadEntities(Chunk chunk, NBTTagCompound nbttagcompound, World world) {
2014-07-07 18:59:02 -04:00
// CraftBukkit end
2015-02-28 11:36:22 +00:00
-
2014-07-07 18:59:02 -04:00
+ world.timings.syncChunkLoadEntitiesTimer.startTiming(); // Spigot
NBTTagList nbttaglist1 = nbttagcompound.getList("Entities", 10);
2016-11-17 12:41:12 +11:00
for (int l = 0; l < nbttaglist1.size(); ++l) {
2017-08-11 19:46:40 +01:00
@@ -404,7 +406,8 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver {
2016-11-17 12:41:12 +11:00
a(nbttagcompound2, world, chunk);
chunk.g(true);
2014-07-07 18:59:02 -04:00
}
-
+ world.timings.syncChunkLoadEntitiesTimer.stopTiming(); // Spigot
+ world.timings.syncChunkLoadTileEntitiesTimer.startTiming(); // Spigot
NBTTagList nbttaglist2 = nbttagcompound.getList("TileEntities", 10);
2016-11-17 12:41:12 +11:00
for (int i1 = 0; i1 < nbttaglist2.size(); ++i1) {
2017-08-11 19:46:40 +01:00
@@ -415,6 +418,8 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver {
2016-11-17 12:41:12 +11:00
chunk.a(tileentity);
2014-07-07 18:59:02 -04:00
}
}
+ world.timings.syncChunkLoadTileEntitiesTimer.stopTiming(); // Spigot
+ world.timings.syncChunkLoadTileTicksTimer.startTiming(); // Spigot
if (nbttagcompound.hasKeyOfType("TileTicks", 9)) {
NBTTagList nbttaglist3 = nbttagcompound.getList("TileTicks", 10);
2017-08-11 19:46:40 +01:00
@@ -432,6 +437,7 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver {
2016-11-17 12:41:12 +11:00
world.b(new BlockPosition(nbttagcompound4.getInt("x"), nbttagcompound4.getInt("y"), nbttagcompound4.getInt("z")), block, nbttagcompound4.getInt("t"), nbttagcompound4.getInt("p"));
2014-07-07 18:59:02 -04:00
}
}
+ world.timings.syncChunkLoadTileTicksTimer.stopTiming(); // Spigot
2015-02-28 11:36:22 +00:00
// return chunk; // CraftBukkit
2014-07-07 18:59:02 -04:00
}
diff --git a/src/main/java/net/minecraft/server/DedicatedServer.java b/src/main/java/net/minecraft/server/DedicatedServer.java
2017-10-28 16:17:34 +11:00
index 330c5fe3..f1a389b6 100644
2014-07-07 18:59:02 -04:00
--- a/src/main/java/net/minecraft/server/DedicatedServer.java
+++ b/src/main/java/net/minecraft/server/DedicatedServer.java
2017-05-14 12:00:00 +10:00
@@ -24,6 +24,7 @@ import java.io.PrintStream;
2014-07-07 18:59:02 -04:00
import org.apache.logging.log4j.Level;
import org.bukkit.craftbukkit.LoggerOutputStream;
+import org.bukkit.craftbukkit.SpigotTimings; // Spigot
import org.bukkit.event.server.ServerCommandEvent;
2015-02-28 11:36:22 +00:00
import org.bukkit.craftbukkit.util.Waitable;
import org.bukkit.event.server.RemoteServerCommandEvent;
2017-08-03 23:00:00 +10:00
@@ -400,6 +401,7 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer
2014-07-07 18:59:02 -04:00
}
2017-05-14 12:00:00 +10:00
public void aP() {
2014-07-07 18:59:02 -04:00
+ SpigotTimings.serverCommandTimer.startTiming(); // Spigot
2016-03-01 08:33:06 +11:00
while (!this.serverCommandQueue.isEmpty()) {
ServerCommand servercommand = (ServerCommand) this.serverCommandQueue.remove(0);
2014-07-07 18:59:02 -04:00
2017-08-03 23:00:00 +10:00
@@ -414,6 +416,7 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer
2014-07-07 18:59:02 -04:00
// CraftBukkit end
}
2014-11-26 08:27:08 +11:00
2014-07-07 18:59:02 -04:00
+ SpigotTimings.serverCommandTimer.stopTiming(); // Spigot
}
2016-03-01 08:33:06 +11:00
public boolean aa() {
2013-02-26 12:21:40 -05:00
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
2017-11-07 17:30:57 +11:00
index 0c20b450..23a9764f 100644
2013-02-26 12:21:40 -05:00
--- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java
2016-12-21 07:00:00 +11:00
@@ -25,6 +25,7 @@ import org.bukkit.block.BlockFace;
2016-03-01 08:33:06 +11:00
import org.bukkit.entity.Hanging;
2013-02-26 12:21:40 -05:00
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Vehicle;
2013-06-02 11:29:44 +10:00
+import org.spigotmc.CustomTimingsHandler; // Spigot
2013-02-26 12:21:40 -05:00
import org.bukkit.event.entity.EntityCombustByEntityEvent;
2014-04-18 17:08:19 +00:00
import org.bukkit.event.hanging.HangingBreakByEntityEvent;
2016-03-01 08:33:06 +11:00
import org.bukkit.event.vehicle.VehicleBlockCollisionEvent;
2017-11-07 17:30:57 +11:00
@@ -146,6 +147,7 @@ public abstract class Entity implements ICommandListener {
public boolean valid;
public org.bukkit.projectiles.ProjectileSource projectileSource; // For projectiles only
public boolean forceExplosionKnockback; // SPIGOT-949
2013-02-26 12:21:40 -05:00
+ public CustomTimingsHandler tickTimer = org.bukkit.craftbukkit.SpigotTimings.getEntityTimings(this); // Spigot
2016-03-01 08:33:06 +11:00
2017-11-07 17:30:57 +11:00
public float getBukkitYaw() {
return this.yaw;
@@ -517,6 +519,7 @@ public abstract class Entity implements ICommandListener {
2014-11-26 08:27:08 +11:00
}
2016-11-17 12:41:12 +11:00
public void move(EnumMoveType enummovetype, double d0, double d1, double d2) {
2013-02-26 12:21:40 -05:00
+ org.bukkit.craftbukkit.SpigotTimings.entityMoveTimer.startTiming(); // Spigot
2015-02-28 11:36:22 +00:00
if (this.noclip) {
2016-11-17 12:41:12 +11:00
this.a(this.getBoundingBox().d(d0, d1, d2));
2014-11-26 08:27:08 +11:00
this.recalcPosition();
2017-11-07 17:30:57 +11:00
@@ -910,6 +913,7 @@ public abstract class Entity implements ICommandListener {
2013-02-26 12:21:40 -05:00
this.world.methodProfiler.b();
}
+ org.bukkit.craftbukkit.SpigotTimings.entityMoveTimer.stopTiming(); // Spigot
}
2016-03-01 08:33:06 +11:00
public void recalcPosition() {
2014-07-07 18:59:02 -04:00
diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java
2017-11-07 17:30:57 +11:00
index cc037988..3912b40d 100644
2014-07-07 18:59:02 -04:00
--- a/src/main/java/net/minecraft/server/EntityLiving.java
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
2016-11-17 12:41:12 +11:00
@@ -31,6 +31,8 @@ import org.bukkit.event.entity.EntityTeleportEvent;
2016-03-01 08:33:06 +11:00
import org.bukkit.event.player.PlayerItemConsumeEvent;
2014-07-07 18:59:02 -04:00
// CraftBukkit end
+import org.bukkit.craftbukkit.SpigotTimings; // Spigot
+
public abstract class EntityLiving extends Entity {
2016-11-17 12:41:12 +11:00
private static final Logger a = LogManager.getLogger();
2017-11-07 17:30:57 +11:00
@@ -1858,6 +1860,7 @@ public abstract class EntityLiving extends Entity {
2014-07-07 18:59:02 -04:00
}
2017-05-14 12:00:00 +10:00
public void B_() {
2014-07-07 18:59:02 -04:00
+ SpigotTimings.timerEntityBaseTick.startTiming(); // Spigot
2017-05-14 12:00:00 +10:00
super.B_();
2017-06-08 18:00:00 +10:00
this.cI();
2015-02-28 11:36:22 +00:00
if (!this.world.isClientSide) {
2017-11-07 17:30:57 +11:00
@@ -1930,7 +1933,9 @@ public abstract class EntityLiving extends Entity {
2014-07-07 18:59:02 -04:00
}
}
+ SpigotTimings.timerEntityBaseTick.stopTiming(); // Spigot
2016-03-01 08:33:06 +11:00
this.n();
2014-07-07 18:59:02 -04:00
+ SpigotTimings.timerEntityTickRest.startTiming(); // Spigot
double d0 = this.locX - this.lastX;
double d1 = this.locZ - this.lastZ;
float f = (float) (d0 * d0 + d1 * d1);
2017-11-07 17:30:57 +11:00
@@ -2007,6 +2012,7 @@ public abstract class EntityLiving extends Entity {
2017-05-14 12:00:00 +10:00
this.bq = 0;
2016-03-01 08:33:06 +11:00
}
2014-07-07 18:59:02 -04:00
+ SpigotTimings.timerEntityTickRest.stopTiming(); // Spigot
}
2017-05-14 12:00:00 +10:00
protected float g(float f, float f1) {
2017-11-07 17:30:57 +11:00
@@ -2071,6 +2077,7 @@ public abstract class EntityLiving extends Entity {
2014-07-07 18:59:02 -04:00
}
this.world.methodProfiler.a("ai");
+ SpigotTimings.timerEntityAI.startTiming(); // Spigot
2016-11-17 12:41:12 +11:00
if (this.isFrozen()) {
this.bd = false;
this.be = 0.0F;
2017-11-07 17:30:57 +11:00
@@ -2081,6 +2088,7 @@ public abstract class EntityLiving extends Entity {
2014-11-26 08:27:08 +11:00
this.doTick();
this.world.methodProfiler.b();
2014-07-07 18:59:02 -04:00
}
+ SpigotTimings.timerEntityAI.stopTiming(); // Spigot
this.world.methodProfiler.b();
this.world.methodProfiler.a("jump");
2017-11-07 17:30:57 +11:00
@@ -2103,10 +2111,14 @@ public abstract class EntityLiving extends Entity {
2017-05-14 12:00:00 +10:00
this.bg *= 0.98F;
this.bh *= 0.9F;
2016-03-01 08:33:06 +11:00
this.r();
2014-07-07 18:59:02 -04:00
+ SpigotTimings.timerEntityAIMove.startTiming(); // Spigot
2017-05-14 12:00:00 +10:00
this.a(this.be, this.bf, this.bg);
2014-07-07 18:59:02 -04:00
+ SpigotTimings.timerEntityAIMove.stopTiming(); // Spigot
this.world.methodProfiler.b();
this.world.methodProfiler.a("push");
2016-03-01 08:33:06 +11:00
+ SpigotTimings.timerEntityAICollision.startTiming(); // Spigot
2017-06-08 18:00:00 +10:00
this.cB();
2016-03-01 08:33:06 +11:00
+ SpigotTimings.timerEntityAICollision.stopTiming(); // Spigot
2014-07-07 18:59:02 -04:00
this.world.methodProfiler.b();
2016-03-01 08:33:06 +11:00
}
2013-02-26 12:21:40 -05:00
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
2017-10-28 16:17:34 +11:00
index 48495b64..26fe01ba 100644
2013-02-26 12:21:40 -05:00
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
2017-08-03 23:00:00 +10:00
@@ -48,6 +48,7 @@ import org.bukkit.Bukkit;
2016-05-10 21:48:25 +10:00
import org.bukkit.craftbukkit.CraftServer;
2016-07-15 20:11:38 +10:00
import org.bukkit.craftbukkit.Main;
2015-07-12 19:59:20 +10:00
// CraftBukkit end
2016-03-01 08:33:06 +11:00
+import org.bukkit.craftbukkit.SpigotTimings; // Spigot
2016-07-15 20:11:38 +10:00
2017-05-14 12:00:00 +10:00
public abstract class MinecraftServer implements ICommandListener, Runnable, IAsyncTaskHandler, IMojangStatistics {
2014-01-22 19:23:59 +11:00
2017-08-03 23:00:00 +10:00
@@ -638,6 +639,7 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IAs
2016-06-09 11:43:56 +10:00
public void B() {}
2016-03-01 08:33:06 +11:00
protected void C() throws ExceptionWorldConflict { // CraftBukkit - added throws
2014-01-22 19:23:59 +11:00
+ SpigotTimings.serverTickTimer.startTiming(); // Spigot
long i = System.nanoTime();
2014-03-23 00:06:43 +00:00
++this.ticks;
2017-08-03 23:00:00 +10:00
@@ -664,10 +666,12 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IAs
2014-07-07 18:59:02 -04:00
}
2014-11-26 08:27:08 +11:00
if (autosavePeriod > 0 && this.ticks % autosavePeriod == 0) { // CraftBukkit
2014-07-07 18:59:02 -04:00
+ SpigotTimings.worldSaveTimer.startTiming(); // Spigot
this.methodProfiler.a("save");
2014-11-26 08:27:08 +11:00
this.v.savePlayers();
2014-07-07 18:59:02 -04:00
this.saveChunks(true);
this.methodProfiler.b();
+ SpigotTimings.worldSaveTimer.stopTiming(); // Spigot
}
this.methodProfiler.a("tallying");
2017-08-03 23:00:00 +10:00
@@ -684,10 +688,14 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IAs
2014-08-05 17:29:09 +01:00
this.methodProfiler.b();
this.methodProfiler.b();
+ SpigotTimings.serverTickTimer.stopTiming(); // Spigot
+ org.spigotmc.CustomTimingsHandler.tick(); // Spigot
}
2016-03-01 08:33:06 +11:00
public void D() {
2013-02-26 12:21:40 -05:00
+ SpigotTimings.schedulerTimer.startTiming(); // Spigot
2016-06-30 15:22:27 +10:00
this.server.getScheduler().mainThreadHeartbeat(this.ticks); // CraftBukkit
2014-07-07 18:59:02 -04:00
+ SpigotTimings.schedulerTimer.stopTiming(); // Spigot
2016-06-30 15:22:27 +10:00
this.methodProfiler.a("jobs");
Queue queue = this.j;
2013-02-26 12:21:40 -05:00
2017-08-03 23:00:00 +10:00
@@ -701,12 +709,17 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IAs
2016-06-30 15:22:27 +10:00
// CraftBukkit start
2014-07-07 18:59:02 -04:00
// Run tasks that are waiting on processing
+ SpigotTimings.processQueueTimer.startTiming(); // Spigot
while (!processQueue.isEmpty()) {
2013-02-26 12:21:40 -05:00
processQueue.remove().run();
}
2014-07-07 18:59:02 -04:00
+ SpigotTimings.processQueueTimer.stopTiming(); // Spigot
2013-02-26 12:21:40 -05:00
+ SpigotTimings.chunkIOTickTimer.startTiming(); // Spigot
org.bukkit.craftbukkit.chunkio.ChunkIOExecutor.tick();
+ SpigotTimings.chunkIOTickTimer.stopTiming(); // Spigot
2014-07-07 18:59:02 -04:00
+ SpigotTimings.timeUpdateTimer.startTiming(); // Spigot
2013-03-25 18:57:00 +11:00
// Send time updates to everyone, it will get the right time from the world the player is in.
2013-02-26 12:21:40 -05:00
if (this.ticks % 20 == 0) {
2014-07-07 18:59:02 -04:00
for (int i = 0; i < this.getPlayerList().players.size(); ++i) {
2017-08-03 23:00:00 +10:00
@@ -714,6 +727,7 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IAs
2014-07-07 18:59:02 -04:00
entityplayer.playerConnection.sendPacket(new PacketPlayOutUpdateTime(entityplayer.world.getTime(), entityplayer.getPlayerTime(), entityplayer.world.getGameRules().getBoolean("doDaylightCycle"))); // Add support for per player time
}
}
+ SpigotTimings.timeUpdateTimer.stopTiming(); // Spigot
int i;
2017-08-03 23:00:00 +10:00
@@ -739,7 +753,9 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IAs
2014-07-07 18:59:02 -04:00
CrashReport crashreport;
try {
+ worldserver.timings.doTick.startTiming(); // Spigot
worldserver.doTick();
+ worldserver.timings.doTick.stopTiming(); // Spigot
2015-02-28 11:36:22 +00:00
} catch (Throwable throwable) {
crashreport = CrashReport.a(throwable, "Exception ticking world");
2014-07-07 18:59:02 -04:00
worldserver.a(crashreport);
2017-08-03 23:00:00 +10:00
@@ -747,7 +763,9 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IAs
2014-07-07 18:59:02 -04:00
}
try {
+ worldserver.timings.tickEntities.startTiming(); // Spigot
worldserver.tickEntities();
+ worldserver.timings.tickEntities.stopTiming(); // Spigot
2015-02-28 11:36:22 +00:00
} catch (Throwable throwable1) {
crashreport = CrashReport.a(throwable1, "Exception ticking world entities");
2014-07-07 18:59:02 -04:00
worldserver.a(crashreport);
2017-08-03 23:00:00 +10:00
@@ -756,7 +774,9 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IAs
2013-02-26 12:21:40 -05:00
this.methodProfiler.b();
this.methodProfiler.a("tracker");
+ worldserver.timings.tracker.startTiming(); // Spigot
worldserver.getTracker().updatePlayers();
+ worldserver.timings.tracker.stopTiming(); // Spigot
this.methodProfiler.b();
this.methodProfiler.b();
// } // CraftBukkit
2017-08-03 23:00:00 +10:00
@@ -765,16 +785,24 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IAs
2013-02-26 12:21:40 -05:00
}
this.methodProfiler.c("connection");
+ SpigotTimings.connectionTimer.startTiming(); // Spigot
2016-11-17 12:41:12 +11:00
this.an().c();
2013-02-26 12:21:40 -05:00
+ SpigotTimings.connectionTimer.stopTiming(); // Spigot
this.methodProfiler.c("players");
+ SpigotTimings.playerListTimer.startTiming(); // Spigot
2014-11-26 08:27:08 +11:00
this.v.tick();
2013-02-26 12:21:40 -05:00
+ SpigotTimings.playerListTimer.stopTiming(); // Spigot
2017-05-14 12:00:00 +10:00
this.methodProfiler.c("commandFunctions");
+ SpigotTimings.commandFunctionsTimer.startTiming(); // Spigot
this.aL().e();
+ SpigotTimings.commandFunctionsTimer.stopTiming();// Spigot
2013-02-26 12:21:40 -05:00
this.methodProfiler.c("tickables");
+ SpigotTimings.tickablesTimer.startTiming(); // Spigot
2016-03-01 08:33:06 +11:00
for (i = 0; i < this.o.size(); ++i) {
2017-05-14 12:00:00 +10:00
((ITickable) this.o.get(i)).e();
2013-02-26 12:21:40 -05:00
}
+ SpigotTimings.tickablesTimer.stopTiming(); // Spigot
this.methodProfiler.b();
}
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
2017-10-28 16:17:34 +11:00
index eda6dff9..360bca58 100644
2013-02-26 12:21:40 -05:00
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
2017-09-18 20:00:00 +10:00
@@ -1317,6 +1317,7 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
2013-02-26 12:21:40 -05:00
// CraftBukkit end
2017-05-14 12:00:00 +10:00
private void handleCommand(String s) {
2013-02-26 12:21:40 -05:00
+ org.bukkit.craftbukkit.SpigotTimings.playerCommandTimer.startTiming(); // Spigot
2014-11-26 08:27:08 +11:00
// CraftBukkit start - whole method
2016-03-01 08:33:06 +11:00
this.LOGGER.info(this.player.getName() + " issued server command: " + s);
2013-02-26 12:21:40 -05:00
2017-09-18 20:00:00 +10:00
@@ -1326,18 +1327,22 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
2013-02-26 12:21:40 -05:00
this.server.getPluginManager().callEvent(event);
if (event.isCancelled()) {
+ org.bukkit.craftbukkit.SpigotTimings.playerCommandTimer.stopTiming(); // Spigot
return;
}
try {
if (this.server.dispatchCommand(event.getPlayer(), event.getMessage().substring(1))) {
+ org.bukkit.craftbukkit.SpigotTimings.playerCommandTimer.stopTiming(); // Spigot
return;
}
} catch (org.bukkit.command.CommandException ex) {
player.sendMessage(org.bukkit.ChatColor.RED + "An internal error occurred while attempting to perform this command");
2013-03-25 18:57:00 +11:00
java.util.logging.Logger.getLogger(PlayerConnection.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
2013-02-26 12:21:40 -05:00
+ org.bukkit.craftbukkit.SpigotTimings.playerCommandTimer.stopTiming(); // Spigot
return;
}
+ org.bukkit.craftbukkit.SpigotTimings.playerCommandTimer.stopTiming(); // Spigot
2017-05-19 21:00:22 +10:00
// this.minecraftServer.getCommandHandler().a(this.player, s);
2013-02-26 12:21:40 -05:00
// CraftBukkit end
2013-12-01 14:40:53 +11:00
}
2013-02-26 12:21:40 -05:00
diff --git a/src/main/java/net/minecraft/server/TileEntity.java b/src/main/java/net/minecraft/server/TileEntity.java
2017-10-28 16:17:34 +11:00
index 296a0295..e29b593a 100644
2013-02-26 12:21:40 -05:00
--- a/src/main/java/net/minecraft/server/TileEntity.java
+++ b/src/main/java/net/minecraft/server/TileEntity.java
2016-11-17 12:41:12 +11:00
@@ -4,10 +4,12 @@ import javax.annotation.Nullable;
2013-12-01 14:40:53 +11:00
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
2013-02-26 12:21:40 -05:00
2013-06-02 11:29:44 +10:00
+import org.spigotmc.CustomTimingsHandler; // Spigot
2013-02-26 12:21:40 -05:00
import org.bukkit.inventory.InventoryHolder; // CraftBukkit
2014-11-26 08:27:08 +11:00
public abstract class TileEntity {
2013-02-26 12:21:40 -05:00
+ public CustomTimingsHandler tickTimer = org.bukkit.craftbukkit.SpigotTimings.getTileEntityTimings(this); // Spigot
2013-12-01 14:40:53 +11:00
private static final Logger a = LogManager.getLogger();
2016-11-17 12:41:12 +11:00
private static final RegistryMaterials<MinecraftKey, Class<? extends TileEntity>> f = new RegistryMaterials();
protected World world;
2013-02-26 12:21:40 -05:00
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
2017-10-28 16:17:34 +11:00
index b043266b..8a618dfc 100644
2013-02-26 12:21:40 -05:00
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
2017-08-03 23:00:00 +10:00
@@ -19,6 +19,7 @@ import com.google.common.collect.Maps;
2016-03-01 08:33:06 +11:00
import java.util.Map;
import org.bukkit.Bukkit;
2014-04-24 16:27:12 +10:00
import org.bukkit.block.BlockState;
2013-02-26 12:21:40 -05:00
+import org.bukkit.craftbukkit.SpigotTimings; // Spigot
import org.bukkit.craftbukkit.CraftServer;
2014-02-12 13:48:26 +00:00
import org.bukkit.craftbukkit.CraftWorld;
2016-03-01 08:33:06 +11:00
import org.bukkit.craftbukkit.event.CraftEventFactory;
2017-08-03 23:00:00 +10:00
@@ -103,6 +104,8 @@ public abstract class World implements IBlockAccess {
2016-03-01 08:33:06 +11:00
private int tickPosition;
2013-06-20 18:52:23 +10:00
public final org.spigotmc.SpigotWorldConfig spigotConfig; // Spigot
2013-02-26 12:21:40 -05:00
+ public final SpigotTimings.WorldTimingsHandler timings; // Spigot
+
public CraftWorld getWorld() {
return this.world;
}
2017-08-03 23:00:00 +10:00
@@ -164,6 +167,7 @@ public abstract class World implements IBlockAccess {
2016-03-06 14:36:33 +11:00
});
2016-03-01 11:23:45 +11:00
this.getServer().addWorld(this.world);
// CraftBukkit end
2016-03-01 08:33:06 +11:00
+ timings = new SpigotTimings.WorldTimingsHandler(this); // Spigot - code below can generate new world and access timings
2014-11-26 08:27:08 +11:00
}
public World b() {
2017-08-03 23:00:00 +10:00
@@ -1348,6 +1352,7 @@ public abstract class World implements IBlockAccess {
2016-03-01 08:33:06 +11:00
CrashReportSystemDetails crashreportsystemdetails1;
CrashReport crashreport1;
2013-02-26 12:21:40 -05:00
+ timings.entityTick.startTiming(); // Spigot
2014-02-12 13:48:26 +00:00
// CraftBukkit start - Use field for loop variable
for (this.tickPosition = 0; this.tickPosition < this.entityList.size(); ++this.tickPosition) {
entity = (Entity) this.entityList.get(this.tickPosition);
2017-08-03 23:00:00 +10:00
@@ -1365,7 +1370,9 @@ public abstract class World implements IBlockAccess {
2013-02-26 12:21:40 -05:00
this.methodProfiler.a("tick");
2016-03-01 08:33:06 +11:00
if (!entity.dead && !(entity instanceof EntityPlayer)) {
2013-02-26 12:21:40 -05:00
try {
+ SpigotTimings.tickEntityTimer.startTiming(); // Spigot
2016-12-21 07:00:00 +11:00
this.h(entity);
2013-02-26 12:21:40 -05:00
+ SpigotTimings.tickEntityTimer.stopTiming(); // Spigot
} catch (Throwable throwable1) {
2016-03-01 08:33:06 +11:00
crashreport1 = CrashReport.a(throwable1, "Ticking entity");
crashreportsystemdetails1 = crashreport1.a("Entity being ticked");
2017-09-18 20:00:00 +10:00
@@ -1391,7 +1398,9 @@ public abstract class World implements IBlockAccess {
2013-02-26 12:21:40 -05:00
this.methodProfiler.b();
}
+ timings.entityTick.stopTiming(); // Spigot
2013-12-01 14:40:53 +11:00
this.methodProfiler.c("blockEntities");
2016-06-15 13:24:40 +10:00
+ timings.tileEntityTick.startTiming(); // Spigot
if (!this.tileEntityListUnload.isEmpty()) {
this.tileEntityListTick.removeAll(this.tileEntityListUnload);
2017-09-18 20:00:00 +10:00
this.tileEntityList.removeAll(this.tileEntityListUnload);
@@ -1412,6 +1421,7 @@ public abstract class World implements IBlockAccess {
2017-08-03 23:00:00 +10:00
this.methodProfiler.a(() -> {
return String.valueOf(TileEntity.a(tileentity.getClass()));
});
2014-11-26 08:27:08 +11:00
+ tileentity.tickTimer.startTiming(); // Spigot
2017-05-14 12:00:00 +10:00
((ITickable) tileentity).e();
2016-03-01 08:33:06 +11:00
this.methodProfiler.b();
2014-11-26 08:27:08 +11:00
} catch (Throwable throwable2) {
2017-09-18 20:00:00 +10:00
@@ -1420,6 +1430,11 @@ public abstract class World implements IBlockAccess {
2014-11-26 08:27:08 +11:00
tileentity.a(crashreportsystemdetails1);
throw new ReportedException(crashreport1);
}
+ // Spigot start
+ finally {
+ tileentity.tickTimer.stopTiming();
+ }
+ // Spigot end
}
}
2013-02-26 12:21:40 -05:00
2017-09-18 20:00:00 +10:00
@@ -1432,6 +1447,8 @@ public abstract class World implements IBlockAccess {
2013-02-26 12:21:40 -05:00
}
}
+ timings.tileEntityTick.stopTiming(); // Spigot
+ timings.tileEntityPending.startTiming(); // Spigot
2017-05-14 12:00:00 +10:00
this.O = false;
2017-09-18 20:00:00 +10:00
this.methodProfiler.c("pendingBlockEntities");
if (!this.b.isEmpty()) {
@@ -1464,6 +1481,7 @@ public abstract class World implements IBlockAccess {
2015-02-28 11:36:22 +00:00
this.b.clear();
2013-02-26 12:21:40 -05:00
}
+ timings.tileEntityPending.stopTiming(); // Spigot
this.methodProfiler.b();
this.methodProfiler.b();
}
2017-09-18 20:00:00 +10:00
@@ -1518,6 +1536,7 @@ public abstract class World implements IBlockAccess {
2017-05-20 11:32:58 +10:00
}
// CraftBukkit end
2017-05-19 21:00:22 +10:00
+ entity.tickTimer.startTiming(); // Spigot
entity.M = entity.locX;
entity.N = entity.locY;
entity.O = entity.locZ;
2017-09-18 20:00:00 +10:00
@@ -1584,6 +1603,7 @@ public abstract class World implements IBlockAccess {
2013-02-26 12:21:40 -05:00
}
}
}
2017-05-19 21:00:22 +10:00
+ entity.tickTimer.stopTiming(); // Spigot
2013-02-26 12:21:40 -05:00
}
diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
2017-10-28 16:17:34 +11:00
index ad88b4d9..1e07fb29 100644
2013-02-26 12:21:40 -05:00
--- a/src/main/java/net/minecraft/server/WorldServer.java
+++ b/src/main/java/net/minecraft/server/WorldServer.java
2017-09-18 20:00:00 +10:00
@@ -283,10 +283,13 @@ public class WorldServer extends World implements IAsyncTaskHandler {
2013-02-26 12:21:40 -05:00
// CraftBukkit start - Only call spawner if we have players online and the world allows for mobs or animals
long time = this.worldData.getTime();
2014-11-26 08:27:08 +11:00
if (this.getGameRules().getBoolean("doMobSpawning") && this.worldData.getType() != WorldType.DEBUG_ALL_BLOCK_STATES && (this.allowMonsters || this.allowAnimals) && (this instanceof WorldServer && this.players.size() > 0)) {
2013-02-26 12:21:40 -05:00
+ timings.mobSpawn.startTiming(); // Spigot
2016-03-01 08:33:06 +11:00
this.spawnerCreature.a(this, this.allowMonsters && (this.ticksPerMonsterSpawns != 0 && time % this.ticksPerMonsterSpawns == 0L), this.allowAnimals && (this.ticksPerAnimalSpawns != 0 && time % this.ticksPerAnimalSpawns == 0L), this.worldData.getTime() % 400L == 0L);
2013-02-26 12:21:40 -05:00
+ timings.mobSpawn.stopTiming(); // Spigot
2014-03-23 00:06:43 +00:00
// CraftBukkit end
2013-02-26 12:21:40 -05:00
}
2016-03-01 08:33:06 +11:00
2013-06-08 09:21:38 +10:00
+ timings.doChunkUnload.startTiming(); // Spigot
2013-02-26 12:21:40 -05:00
this.methodProfiler.c("chunkSource");
this.chunkProvider.unloadChunks();
int j = this.a(1.0F);
2017-09-18 20:00:00 +10:00
@@ -300,21 +303,36 @@ public class WorldServer extends World implements IAsyncTaskHandler {
2013-07-02 13:03:56 +10:00
this.worldData.setDayTime(this.worldData.getDayTime() + 1L);
}
2013-06-08 09:21:38 +10:00
+ timings.doChunkUnload.stopTiming(); // Spigot
this.methodProfiler.c("tickPending");
+ timings.doTickPending.startTiming(); // Spigot
this.a(false);
+ timings.doTickPending.stopTiming(); // Spigot
2013-12-01 14:40:53 +11:00
this.methodProfiler.c("tickBlocks");
2013-06-08 09:21:38 +10:00
+ timings.doTickTiles.startTiming(); // Spigot
2016-03-01 08:33:06 +11:00
this.j();
2013-06-08 09:21:38 +10:00
+ timings.doTickTiles.stopTiming(); // Spigot
this.methodProfiler.c("chunkMap");
+ timings.doChunkMap.startTiming(); // Spigot
this.manager.flush();
+ timings.doChunkMap.stopTiming(); // Spigot
this.methodProfiler.c("village");
+ timings.doVillages.startTiming(); // Spigot
this.villages.tick();
this.siegeManager.a();
+ timings.doVillages.stopTiming(); // Spigot
this.methodProfiler.c("portalForcer");
+ timings.doPortalForcer.startTiming(); // Spigot
2016-03-01 08:33:06 +11:00
this.portalTravelAgent.a(this.getTime());
2013-06-08 09:21:38 +10:00
+ timings.doPortalForcer.stopTiming(); // Spigot
this.methodProfiler.b();
+ timings.doSounds.startTiming(); // Spigot
2017-05-14 12:00:00 +10:00
this.aq();
2016-03-01 08:33:06 +11:00
+ timings.doSounds.stopTiming(); // Spigot
2015-02-28 11:36:22 +00:00
2016-03-03 20:22:48 +11:00
+ timings.doChunkGC.startTiming();// Spigot
2013-02-26 12:21:40 -05:00
this.getWorld().processChunkGC(); // CraftBukkit
2013-06-08 09:21:38 +10:00
+ timings.doChunkGC.stopTiming(); // Spigot
2013-02-26 12:21:40 -05:00
}
2016-05-10 21:48:25 +10:00
@Nullable
2014-08-25 20:09:32 +01:00
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
2017-10-28 16:17:34 +11:00
index ce40ffaf..633ddb49 100644
2014-08-25 20:09:32 +01:00
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
2017-09-09 15:44:16 +10:00
@@ -1702,6 +1702,11 @@ public final class CraftServer implements Server {
2014-08-25 20:09:32 +01:00
private final Spigot spigot = new Spigot()
{
+ @Override
+ public YamlConfiguration getConfig()
+ {
+ return org.spigotmc.SpigotConfig.config;
+ }
};
public Spigot spigot()
2013-02-26 12:21:40 -05:00
diff --git a/src/main/java/org/bukkit/craftbukkit/SpigotTimings.java b/src/main/java/org/bukkit/craftbukkit/SpigotTimings.java
new file mode 100644
2017-10-28 16:17:34 +11:00
index 00000000..fa88be0d
2013-02-26 12:21:40 -05:00
--- /dev/null
+++ b/src/main/java/org/bukkit/craftbukkit/SpigotTimings.java
2017-05-14 12:00:00 +10:00
@@ -0,0 +1,171 @@
2013-02-26 12:21:40 -05:00
+package org.bukkit.craftbukkit;
+
2014-07-07 18:59:02 -04:00
+import com.google.common.collect.Maps;
2013-02-26 12:21:40 -05:00
+import net.minecraft.server.*;
2014-07-07 18:59:02 -04:00
+import org.bukkit.plugin.java.JavaPluginLoader;
2013-06-02 11:29:44 +10:00
+import org.spigotmc.CustomTimingsHandler;
2013-02-26 12:21:40 -05:00
+import org.bukkit.scheduler.BukkitTask;
+
+import java.util.HashMap;
2014-07-07 18:59:02 -04:00
+import java.util.Map;
+
2013-08-03 19:39:35 +10:00
+import org.bukkit.craftbukkit.scheduler.CraftTask;
2013-02-26 12:21:40 -05:00
+
+public class SpigotTimings {
+
+ public static final CustomTimingsHandler serverTickTimer = new CustomTimingsHandler("** Full Server Tick");
+ public static final CustomTimingsHandler playerListTimer = new CustomTimingsHandler("Player List");
2017-05-14 12:00:00 +10:00
+ public static final CustomTimingsHandler commandFunctionsTimer = new CustomTimingsHandler("Command Functions");
2014-07-07 18:59:02 -04:00
+ public static final CustomTimingsHandler connectionTimer = new CustomTimingsHandler("Connection Handler");
2013-02-26 12:21:40 -05:00
+ public static final CustomTimingsHandler tickablesTimer = new CustomTimingsHandler("Tickables");
+ public static final CustomTimingsHandler schedulerTimer = new CustomTimingsHandler("Scheduler");
+ public static final CustomTimingsHandler chunkIOTickTimer = new CustomTimingsHandler("ChunkIOTick");
2014-07-07 18:59:02 -04:00
+ public static final CustomTimingsHandler timeUpdateTimer = new CustomTimingsHandler("Time Update");
+ public static final CustomTimingsHandler serverCommandTimer = new CustomTimingsHandler("Server Command");
+ public static final CustomTimingsHandler worldSaveTimer = new CustomTimingsHandler("World Save");
2013-02-26 12:21:40 -05:00
+
+ public static final CustomTimingsHandler entityMoveTimer = new CustomTimingsHandler("** entityMove");
+ public static final CustomTimingsHandler tickEntityTimer = new CustomTimingsHandler("** tickEntity");
+ public static final CustomTimingsHandler activatedEntityTimer = new CustomTimingsHandler("** activatedTickEntity");
+ public static final CustomTimingsHandler tickTileEntityTimer = new CustomTimingsHandler("** tickTileEntity");
+
+ public static final CustomTimingsHandler timerEntityBaseTick = new CustomTimingsHandler("** livingEntityBaseTick");
+ public static final CustomTimingsHandler timerEntityAI = new CustomTimingsHandler("** livingEntityAI");
+ public static final CustomTimingsHandler timerEntityAICollision = new CustomTimingsHandler("** livingEntityAICollision");
+ public static final CustomTimingsHandler timerEntityAIMove = new CustomTimingsHandler("** livingEntityAIMove");
+ public static final CustomTimingsHandler timerEntityTickRest = new CustomTimingsHandler("** livingEntityTickRest");
+
2014-07-07 18:59:02 -04:00
+ public static final CustomTimingsHandler processQueueTimer = new CustomTimingsHandler("processQueue");
+ public static final CustomTimingsHandler schedulerSyncTimer = new CustomTimingsHandler("** Scheduler - Sync Tasks", JavaPluginLoader.pluginParentTimer);
+
2013-02-26 12:21:40 -05:00
+ public static final CustomTimingsHandler playerCommandTimer = new CustomTimingsHandler("** playerCommand");
+
+ public static final HashMap<String, CustomTimingsHandler> entityTypeTimingMap = new HashMap<String, CustomTimingsHandler>();
+ public static final HashMap<String, CustomTimingsHandler> tileEntityTypeTimingMap = new HashMap<String, CustomTimingsHandler>();
+ public static final HashMap<String, CustomTimingsHandler> pluginTaskTimingMap = new HashMap<String, CustomTimingsHandler>();
+
+ /**
+ * Gets a timer associated with a plugins tasks.
+ * @param task
+ * @param period
+ * @return
+ */
+ public static CustomTimingsHandler getPluginTaskTimings(BukkitTask task, long period) {
2014-07-07 18:59:02 -04:00
+ if (!task.isSync()) {
+ return null;
+ }
+ String plugin;
+ final CraftTask ctask = (CraftTask) task;
+
+ if (task.getOwner() != null) {
+ plugin = task.getOwner().getDescription().getFullName();
+ } else if (ctask.timingName != null) {
+ plugin = "CraftScheduler";
+ } else {
+ plugin = "Unknown";
+ }
+ String taskname = ctask.getTaskName();
+
+ String name = "Task: " + plugin + " Runnable: " + taskname;
2013-02-26 12:21:40 -05:00
+ if (period > 0) {
2013-02-27 00:39:53 -05:00
+ name += "(interval:" + period +")";
2013-02-26 12:21:40 -05:00
+ } else {
2013-02-27 00:39:53 -05:00
+ name += "(Single)";
2013-02-26 12:21:40 -05:00
+ }
2013-02-27 00:39:53 -05:00
+ CustomTimingsHandler result = pluginTaskTimingMap.get(name);
+ if (result == null) {
2014-07-07 18:59:02 -04:00
+ result = new CustomTimingsHandler(name, SpigotTimings.schedulerSyncTimer);
2013-02-27 00:39:53 -05:00
+ pluginTaskTimingMap.put(name, result);
+ }
+ return result;
2013-02-26 12:21:40 -05:00
+ }
+
+ /**
+ * Get a named timer for the specified entity type to track type specific timings.
+ * @param entity
+ * @return
+ */
+ public static CustomTimingsHandler getEntityTimings(Entity entity) {
2017-10-28 16:17:34 +11:00
+ String entityType = entity.getClass().getName();
2013-02-26 12:21:40 -05:00
+ CustomTimingsHandler result = entityTypeTimingMap.get(entityType);
+ if (result == null) {
2017-10-28 16:17:34 +11:00
+ result = new CustomTimingsHandler("** tickEntity - " + entity.getClass().getSimpleName(), activatedEntityTimer);
2013-02-26 12:21:40 -05:00
+ entityTypeTimingMap.put(entityType, result);
+ }
+ return result;
+ }
+
+ /**
+ * Get a named timer for the specified tile entity type to track type specific timings.
+ * @param entity
+ * @return
+ */
+ public static CustomTimingsHandler getTileEntityTimings(TileEntity entity) {
2017-10-28 16:17:34 +11:00
+ String entityType = entity.getClass().getName();
2013-02-26 12:21:40 -05:00
+ CustomTimingsHandler result = tileEntityTypeTimingMap.get(entityType);
+ if (result == null) {
2017-10-28 16:17:34 +11:00
+ result = new CustomTimingsHandler("** tickTileEntity - " + entity.getClass().getSimpleName(), tickTileEntityTimer);
2013-02-26 12:21:40 -05:00
+ tileEntityTypeTimingMap.put(entityType, result);
+ }
+ return result;
+ }
+
+ /**
+ * Set of timers per world, to track world specific timings.
+ */
+ public static class WorldTimingsHandler {
+ public final CustomTimingsHandler mobSpawn;
2013-06-08 09:21:38 +10:00
+ public final CustomTimingsHandler doChunkUnload;
+ public final CustomTimingsHandler doPortalForcer;
+ public final CustomTimingsHandler doTickPending;
+ public final CustomTimingsHandler doTickTiles;
+ public final CustomTimingsHandler doVillages;
+ public final CustomTimingsHandler doChunkMap;
+ public final CustomTimingsHandler doChunkGC;
+ public final CustomTimingsHandler doSounds;
2013-02-26 12:21:40 -05:00
+ public final CustomTimingsHandler entityTick;
+ public final CustomTimingsHandler tileEntityTick;
+ public final CustomTimingsHandler tileEntityPending;
+ public final CustomTimingsHandler tracker;
2014-07-07 18:59:02 -04:00
+ public final CustomTimingsHandler doTick;
+ public final CustomTimingsHandler tickEntities;
+
+ public final CustomTimingsHandler syncChunkLoadTimer;
+ public final CustomTimingsHandler syncChunkLoadDataTimer;
+ public final CustomTimingsHandler syncChunkLoadStructuresTimer;
+ public final CustomTimingsHandler syncChunkLoadEntitiesTimer;
+ public final CustomTimingsHandler syncChunkLoadTileEntitiesTimer;
+ public final CustomTimingsHandler syncChunkLoadTileTicksTimer;
+ public final CustomTimingsHandler syncChunkLoadPostTimer;
2013-02-26 12:21:40 -05:00
+
+ public WorldTimingsHandler(World server) {
+ String name = server.worldData.getName() +" - ";
+
2014-07-07 18:59:02 -04:00
+ mobSpawn = new CustomTimingsHandler("** " + name + "mobSpawn");
+ doChunkUnload = new CustomTimingsHandler("** " + name + "doChunkUnload");
+ doTickPending = new CustomTimingsHandler("** " + name + "doTickPending");
+ doTickTiles = new CustomTimingsHandler("** " + name + "doTickTiles");
+ doVillages = new CustomTimingsHandler("** " + name + "doVillages");
+ doChunkMap = new CustomTimingsHandler("** " + name + "doChunkMap");
+ doSounds = new CustomTimingsHandler("** " + name + "doSounds");
+ doChunkGC = new CustomTimingsHandler("** " + name + "doChunkGC");
+ doPortalForcer = new CustomTimingsHandler("** " + name + "doPortalForcer");
+ entityTick = new CustomTimingsHandler("** " + name + "entityTick");
+ tileEntityTick = new CustomTimingsHandler("** " + name + "tileEntityTick");
+ tileEntityPending = new CustomTimingsHandler("** " + name + "tileEntityPending");
+
+ syncChunkLoadTimer = new CustomTimingsHandler("** " + name + "syncChunkLoad");
+ syncChunkLoadDataTimer = new CustomTimingsHandler("** " + name + "syncChunkLoad - Data");
+ syncChunkLoadStructuresTimer = new CustomTimingsHandler("** " + name + "chunkLoad - Structures");
+ syncChunkLoadEntitiesTimer = new CustomTimingsHandler("** " + name + "chunkLoad - Entities");
+ syncChunkLoadTileEntitiesTimer = new CustomTimingsHandler("** " + name + "chunkLoad - TileEntities");
+ syncChunkLoadTileTicksTimer = new CustomTimingsHandler("** " + name + "chunkLoad - TileTicks");
+ syncChunkLoadPostTimer = new CustomTimingsHandler("** " + name + "chunkLoad - Post");
+
+
2013-02-26 12:21:40 -05:00
+ tracker = new CustomTimingsHandler(name + "tracker");
2014-07-07 18:59:02 -04:00
+ doTick = new CustomTimingsHandler(name + "doTick");
+ tickEntities = new CustomTimingsHandler(name + "tickEntities");
2013-02-26 12:21:40 -05:00
+ }
+ }
+}
2014-07-07 18:59:02 -04:00
diff --git a/src/main/java/org/bukkit/craftbukkit/chunkio/ChunkIOProvider.java b/src/main/java/org/bukkit/craftbukkit/chunkio/ChunkIOProvider.java
2017-10-28 16:17:34 +11:00
index f1c1dc49..3a95b446 100644
2014-07-07 18:59:02 -04:00
--- a/src/main/java/org/bukkit/craftbukkit/chunkio/ChunkIOProvider.java
+++ b/src/main/java/org/bukkit/craftbukkit/chunkio/ChunkIOProvider.java
2016-03-01 08:33:06 +11:00
@@ -45,7 +45,9 @@ class ChunkIOProvider implements AsynchronousExecutor.CallBackProvider<QueuedChu
2014-07-07 18:59:02 -04:00
chunk.addEntities();
2016-03-01 08:33:06 +11:00
if (queuedChunk.provider.chunkGenerator != null) {
2014-07-07 18:59:02 -04:00
+ queuedChunk.provider.world.timings.syncChunkLoadStructuresTimer.startTiming(); // Spigot
2016-03-01 08:33:06 +11:00
queuedChunk.provider.chunkGenerator.recreateStructures(chunk, queuedChunk.x, queuedChunk.z);
2014-07-07 18:59:02 -04:00
+ queuedChunk.provider.world.timings.syncChunkLoadStructuresTimer.stopTiming(); // Spigot
}
2016-06-23 10:37:05 +10:00
chunk.loadNearby(queuedChunk.provider, queuedChunk.provider.chunkGenerator, false);
2014-07-07 18:59:02 -04:00
diff --git a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java
2017-10-28 16:17:34 +11:00
index c5d751e9..f2278e89 100644
2014-07-07 18:59:02 -04:00
--- a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java
+++ b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java
2016-10-01 12:27:26 +10:00
@@ -349,7 +349,9 @@ public class CraftScheduler implements BukkitScheduler {
2014-07-07 18:59:02 -04:00
}
if (task.isSync()) {
try {
+ task.timings.startTiming(); // Spigot
task.run();
+ task.timings.stopTiming(); // Spigot
} catch (final Throwable throwable) {
task.getOwner().getLogger().log(
Level.WARNING,
2013-02-26 12:21:40 -05:00
diff --git a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftTask.java b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftTask.java
2017-10-28 16:17:34 +11:00
index 9cb666bb..c37275f2 100644
2013-02-26 12:21:40 -05:00
--- a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftTask.java
+++ b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftTask.java
2013-08-03 19:39:35 +10:00
@@ -1,11 +1,13 @@
2013-02-26 12:21:40 -05:00
package org.bukkit.craftbukkit.scheduler;
import org.bukkit.Bukkit;
+import org.bukkit.craftbukkit.SpigotTimings; // Spigot
2013-06-02 11:29:44 +10:00
+import org.spigotmc.CustomTimingsHandler; // Spigot
2013-02-26 12:21:40 -05:00
import org.bukkit.plugin.Plugin;
import org.bukkit.scheduler.BukkitTask;
2013-08-03 19:39:35 +10:00
-class CraftTask implements BukkitTask, Runnable {
+public class CraftTask implements BukkitTask, Runnable { // Spigot
private volatile CraftTask next = null;
/**
2013-02-26 12:21:40 -05:00
@@ -22,6 +24,7 @@ class CraftTask implements BukkitTask, Runnable {
private final Plugin plugin;
private final int id;
2014-07-07 18:59:02 -04:00
+ final CustomTimingsHandler timings; // Spigot
2013-02-26 12:21:40 -05:00
CraftTask() {
this(null, null, -1, -1);
}
2014-07-07 18:59:02 -04:00
@@ -30,11 +33,26 @@ class CraftTask implements BukkitTask, Runnable {
this(null, task, -1, -1);
2013-02-26 12:21:40 -05:00
}
2014-07-07 18:59:02 -04:00
- CraftTask(final Plugin plugin, final Runnable task, final int id, final long period) {
+ // Spigot start
+ public String timingName = null;
+ CraftTask(String timingName) {
+ this(timingName, null, null, -1, -1);
+ }
+ CraftTask(String timingName, final Runnable task) {
+ this(timingName, null, task, -1, -1);
+ }
+ CraftTask(String timingName, final Plugin plugin, final Runnable task, final int id, final long period) {
this.plugin = plugin;
this.task = task;
this.id = id;
this.period = period;
+ this.timingName = timingName == null && task == null ? "Unknown" : timingName;
+ timings = this.isSync() ? SpigotTimings.getPluginTaskTimings(this, period) : null;
+ }
+
+ CraftTask(final Plugin plugin, final Runnable task, final int id, final long period) {
+ this(null, plugin, task, id, period);
+ // Spigot end
2013-08-03 19:39:35 +10:00
}
2014-07-07 18:59:02 -04:00
public final int getTaskId() {
2017-09-09 15:44:16 +10:00
@@ -99,4 +117,13 @@ class CraftTask implements BukkitTask, Runnable {
2014-07-07 18:59:02 -04:00
setPeriod(-2l);
return true;
2013-08-03 19:39:35 +10:00
}
2014-07-07 18:59:02 -04:00
+
+ // Spigot start
+ public String getTaskName() {
+ if (timingName != null) {
+ return timingName;
+ }
+ return task.getClass().getName();
+ }
+ // Spigot end
}
2013-02-26 12:21:40 -05:00
--
2017-11-07 17:30:57 +11:00
2.14.1
2013-02-26 12:21:40 -05:00