2019-04-28 11:41:06 +10:00
From bc632a05e1407802e7d914e247fed4032a9fdad4 Mon Sep 17 00:00:00 2001
2017-11-07 18:58:02 +11:00
From: Aikar <aikar@aikar.co>
Date: Thu, 10 Jan 2013 00:18:11 -0500
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
diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java
2019-04-25 12:00:00 +10:00
index b763cdd8b..845ad7427 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
2019-04-23 12:00:00 +10:00
@@ -81,8 +81,10 @@ public class ChunkProviderServer extends IChunkProvider {
CompletableFuture completablefuture;
if (flag1) {
+ world.timings.syncChunkLoadTimer.startTiming(); // Spigot
completablefuture = this.getChunkFutureMainThread(i, j, chunkstatus, flag);
2019-04-25 12:00:00 +10:00
this.serverThreadQueue.awaitTasks((BooleanSupplier) completablefuture::isDone); // CraftBukkit - decompile error
2019-04-23 12:00:00 +10:00
+ world.timings.syncChunkLoadTimer.stopTiming(); // Spigot
2018-08-26 12:00:00 +10:00
} else {
2019-04-23 12:00:00 +10:00
completablefuture = CompletableFuture.supplyAsync(() -> {
return this.getChunkFutureMainThread(i, j, chunkstatus, flag);
@@ -206,12 +208,16 @@ public class ChunkProviderServer extends IChunkProvider {
public void tick(BooleanSupplier booleansupplier) {
this.world.getMethodProfiler().enter("purge");
+ this.world.timings.doChunkMap.startTiming(); // Spigot
this.chunkMapDistance.purgeTickets();
this.tickDistanceManager();
+ this.world.timings.doChunkMap.stopTiming(); // Spigot
this.world.getMethodProfiler().exitEnter("chunks");
this.tickChunks();
+ this.world.timings.doChunkUnload.startTiming(); // Spigot
this.world.getMethodProfiler().exitEnter("unload");
this.playerChunkMap.unloadChunks(booleansupplier);
+ this.world.timings.doChunkUnload.stopTiming(); // Spigot
this.world.getMethodProfiler().exit();
}
@@ -249,6 +255,7 @@ public class ChunkProviderServer extends IChunkProvider {
chunk.b(chunk.q() + j);
if (flag1 && (this.allowMonsters || this.allowAnimals) && this.world.getWorldBorder().isInBounds(chunk.getPos())) {
this.world.getMethodProfiler().enter("spawner");
+ this.world.timings.mobSpawn.startTiming(); // Spigot
EnumCreatureType[] aenumcreaturetype1 = aenumcreaturetype;
int i1 = aenumcreaturetype.length;
@@ -286,10 +293,13 @@ public class ChunkProviderServer extends IChunkProvider {
}
}
+ this.world.timings.mobSpawn.stopTiming(); // Spigot
this.world.getMethodProfiler().exit();
}
+ this.world.timings.doTickTiles.startTiming(); // Spigot
this.world.a(chunk, l);
+ this.world.timings.doTickTiles.stopTiming(); // Spigot
}
}
}
@@ -300,7 +310,9 @@ public class ChunkProviderServer extends IChunkProvider {
}
2013-02-26 12:21:40 -05:00
}
2019-04-23 12:00:00 +10:00
+ this.world.timings.tracker.startTiming(); // Spigot
this.playerChunkMap.g();
+ this.world.timings.tracker.stopTiming(); // Spigot
}
@Override
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
2019-04-25 12:00:00 +10:00
index b3c76c9af..d084d24a0 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
2019-04-23 12:00:00 +10:00
@@ -412,6 +412,7 @@ public class ChunkRegionLoader {
private static void loadEntities(NBTTagCompound nbttagcompound, Chunk chunk) {
2018-07-15 10:00:00 +10:00
NBTTagList nbttaglist = nbttagcompound.getList("Entities", 10);
World world = chunk.getWorld();
2014-07-07 18:59:02 -04:00
+ world.timings.syncChunkLoadEntitiesTimer.startTiming(); // Spigot
2018-07-15 10:00:00 +10:00
for (int i = 0; i < nbttaglist.size(); ++i) {
NBTTagCompound nbttagcompound1 = nbttaglist.getCompound(i);
2019-04-23 12:00:00 +10:00
@@ -423,6 +424,8 @@ public class ChunkRegionLoader {
chunk.d(true);
2014-07-07 18:59:02 -04:00
}
2018-07-15 10:00:00 +10:00
2014-07-07 18:59:02 -04:00
+ world.timings.syncChunkLoadEntitiesTimer.stopTiming(); // Spigot
+ world.timings.syncChunkLoadTileEntitiesTimer.startTiming(); // Spigot
2018-07-15 10:00:00 +10:00
NBTTagList nbttaglist1 = nbttagcompound.getList("TileEntities", 10);
2014-07-07 18:59:02 -04:00
2018-07-15 10:00:00 +10:00
for (int j = 0; j < nbttaglist1.size(); ++j) {
2019-04-23 12:00:00 +10:00
@@ -439,6 +442,8 @@ public class ChunkRegionLoader {
2018-07-15 10:00:00 +10:00
}
2014-07-07 18:59:02 -04:00
}
}
+ world.timings.syncChunkLoadTileEntitiesTimer.stopTiming(); // Spigot
+ world.timings.syncChunkLoadTileTicksTimer.startTiming(); // Spigot
2018-12-13 11:00:00 +11:00
if (nbttagcompound.hasKeyOfType("TileTicks", 9) && world.getBlockTickList() instanceof TickListServer) {
((TickListServer) world.getBlockTickList()).a(nbttagcompound.getList("TileTicks", 10));
2019-04-23 12:00:00 +10:00
@@ -447,6 +452,7 @@ public class ChunkRegionLoader {
2018-12-13 11:00:00 +11:00
if (nbttagcompound.hasKeyOfType("LiquidTicks", 9) && world.getFluidTickList() instanceof TickListServer) {
((TickListServer) world.getFluidTickList()).a(nbttagcompound.getList("LiquidTicks", 10));
2014-07-07 18:59:02 -04:00
}
+ world.timings.syncChunkLoadTileTicksTimer.stopTiming(); // Spigot
}
2018-07-15 10:00:00 +10:00
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
2019-04-25 12:00:00 +10:00
index f3fa0bb62..213312b38 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
2019-04-23 12:00:00 +10:00
@@ -31,6 +31,7 @@ import org.apache.logging.log4j.Level;
2014-07-07 18:59:02 -04:00
2018-07-15 10:00:00 +10:00
import org.bukkit.command.CommandSender;
2014-07-07 18:59:02 -04:00
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;
2019-04-23 12:00:00 +10:00
@@ -398,6 +399,7 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer
2014-07-07 18:59:02 -04:00
}
2018-12-13 11:00:00 +11:00
public void handleCommandQueue() {
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
2019-04-23 12:00:00 +10:00
@@ -412,6 +414,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
}
2019-04-23 12:00:00 +10:00
@Override
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
2019-04-28 11:41:06 +10:00
index 1258c8a5f..7f779ec93 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
2019-04-25 12:00:00 +10:00
@@ -29,6 +29,7 @@ import org.bukkit.command.CommandSender;
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;
2019-04-27 10:30:04 +10:00
@@ -160,6 +161,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener {
2017-11-07 17:30:57 +11:00
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;
2019-04-28 11:41:06 +10:00
@@ -469,6 +471,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener {
2014-11-26 08:27:08 +11:00
}
2019-04-23 12:00:00 +10:00
public void move(EnumMoveType enummovetype, Vec3D vec3d) {
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) {
2019-04-23 12:00:00 +10:00
this.a(this.getBoundingBox().b(vec3d));
2014-11-26 08:27:08 +11:00
this.recalcPosition();
2019-04-28 11:41:06 +10:00
@@ -633,6 +636,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener {
2013-02-26 12:21:40 -05:00
2019-04-23 12:00:00 +10:00
this.world.getMethodProfiler().exit();
2013-02-26 12:21:40 -05:00
}
+ org.bukkit.craftbukkit.SpigotTimings.entityMoveTimer.stopTiming(); // Spigot
}
2019-04-23 12:00:00 +10:00
protected Vec3D a(Vec3D vec3d, EnumMoveType enummovetype) {
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
2019-04-25 12:00:00 +10:00
index 31abdec9c..904d86292 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
2019-04-23 12:00:00 +10:00
@@ -35,6 +35,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 {
2019-04-23 12:00:00 +10:00
private static final UUID b = UUID.fromString("662A6B8D-DA3E-4C1C-8813-96EA6097278D");
@@ -2198,6 +2200,7 @@ public abstract class EntityLiving extends Entity {
2014-07-07 18:59:02 -04:00
2019-04-23 12:00:00 +10:00
@Override
2018-07-15 10:00:00 +10:00
public void tick() {
2014-07-07 18:59:02 -04:00
+ SpigotTimings.timerEntityBaseTick.startTiming(); // Spigot
2018-07-15 10:00:00 +10:00
super.tick();
2019-04-23 12:00:00 +10:00
this.dk();
2018-07-15 10:00:00 +10:00
this.o();
2019-04-23 12:00:00 +10:00
@@ -2272,7 +2275,9 @@ public abstract class EntityLiving extends Entity {
2014-07-07 18:59:02 -04:00
}
}
+ SpigotTimings.timerEntityBaseTick.stopTiming(); // Spigot
2018-12-13 11:00:00 +11:00
this.movementTick();
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);
2019-04-23 12:00:00 +10:00
@@ -2353,6 +2358,7 @@ public abstract class EntityLiving extends Entity {
this.pitch = 0.0F;
2016-03-01 08:33:06 +11:00
}
2014-07-07 18:59:02 -04:00
+ SpigotTimings.timerEntityTickRest.stopTiming(); // Spigot
}
2018-07-15 10:00:00 +10:00
protected float e(float f, float f1) {
2019-04-23 12:00:00 +10:00
@@ -2426,6 +2432,7 @@ public abstract class EntityLiving extends Entity {
2014-07-07 18:59:02 -04:00
2019-04-23 12:00:00 +10:00
this.setMot(d4, d5, d6);
this.world.getMethodProfiler().enter("ai");
2014-07-07 18:59:02 -04:00
+ SpigotTimings.timerEntityAI.startTiming(); // Spigot
2016-11-17 12:41:12 +11:00
if (this.isFrozen()) {
2019-04-23 12:00:00 +10:00
this.jumping = false;
this.bb = 0.0F;
@@ -2436,6 +2443,7 @@ public abstract class EntityLiving extends Entity {
2014-11-26 08:27:08 +11:00
this.doTick();
2019-04-23 12:00:00 +10:00
this.world.getMethodProfiler().exit();
2014-07-07 18:59:02 -04:00
}
+ SpigotTimings.timerEntityAI.stopTiming(); // Spigot
2019-04-23 12:00:00 +10:00
this.world.getMethodProfiler().exit();
this.world.getMethodProfiler().enter("jump");
@@ -2460,7 +2468,9 @@ public abstract class EntityLiving extends Entity {
2018-07-15 10:00:00 +10:00
this.n();
AxisAlignedBB axisalignedbb = this.getBoundingBox();
2014-07-07 18:59:02 -04:00
+ SpigotTimings.timerEntityAIMove.startTiming(); // Spigot
2019-04-23 12:00:00 +10:00
this.e(new Vec3D((double) this.bb, (double) this.bc, (double) this.bd));
2014-07-07 18:59:02 -04:00
+ SpigotTimings.timerEntityAIMove.stopTiming(); // Spigot
2019-04-23 12:00:00 +10:00
this.world.getMethodProfiler().exit();
this.world.getMethodProfiler().enter("push");
if (this.bq > 0) {
@@ -2468,7 +2478,9 @@ public abstract class EntityLiving extends Entity {
2018-07-15 10:00:00 +10:00
this.a(axisalignedbb, this.getBoundingBox());
}
2016-03-01 08:33:06 +11:00
+ SpigotTimings.timerEntityAICollision.startTiming(); // Spigot
2019-04-23 12:00:00 +10:00
this.collideNearby();
2016-03-01 08:33:06 +11:00
+ SpigotTimings.timerEntityAICollision.stopTiming(); // Spigot
2019-04-23 12:00:00 +10:00
this.world.getMethodProfiler().exit();
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
2019-04-28 11:41:06 +10:00
index 85080affa..a9e5e3659 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
2019-04-23 14:06:57 +10:00
@@ -54,6 +54,7 @@ import org.bukkit.craftbukkit.CraftServer;
2016-07-15 20:11:38 +10:00
import org.bukkit.craftbukkit.Main;
2018-09-08 13:48:25 +10:00
import org.bukkit.event.server.ServerLoadEvent;
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
2019-04-23 12:00:00 +10:00
public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTask> implements IMojangStatistics, ICommandListener, AutoCloseable, Runnable {
2014-01-22 19:23:59 +11:00
2019-04-25 15:38:41 +10:00
@@ -903,6 +904,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
2019-04-23 12:00:00 +10:00
protected void exit() {}
2016-03-01 08:33:06 +11:00
2018-08-26 12:00:00 +10:00
protected void a(BooleanSupplier booleansupplier) {
2014-01-22 19:23:59 +11:00
+ SpigotTimings.serverTickTimer.startTiming(); // Spigot
2018-12-13 11:00:00 +11:00
long i = SystemUtils.getMonotonicNanos();
2014-01-22 19:23:59 +11:00
2014-03-23 00:06:43 +00:00
++this.ticks;
2019-04-25 15:38:41 +10:00
@@ -922,12 +924,14 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
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
2019-04-23 12:00:00 +10:00
MinecraftServer.LOGGER.debug("Autosave started");
2018-12-13 11:00:00 +11:00
this.methodProfiler.enter("save");
this.playerList.savePlayers();
2019-04-23 12:00:00 +10:00
this.saveChunks(true, false, false);
2018-12-13 11:00:00 +11:00
this.methodProfiler.exit();
2019-04-23 12:00:00 +10:00
MinecraftServer.LOGGER.debug("Autosave finished");
2014-07-07 18:59:02 -04:00
+ SpigotTimings.worldSaveTimer.stopTiming(); // Spigot
}
2018-12-13 11:00:00 +11:00
this.methodProfiler.enter("snooper");
2019-04-25 15:38:41 +10:00
@@ -948,20 +952,29 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
2019-04-23 12:00:00 +10:00
this.ap.a(i1 - i);
2018-12-13 11:00:00 +11:00
this.methodProfiler.exit();
2014-08-05 17:29:09 +01:00
+ SpigotTimings.serverTickTimer.stopTiming(); // Spigot
+ org.spigotmc.CustomTimingsHandler.tick(); // Spigot
}
2019-04-23 12:00:00 +10:00
protected void b(BooleanSupplier booleansupplier) {
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
2019-04-23 12:00:00 +10:00
this.methodProfiler.enter("commandFunctions");
2018-07-15 10:00:00 +10:00
+ SpigotTimings.commandFunctionsTimer.startTiming(); // Spigot
2018-12-13 11:00:00 +11:00
this.getFunctionData().tick();
2018-07-15 10:00:00 +10:00
+ SpigotTimings.commandFunctionsTimer.stopTiming(); // Spigot
2018-12-13 11:00:00 +11:00
this.methodProfiler.exitEnter("levels");
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
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) {
2019-04-25 15:38:41 +10:00
@@ -969,6 +982,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
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
2018-08-26 12:00:00 +10:00
// WorldServer worldserver; // CraftBukkit - dropped down
long i;
2019-04-25 15:38:41 +10:00
@@ -992,7 +1006,9 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
2019-04-23 12:00:00 +10:00
this.methodProfiler.enter("tick");
2014-07-07 18:59:02 -04:00
try {
+ worldserver.timings.doTick.startTiming(); // Spigot
2018-08-26 12:00:00 +10:00
worldserver.doTick(booleansupplier);
2014-07-07 18:59:02 -04:00
+ worldserver.timings.doTick.stopTiming(); // Spigot
2015-02-28 11:36:22 +00:00
} catch (Throwable throwable) {
2019-04-23 12:00:00 +10:00
CrashReport crashreport = CrashReport.a(throwable, "Exception ticking world");
2014-07-07 18:59:02 -04:00
2019-04-25 15:38:41 +10:00
@@ -1006,14 +1022,20 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
2013-02-26 12:21:40 -05:00
}
2018-12-13 11:00:00 +11:00
this.methodProfiler.exitEnter("connection");
2013-02-26 12:21:40 -05:00
+ SpigotTimings.connectionTimer.startTiming(); // Spigot
2018-07-15 10:00:00 +10:00
this.getServerConnection().c();
2013-02-26 12:21:40 -05:00
+ SpigotTimings.connectionTimer.stopTiming(); // Spigot
2018-12-13 11:00:00 +11:00
this.methodProfiler.exitEnter("players");
2013-02-26 12:21:40 -05:00
+ SpigotTimings.playerListTimer.startTiming(); // Spigot
2018-12-13 11:00:00 +11:00
this.playerList.tick();
2013-02-26 12:21:40 -05:00
+ SpigotTimings.playerListTimer.stopTiming(); // Spigot
2019-04-23 12:00:00 +10:00
this.methodProfiler.exitEnter("server gui refresh");
2013-02-26 12:21:40 -05:00
+ SpigotTimings.tickablesTimer.startTiming(); // Spigot
2019-04-23 12:00:00 +10:00
for (int j = 0; j < this.tickables.size(); ++j) {
((Runnable) this.tickables.get(j)).run();
2013-02-26 12:21:40 -05:00
}
+ SpigotTimings.tickablesTimer.stopTiming(); // Spigot
2018-12-13 11:00:00 +11:00
this.methodProfiler.exit();
2013-02-26 12:21:40 -05:00
}
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
2019-04-25 12:00:00 +10:00
index 0e936a511..887b8a40b 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
2019-04-23 12:00:00 +10:00
@@ -136,6 +136,7 @@ public class PlayerConnection implements PacketListenerPlayIn {
2018-10-27 17:44:13 +11:00
// CraftBukkit end
2018-12-13 11:00:00 +11:00
public void tick() {
2018-10-27 17:44:13 +11:00
+ org.bukkit.craftbukkit.SpigotTimings.playerConnectionTimer.startTiming(); // Spigot
this.syncPosition();
this.player.playerTick();
this.player.setLocation(this.l, this.m, this.n, this.player.yaw, this.player.pitch);
2019-04-23 12:00:00 +10:00
@@ -208,6 +209,7 @@ public class PlayerConnection implements PacketListenerPlayIn {
2018-10-27 17:44:13 +11:00
this.player.resetIdleTimer(); // CraftBukkit - SPIGOT-854
this.disconnect(new ChatMessage("multiplayer.disconnect.idling", new Object[0]));
}
+ org.bukkit.craftbukkit.SpigotTimings.playerConnectionTimer.stopTiming(); // Spigot
}
2019-04-23 12:00:00 +10:00
@@ -1600,6 +1602,7 @@ public class PlayerConnection implements PacketListenerPlayIn {
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
2018-07-15 10:00:00 +10: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
2019-04-23 12:00:00 +10:00
@@ -1609,6 +1612,7 @@ public class PlayerConnection implements PacketListenerPlayIn {
2013-02-26 12:21:40 -05:00
this.server.getPluginManager().callEvent(event);
if (event.isCancelled()) {
+ org.bukkit.craftbukkit.SpigotTimings.playerCommandTimer.stopTiming(); // Spigot
return;
}
2019-04-23 12:00:00 +10:00
@@ -1620,6 +1624,8 @@ public class PlayerConnection implements PacketListenerPlayIn {
2013-02-26 12:21:40 -05:00
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
return;
2018-07-15 10:00:00 +10:00
+ } finally {
+ org.bukkit.craftbukkit.SpigotTimings.playerCommandTimer.stopTiming(); // Spigot
2013-02-26 12:21:40 -05:00
}
2018-07-15 10:00:00 +10:00
// this.minecraftServer.getCommandDispatcher().a(this.player.getCommandListener(), s);
2013-02-26 12:21:40 -05:00
// CraftBukkit end
diff --git a/src/main/java/net/minecraft/server/TileEntity.java b/src/main/java/net/minecraft/server/TileEntity.java
2019-04-25 14:39:43 +10:00
index d5967b935..7b0a65e36 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
2019-04-25 14:39:43 +10:00
@@ -8,9 +8,11 @@ import org.bukkit.craftbukkit.persistence.CraftPersistentDataContainer;
import org.bukkit.craftbukkit.persistence.CraftPersistentDataTypeRegistry;
import org.bukkit.inventory.InventoryHolder;
// CraftBukkit end
2013-06-02 11:29:44 +10:00
+import org.spigotmc.CustomTimingsHandler; // Spigot
2013-02-26 12:21:40 -05:00
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
2019-04-25 14:39:43 +10:00
// CraftBukkit start - data containers
private static final CraftPersistentDataTypeRegistry DATA_TYPE_REGISTRY = new CraftPersistentDataTypeRegistry();
public final CraftPersistentDataContainer persistentDataContainer = new CraftPersistentDataContainer(DATA_TYPE_REGISTRY);
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
2019-04-25 12:00:00 +10:00
index 7bcf0f401..cf10a89d8 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
2019-04-23 12:00:00 +10:00
@@ -20,6 +20,7 @@ import java.util.ArrayList;
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;
2018-07-15 10:00:00 +10:00
import org.bukkit.craftbukkit.block.CraftBlockState;
2019-04-23 12:00:00 +10:00
@@ -85,6 +86,8 @@ public abstract class World implements IIBlockAccess, GeneratorAccess, AutoClose
public boolean populating;
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;
}
2019-04-23 12:00:00 +10:00
@@ -140,6 +143,7 @@ public abstract class World implements IIBlockAccess, GeneratorAccess, AutoClose
public void c(WorldBorder worldborder, double d0) {}
2016-03-06 14:36:33 +11:00
});
2016-03-01 11:23:45 +11:00
// 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
}
2019-04-23 12:00:00 +10:00
@Override
@@ -612,6 +616,7 @@ public abstract class World implements IIBlockAccess, GeneratorAccess, AutoClose
GameProfilerFiller gameprofilerfiller = this.getMethodProfiler();
2013-02-26 12:21:40 -05:00
2019-04-23 12:00:00 +10:00
gameprofilerfiller.enter("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);
2019-04-23 12:00:00 +10:00
@@ -632,6 +637,7 @@ public abstract class World implements IIBlockAccess, GeneratorAccess, AutoClose
gameprofilerfiller.a(() -> {
return String.valueOf(TileEntityTypes.a(tileentity.q()));
2017-08-03 23:00:00 +10:00
});
2014-11-26 08:27:08 +11:00
+ tileentity.tickTimer.startTiming(); // Spigot
2018-12-13 11:00:00 +11:00
((ITickable) tileentity).tick();
2019-04-23 12:00:00 +10:00
gameprofilerfiller.exit();
} catch (Throwable throwable) {
@@ -641,6 +647,11 @@ public abstract class World implements IIBlockAccess, GeneratorAccess, AutoClose
tileentity.a(crashreportsystemdetails);
throw new ReportedException(crashreport);
2014-11-26 08:27:08 +11:00
}
+ // Spigot start
+ finally {
+ tileentity.tickTimer.stopTiming();
+ }
+ // Spigot end
}
}
2013-02-26 12:21:40 -05:00
2019-04-23 12:00:00 +10:00
@@ -653,6 +664,8 @@ public abstract class World implements IIBlockAccess, GeneratorAccess, AutoClose
2013-02-26 12:21:40 -05:00
}
}
+ timings.tileEntityTick.stopTiming(); // Spigot
+ timings.tileEntityPending.startTiming(); // Spigot
2019-04-23 12:00:00 +10:00
this.tickingTileEntities = false;
gameprofilerfiller.exitEnter("pendingBlockEntities");
if (!this.tileEntityListPending.isEmpty()) {
@@ -685,11 +698,16 @@ public abstract class World implements IIBlockAccess, GeneratorAccess, AutoClose
this.tileEntityListPending.clear();
2013-02-26 12:21:40 -05:00
}
+ timings.tileEntityPending.stopTiming(); // Spigot
2019-04-23 12:00:00 +10:00
gameprofilerfiller.exit();
2013-02-26 12:21:40 -05:00
}
2017-05-19 21:00:22 +10:00
2019-04-23 12:00:00 +10:00
public void a(Consumer<Entity> consumer, Entity entity) {
try {
+ // Spigot start
+ SpigotTimings.tickEntityTimer.startTiming();
+ entity.tickTimer.startTiming();
+ // Spigot end
consumer.accept(entity);
} catch (Throwable throwable) {
CrashReport crashreport = CrashReport.a(throwable, "Ticking entity");
@@ -698,6 +716,12 @@ public abstract class World implements IIBlockAccess, GeneratorAccess, AutoClose
entity.appendEntityCrashDetails(crashreportsystemdetails);
throw new ReportedException(crashreport);
2013-02-26 12:21:40 -05:00
}
2019-04-23 12:00:00 +10:00
+ // Spigot start
+ finally {
+ entity.tickTimer.stopTiming();
+ SpigotTimings.tickEntityTimer.startTiming();
+ }
+ // Spigot end
2013-02-26 12:21:40 -05:00
}
2019-04-23 12:00:00 +10:00
public boolean a(AxisAlignedBB axisalignedbb) {
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
2019-04-27 10:30:04 +10:00
index 1faa64734..0efb614a2 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
2019-04-23 12:00:00 +10:00
@@ -37,6 +37,7 @@ import org.bukkit.Bukkit;
2016-03-01 08:33:06 +11:00
2019-04-23 12:00:00 +10:00
import org.bukkit.WeatherType;
import org.bukkit.block.BlockState;
+import org.bukkit.craftbukkit.SpigotTimings; // Spigot
import org.bukkit.craftbukkit.event.CraftEventFactory;
import org.bukkit.craftbukkit.util.HashTreeSet;
2013-06-08 09:21:38 +10:00
2019-04-24 10:30:28 +10:00
@@ -264,15 +265,21 @@ public class WorldServer extends World {
2019-04-23 12:00:00 +10:00
gameprofilerfiller.exitEnter("chunkSource");
this.getChunkProvider().tick(booleansupplier);
gameprofilerfiller.exitEnter("tickPending");
2013-06-08 09:21:38 +10:00
+ timings.doTickPending.startTiming(); // Spigot
2019-04-23 12:00:00 +10:00
if (this.worldData.getType() != WorldType.DEBUG_ALL_BLOCK_STATES) {
this.nextTickListBlock.a();
this.nextTickListFluid.a();
}
2013-06-08 09:21:38 +10:00
+ timings.doTickPending.stopTiming(); // Spigot
2019-04-23 12:00:00 +10:00
gameprofilerfiller.exitEnter("village");
2013-06-08 09:21:38 +10:00
+ timings.doVillages.startTiming(); // Spigot
this.siegeManager.a();
+ timings.doVillages.stopTiming(); // Spigot
2019-04-23 12:00:00 +10:00
gameprofilerfiller.exitEnter("portalForcer");
2013-06-08 09:21:38 +10:00
+ 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
2019-04-23 12:00:00 +10:00
gameprofilerfiller.exitEnter("raid");
this.c.a();
if (this.mobSpawnerTrader != null) {
2019-04-24 10:30:28 +10:00
@@ -280,7 +287,9 @@ public class WorldServer extends World {
2019-04-23 12:00:00 +10:00
}
gameprofilerfiller.exitEnter("blockEvents");
2013-06-08 09:21:38 +10:00
+ timings.doSounds.startTiming(); // Spigot
2019-04-23 12:00:00 +10:00
this.ae();
2016-03-01 08:33:06 +11:00
+ timings.doSounds.stopTiming(); // Spigot
2019-04-23 12:00:00 +10:00
this.ticking = false;
gameprofilerfiller.exitEnter("entities");
boolean flag3 = true || !this.players.isEmpty() || !this.getForceLoadedChunks().isEmpty(); // CraftBukkit - this prevents entity cleanup, other issues on servers with no players
2019-04-24 10:30:28 +10:00
@@ -290,6 +299,7 @@ public class WorldServer extends World {
2019-04-23 12:00:00 +10:00
}
2015-02-28 11:36:22 +00:00
2019-04-23 12:00:00 +10:00
if (flag3 || this.emptyTime++ < 300) {
+ timings.tickEntities.startTiming(); // Spigot
this.worldProvider.l();
gameprofilerfiller.enter("global");
2019-04-24 10:30:28 +10:00
@@ -315,6 +325,7 @@ public class WorldServer extends World {
2019-04-23 12:00:00 +10:00
this.tickingEntities = true;
ObjectIterator objectiterator = this.entitiesById.int2ObjectEntrySet().iterator();
+ timings.entityTick.startTiming(); // Spigot
while (objectiterator.hasNext()) {
Entry<Entity> entry = (Entry) objectiterator.next();
Entity entity1 = (Entity) entry.getValue();
2019-04-24 10:30:28 +10:00
@@ -353,6 +364,7 @@ public class WorldServer extends World {
2019-04-23 12:00:00 +10:00
gameprofilerfiller.exit();
}
+ timings.entityTick.stopTiming(); // Spigot
this.tickingEntities = false;
2019-04-24 10:30:28 +10:00
@@ -361,6 +373,7 @@ public class WorldServer extends World {
2019-04-23 12:00:00 +10:00
}
gameprofilerfiller.exit();
+ timings.tickEntities.stopTiming(); // Spigot
this.tickBlockEntities();
}
2013-02-26 12:21:40 -05:00
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
2019-04-28 11:41:06 +10:00
index 286379122..9cd50e16c 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
2019-04-28 11:41:06 +10:00
@@ -1887,6 +1887,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
2019-04-25 12:00:00 +10:00
index 000000000..153be935e
2013-02-26 12:21:40 -05:00
--- /dev/null
+++ b/src/main/java/org/bukkit/craftbukkit/SpigotTimings.java
2019-04-23 15:12:43 +10:00
@@ -0,0 +1,163 @@
2013-02-26 12:21:40 -05:00
+package org.bukkit.craftbukkit;
+
+import java.util.HashMap;
2019-04-23 15:12:43 +10:00
+import net.minecraft.server.Entity;
+import net.minecraft.server.TileEntity;
+import net.minecraft.server.World;
2013-08-03 19:39:35 +10:00
+import org.bukkit.craftbukkit.scheduler.CraftTask;
2019-04-23 15:12:43 +10:00
+import org.bukkit.plugin.java.JavaPluginLoader;
+import org.bukkit.scheduler.BukkitTask;
+import org.spigotmc.CustomTimingsHandler;
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");
2018-10-27 17:44:13 +11:00
+ public static final CustomTimingsHandler playerConnectionTimer = new CustomTimingsHandler("** PlayerConnection");
2013-02-26 12:21:40 -05:00
+ public static final CustomTimingsHandler tickablesTimer = new CustomTimingsHandler("Tickables");
+ public static final CustomTimingsHandler schedulerTimer = new CustomTimingsHandler("Scheduler");
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 {
+ 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 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 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");
+ 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");
+ 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/scheduler/CraftScheduler.java b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java
2019-04-28 11:41:06 +10:00
index d694a2a24..b90979c7b 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
2019-04-28 11:41:06 +10:00
@@ -390,7 +390,9 @@ public class CraftScheduler implements BukkitScheduler {
2014-07-07 18:59:02 -04:00
if (task.isSync()) {
2018-06-20 13:18:48 +10:00
currentTask = task;
2014-07-07 18:59:02 -04:00
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
2019-04-25 12:00:00 +10:00
index a85fbbb69..3f55381c1 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
2018-11-23 12:11:41 +11:00
@@ -2,11 +2,13 @@ package org.bukkit.craftbukkit.scheduler;
2013-02-26 12:21:40 -05:00
2018-11-23 12:11:41 +11:00
import java.util.function.Consumer;
2013-02-26 12:21:40 -05:00
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;
2018-03-30 08:44:10 +11:00
public static final int ERROR = 0;
2018-11-23 12:11:41 +11:00
@@ -29,6 +31,7 @@ class CraftTask implements BukkitTask, Runnable {
2013-02-26 12:21:40 -05:00
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() {
2018-03-30 08:44:10 +11:00
this(null, null, CraftTask.NO_REPEATING, CraftTask.NO_REPEATING);
2013-02-26 12:21:40 -05:00
}
2018-11-23 12:11:41 +11:00
@@ -54,6 +57,7 @@ class CraftTask implements BukkitTask, Runnable {
}
2014-07-07 18:59:02 -04:00
this.id = id;
this.period = period;
2018-11-23 12:11:41 +11:00
+ this.timings = this.isSync() ? SpigotTimings.getPluginTaskTimings(this, period) : null; // Spigot
2013-08-03 19:39:35 +10:00
}
2018-11-23 12:11:41 +11:00
@Override
@@ -127,4 +131,10 @@ class CraftTask implements BukkitTask, Runnable {
2018-03-30 08:44:10 +11:00
setPeriod(CraftTask.CANCEL);
2014-07-07 18:59:02 -04:00
return true;
2013-08-03 19:39:35 +10:00
}
2014-07-07 18:59:02 -04:00
+
+ // Spigot start
+ public String getTaskName() {
2018-11-23 14:22:14 +11:00
+ return (getTaskClass() == null) ? "Unknown" : getTaskClass().getName();
2014-07-07 18:59:02 -04:00
+ }
+ // Spigot end
}
2013-02-26 12:21:40 -05:00
--
2019-04-23 09:33:25 +10:00
2.20.1
2013-02-26 12:21:40 -05:00