mirror of
https://hub.spigotmc.org/stash/scm/spigot/spigot.git
synced 2025-08-05 16:48:51 +00:00
836 lines
39 KiB
Diff
836 lines
39 KiB
Diff
From 638ccd1e6396da6b58cc60744a760a1711417f8e Mon Sep 17 00:00:00 2001
|
|
From: Aikar <aikar@aikar.co>
|
|
Date: Thu, 10 Jan 2013 00:18:11 -0500
|
|
Subject: [PATCH] Spigot Timings
|
|
|
|
Overhauls the Timings System adding performance tracking all around the Minecraft Server
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java
|
|
index 684fa0753..3e719d5cd 100644
|
|
--- a/src/main/java/net/minecraft/server/ChunkProviderServer.java
|
|
+++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java
|
|
@@ -123,11 +123,13 @@ public class ChunkProviderServer implements IChunkProvider {
|
|
return chunk;
|
|
} else {
|
|
try {
|
|
+ world.timings.syncChunkLoadTimer.startTiming(); // Spigot
|
|
chunk = (Chunk) this.generateChunk(i, j).get();
|
|
return chunk;
|
|
} catch (ExecutionException | InterruptedException interruptedexception) {
|
|
throw this.a(i, j, (Throwable) interruptedexception);
|
|
}
|
|
+ finally { world.timings.syncChunkLoadTimer.stopTiming(); } // Spigot
|
|
}
|
|
}
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/ChunkRegionLoader.java b/src/main/java/net/minecraft/server/ChunkRegionLoader.java
|
|
index 0989ebd88..6a99c9928 100644
|
|
--- a/src/main/java/net/minecraft/server/ChunkRegionLoader.java
|
|
+++ b/src/main/java/net/minecraft/server/ChunkRegionLoader.java
|
|
@@ -120,7 +120,9 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver {
|
|
// CraftBukkit start - Add async variant, provide compatibility
|
|
@Nullable
|
|
public synchronized Chunk a(GeneratorAccess generatoraccess, int i, int j, Consumer<Chunk> consumer) throws IOException {
|
|
+ generatoraccess.getMinecraftWorld().timings.syncChunkLoadDataTimer.startTiming(); // Spigot
|
|
Object[] data = loadChunk(generatoraccess, i, j, consumer);
|
|
+ generatoraccess.getMinecraftWorld().timings.syncChunkLoadDataTimer.stopTiming(); // Spigot
|
|
if (data != null) {
|
|
Chunk chunk = (Chunk) data[0];
|
|
NBTTagCompound nbttagcompound = (NBTTagCompound) data[1];
|
|
@@ -653,6 +655,7 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver {
|
|
public void loadEntities(NBTTagCompound nbttagcompound, Chunk chunk) {
|
|
NBTTagList nbttaglist = nbttagcompound.getList("Entities", 10);
|
|
World world = chunk.getWorld();
|
|
+ world.timings.syncChunkLoadEntitiesTimer.startTiming(); // Spigot
|
|
|
|
for (int i = 0; i < nbttaglist.size(); ++i) {
|
|
NBTTagCompound nbttagcompound1 = nbttaglist.getCompound(i);
|
|
@@ -661,6 +664,8 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver {
|
|
chunk.f(true);
|
|
}
|
|
|
|
+ world.timings.syncChunkLoadEntitiesTimer.stopTiming(); // Spigot
|
|
+ world.timings.syncChunkLoadTileEntitiesTimer.startTiming(); // Spigot
|
|
NBTTagList nbttaglist1 = nbttagcompound.getList("TileEntities", 10);
|
|
|
|
for (int j = 0; j < nbttaglist1.size(); ++j) {
|
|
@@ -677,6 +682,8 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver {
|
|
}
|
|
}
|
|
}
|
|
+ world.timings.syncChunkLoadTileEntitiesTimer.stopTiming(); // Spigot
|
|
+ world.timings.syncChunkLoadTileTicksTimer.startTiming(); // Spigot
|
|
|
|
if (nbttagcompound.hasKeyOfType("TileTicks", 9) && world.I() instanceof TickListServer) {
|
|
((TickListServer) world.I()).a(nbttagcompound.getList("TileTicks", 10));
|
|
@@ -685,6 +692,7 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver {
|
|
if (nbttagcompound.hasKeyOfType("LiquidTicks", 9) && world.H() instanceof TickListServer) {
|
|
((TickListServer) world.H()).a(nbttagcompound.getList("LiquidTicks", 10));
|
|
}
|
|
+ world.timings.syncChunkLoadTileTicksTimer.stopTiming(); // Spigot
|
|
|
|
}
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/DedicatedServer.java b/src/main/java/net/minecraft/server/DedicatedServer.java
|
|
index b8a4b0bdd..dbd74d384 100644
|
|
--- a/src/main/java/net/minecraft/server/DedicatedServer.java
|
|
+++ b/src/main/java/net/minecraft/server/DedicatedServer.java
|
|
@@ -29,6 +29,7 @@ import org.apache.logging.log4j.Level;
|
|
|
|
import org.bukkit.command.CommandSender;
|
|
import org.bukkit.craftbukkit.LoggerOutputStream;
|
|
+import org.bukkit.craftbukkit.SpigotTimings; // Spigot
|
|
import org.bukkit.event.server.ServerCommandEvent;
|
|
import org.bukkit.craftbukkit.util.Waitable;
|
|
import org.bukkit.event.server.RemoteServerCommandEvent;
|
|
@@ -409,6 +410,7 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer
|
|
}
|
|
|
|
public void aW() {
|
|
+ SpigotTimings.serverCommandTimer.startTiming(); // Spigot
|
|
while (!this.serverCommandQueue.isEmpty()) {
|
|
ServerCommand servercommand = (ServerCommand) this.serverCommandQueue.remove(0);
|
|
|
|
@@ -423,6 +425,7 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer
|
|
// CraftBukkit end
|
|
}
|
|
|
|
+ SpigotTimings.serverCommandTimer.stopTiming(); // Spigot
|
|
}
|
|
|
|
public boolean S() {
|
|
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
|
|
index 015c6ab69..e7f989686 100644
|
|
--- a/src/main/java/net/minecraft/server/Entity.java
|
|
+++ b/src/main/java/net/minecraft/server/Entity.java
|
|
@@ -29,6 +29,7 @@ import org.bukkit.command.CommandSender;
|
|
import org.bukkit.entity.Hanging;
|
|
import org.bukkit.entity.LivingEntity;
|
|
import org.bukkit.entity.Vehicle;
|
|
+import org.spigotmc.CustomTimingsHandler; // Spigot
|
|
import org.bukkit.event.entity.EntityCombustByEntityEvent;
|
|
import org.bukkit.event.hanging.HangingBreakByEntityEvent;
|
|
import org.bukkit.event.vehicle.VehicleBlockCollisionEvent;
|
|
@@ -157,6 +158,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener {
|
|
public boolean valid;
|
|
public org.bukkit.projectiles.ProjectileSource projectileSource; // For projectiles only
|
|
public boolean forceExplosionKnockback; // SPIGOT-949
|
|
+ public CustomTimingsHandler tickTimer = org.bukkit.craftbukkit.SpigotTimings.getEntityTimings(this); // Spigot
|
|
|
|
public float getBukkitYaw() {
|
|
return this.yaw;
|
|
@@ -525,6 +527,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener {
|
|
}
|
|
|
|
public void move(EnumMoveType enummovetype, double d0, double d1, double d2) {
|
|
+ org.bukkit.craftbukkit.SpigotTimings.entityMoveTimer.startTiming(); // Spigot
|
|
if (this.noclip) {
|
|
this.a(this.getBoundingBox().d(d0, d1, d2));
|
|
this.recalcPosition();
|
|
@@ -893,6 +896,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener {
|
|
|
|
this.world.methodProfiler.e();
|
|
}
|
|
+ org.bukkit.craftbukkit.SpigotTimings.entityMoveTimer.stopTiming(); // Spigot
|
|
}
|
|
|
|
protected float ab() {
|
|
diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java
|
|
index caccb1a15..6f8572573 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityLiving.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
|
|
@@ -32,6 +32,8 @@ import org.bukkit.event.entity.EntityTeleportEvent;
|
|
import org.bukkit.event.player.PlayerItemConsumeEvent;
|
|
// CraftBukkit end
|
|
|
|
+import org.bukkit.craftbukkit.SpigotTimings; // Spigot
|
|
+
|
|
public abstract class EntityLiving extends Entity {
|
|
|
|
private static final Logger a = LogManager.getLogger();
|
|
@@ -1975,6 +1977,7 @@ public abstract class EntityLiving extends Entity {
|
|
}
|
|
|
|
public void tick() {
|
|
+ SpigotTimings.timerEntityBaseTick.startTiming(); // Spigot
|
|
super.tick();
|
|
this.cV();
|
|
this.o();
|
|
@@ -2048,7 +2051,9 @@ public abstract class EntityLiving extends Entity {
|
|
}
|
|
}
|
|
|
|
+ SpigotTimings.timerEntityBaseTick.stopTiming(); // Spigot
|
|
this.k();
|
|
+ SpigotTimings.timerEntityTickRest.startTiming(); // Spigot
|
|
double d0 = this.locX - this.lastX;
|
|
double d1 = this.locZ - this.lastZ;
|
|
float f = (float) (d0 * d0 + d1 * d1);
|
|
@@ -2125,6 +2130,7 @@ public abstract class EntityLiving extends Entity {
|
|
this.bv = 0;
|
|
}
|
|
|
|
+ SpigotTimings.timerEntityTickRest.stopTiming(); // Spigot
|
|
}
|
|
|
|
protected float e(float f, float f1) {
|
|
@@ -2194,6 +2200,7 @@ public abstract class EntityLiving extends Entity {
|
|
}
|
|
|
|
this.world.methodProfiler.a("ai");
|
|
+ SpigotTimings.timerEntityAI.startTiming(); // Spigot
|
|
if (this.isFrozen()) {
|
|
this.bg = false;
|
|
this.bh = 0.0F;
|
|
@@ -2204,6 +2211,7 @@ public abstract class EntityLiving extends Entity {
|
|
this.doTick();
|
|
this.world.methodProfiler.e();
|
|
}
|
|
+ SpigotTimings.timerEntityAI.stopTiming(); // Spigot
|
|
|
|
this.world.methodProfiler.e();
|
|
this.world.methodProfiler.a("jump");
|
|
@@ -2228,7 +2236,9 @@ public abstract class EntityLiving extends Entity {
|
|
this.n();
|
|
AxisAlignedBB axisalignedbb = this.getBoundingBox();
|
|
|
|
+ SpigotTimings.timerEntityAIMove.startTiming(); // Spigot
|
|
this.a(this.bh, this.bi, this.bj);
|
|
+ SpigotTimings.timerEntityAIMove.stopTiming(); // Spigot
|
|
this.world.methodProfiler.e();
|
|
this.world.methodProfiler.a("push");
|
|
if (this.bw > 0) {
|
|
@@ -2236,7 +2246,9 @@ public abstract class EntityLiving extends Entity {
|
|
this.a(axisalignedbb, this.getBoundingBox());
|
|
}
|
|
|
|
+ SpigotTimings.timerEntityAICollision.startTiming(); // Spigot
|
|
this.cN();
|
|
+ SpigotTimings.timerEntityAICollision.stopTiming(); // Spigot
|
|
this.world.methodProfiler.e();
|
|
}
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
index 55022c848..de497fa50 100644
|
|
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
@@ -62,6 +62,7 @@ import org.bukkit.Bukkit;
|
|
import org.bukkit.craftbukkit.CraftServer;
|
|
import org.bukkit.craftbukkit.Main;
|
|
// CraftBukkit end
|
|
+import org.bukkit.craftbukkit.SpigotTimings; // Spigot
|
|
|
|
public abstract class MinecraftServer implements IAsyncTaskHandler, IMojangStatistics, ICommandListener, Runnable {
|
|
|
|
@@ -768,6 +769,7 @@ public abstract class MinecraftServer implements IAsyncTaskHandler, IMojangStati
|
|
public void u() {}
|
|
|
|
protected void v() {
|
|
+ SpigotTimings.serverTickTimer.startTiming(); // Spigot
|
|
long i = SystemUtils.c();
|
|
|
|
++this.ticks;
|
|
@@ -793,10 +795,12 @@ public abstract class MinecraftServer implements IAsyncTaskHandler, IMojangStati
|
|
}
|
|
|
|
if (autosavePeriod > 0 && this.ticks % autosavePeriod == 0) { // CraftBukkit
|
|
+ SpigotTimings.worldSaveTimer.startTiming(); // Spigot
|
|
this.methodProfiler.a("save");
|
|
this.s.savePlayers();
|
|
this.saveChunks(true);
|
|
this.methodProfiler.e();
|
|
+ SpigotTimings.worldSaveTimer.stopTiming(); // Spigot
|
|
}
|
|
|
|
this.methodProfiler.a("snooper");
|
|
@@ -815,10 +819,14 @@ public abstract class MinecraftServer implements IAsyncTaskHandler, IMojangStati
|
|
this.ap = this.ap * 0.8F + (float) l / 1000000.0F * 0.19999999F;
|
|
this.methodProfiler.e();
|
|
this.methodProfiler.e();
|
|
+ SpigotTimings.serverTickTimer.stopTiming(); // Spigot
|
|
+ org.spigotmc.CustomTimingsHandler.tick(); // Spigot
|
|
}
|
|
|
|
public void w() {
|
|
+ SpigotTimings.schedulerTimer.startTiming(); // Spigot
|
|
this.server.getScheduler().mainThreadHeartbeat(this.ticks); // CraftBukkit
|
|
+ SpigotTimings.schedulerTimer.stopTiming(); // Spigot
|
|
this.methodProfiler.a("jobs");
|
|
|
|
FutureTask futuretask;
|
|
@@ -828,17 +836,24 @@ public abstract class MinecraftServer implements IAsyncTaskHandler, IMojangStati
|
|
}
|
|
|
|
this.methodProfiler.c("commandFunctions");
|
|
+ SpigotTimings.commandFunctionsTimer.startTiming(); // Spigot
|
|
this.getFunctionData().Y_();
|
|
+ SpigotTimings.commandFunctionsTimer.stopTiming(); // Spigot
|
|
this.methodProfiler.c("levels");
|
|
|
|
// CraftBukkit start
|
|
// Run tasks that are waiting on processing
|
|
+ SpigotTimings.processQueueTimer.startTiming(); // Spigot
|
|
while (!processQueue.isEmpty()) {
|
|
processQueue.remove().run();
|
|
}
|
|
+ SpigotTimings.processQueueTimer.stopTiming(); // Spigot
|
|
|
|
+ SpigotTimings.chunkIOTickTimer.startTiming(); // Spigot
|
|
org.bukkit.craftbukkit.chunkio.ChunkIOExecutor.tick();
|
|
+ SpigotTimings.chunkIOTickTimer.stopTiming(); // Spigot
|
|
|
|
+ SpigotTimings.timeUpdateTimer.startTiming(); // Spigot
|
|
// Send time updates to everyone, it will get the right time from the world the player is in.
|
|
if (this.ticks % 20 == 0) {
|
|
for (int i = 0; i < this.getPlayerList().players.size(); ++i) {
|
|
@@ -846,6 +861,7 @@ public abstract class MinecraftServer implements IAsyncTaskHandler, IMojangStati
|
|
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;
|
|
|
|
@@ -871,7 +887,9 @@ public abstract class MinecraftServer implements IAsyncTaskHandler, IMojangStati
|
|
CrashReport crashreport;
|
|
|
|
try {
|
|
+ worldserver.timings.doTick.startTiming(); // Spigot
|
|
worldserver.doTick();
|
|
+ worldserver.timings.doTick.stopTiming(); // Spigot
|
|
} catch (Throwable throwable) {
|
|
crashreport = CrashReport.a(throwable, "Exception ticking world");
|
|
worldserver.a(crashreport);
|
|
@@ -879,7 +897,9 @@ public abstract class MinecraftServer implements IAsyncTaskHandler, IMojangStati
|
|
}
|
|
|
|
try {
|
|
+ worldserver.timings.tickEntities.startTiming(); // Spigot
|
|
worldserver.tickEntities();
|
|
+ worldserver.timings.tickEntities.stopTiming(); // Spigot
|
|
} catch (Throwable throwable1) {
|
|
crashreport = CrashReport.a(throwable1, "Exception ticking world entities");
|
|
worldserver.a(crashreport);
|
|
@@ -888,7 +908,9 @@ public abstract class MinecraftServer implements IAsyncTaskHandler, IMojangStati
|
|
|
|
this.methodProfiler.e();
|
|
this.methodProfiler.a("tracker");
|
|
+ worldserver.timings.tracker.startTiming(); // Spigot
|
|
worldserver.getTracker().updatePlayers();
|
|
+ worldserver.timings.tracker.stopTiming(); // Spigot
|
|
this.methodProfiler.e();
|
|
this.methodProfiler.e();
|
|
}
|
|
@@ -897,14 +919,20 @@ public abstract class MinecraftServer implements IAsyncTaskHandler, IMojangStati
|
|
}
|
|
|
|
this.methodProfiler.c("connection");
|
|
+ SpigotTimings.connectionTimer.startTiming(); // Spigot
|
|
this.getServerConnection().c();
|
|
+ SpigotTimings.connectionTimer.stopTiming(); // Spigot
|
|
this.methodProfiler.c("players");
|
|
+ SpigotTimings.playerListTimer.startTiming(); // Spigot
|
|
this.s.tick();
|
|
+ SpigotTimings.playerListTimer.stopTiming(); // Spigot
|
|
this.methodProfiler.c("tickables");
|
|
|
|
+ SpigotTimings.tickablesTimer.startTiming(); // Spigot
|
|
for (i = 0; i < this.l.size(); ++i) {
|
|
((ITickable) this.l.get(i)).Y_();
|
|
}
|
|
+ SpigotTimings.tickablesTimer.stopTiming(); // Spigot
|
|
|
|
this.methodProfiler.e();
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
|
|
index 94a4cc7f1..66420735c 100644
|
|
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
|
|
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
|
|
@@ -1559,6 +1559,7 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
|
|
// CraftBukkit end
|
|
|
|
private void handleCommand(String s) {
|
|
+ org.bukkit.craftbukkit.SpigotTimings.playerCommandTimer.startTiming(); // Spigot
|
|
// CraftBukkit start - whole method
|
|
this.LOGGER.info(this.player.getName() + " issued server command: " + s);
|
|
|
|
@@ -1568,6 +1569,7 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
|
|
this.server.getPluginManager().callEvent(event);
|
|
|
|
if (event.isCancelled()) {
|
|
+ org.bukkit.craftbukkit.SpigotTimings.playerCommandTimer.stopTiming(); // Spigot
|
|
return;
|
|
}
|
|
|
|
@@ -1579,6 +1581,8 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
|
|
player.sendMessage(org.bukkit.ChatColor.RED + "An internal error occurred while attempting to perform this command");
|
|
java.util.logging.Logger.getLogger(PlayerConnection.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
|
return;
|
|
+ } finally {
|
|
+ org.bukkit.craftbukkit.SpigotTimings.playerCommandTimer.stopTiming(); // Spigot
|
|
}
|
|
// this.minecraftServer.getCommandDispatcher().a(this.player.getCommandListener(), s);
|
|
// CraftBukkit end
|
|
diff --git a/src/main/java/net/minecraft/server/TileEntity.java b/src/main/java/net/minecraft/server/TileEntity.java
|
|
index cde437933..331029284 100644
|
|
--- a/src/main/java/net/minecraft/server/TileEntity.java
|
|
+++ b/src/main/java/net/minecraft/server/TileEntity.java
|
|
@@ -4,10 +4,12 @@ import javax.annotation.Nullable;
|
|
import org.apache.logging.log4j.LogManager;
|
|
import org.apache.logging.log4j.Logger;
|
|
|
|
+import org.spigotmc.CustomTimingsHandler; // Spigot
|
|
import org.bukkit.inventory.InventoryHolder; // CraftBukkit
|
|
|
|
public abstract class TileEntity {
|
|
|
|
+ public CustomTimingsHandler tickTimer = org.bukkit.craftbukkit.SpigotTimings.getTileEntityTimings(this); // Spigot
|
|
private static final Logger a = LogManager.getLogger();
|
|
private final TileEntityTypes<?> e;
|
|
protected World world;
|
|
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
|
|
index 882fa397f..2a13b29f4 100644
|
|
--- a/src/main/java/net/minecraft/server/World.java
|
|
+++ b/src/main/java/net/minecraft/server/World.java
|
|
@@ -20,6 +20,7 @@ import com.google.common.collect.Maps;
|
|
import java.util.Map;
|
|
import org.bukkit.Bukkit;
|
|
import org.bukkit.block.BlockState;
|
|
+import org.bukkit.craftbukkit.SpigotTimings; // Spigot
|
|
import org.bukkit.craftbukkit.CraftServer;
|
|
import org.bukkit.craftbukkit.CraftWorld;
|
|
import org.bukkit.craftbukkit.block.CraftBlockState;
|
|
@@ -101,6 +102,8 @@ public abstract class World implements GeneratorAccess, IIBlockAccess, AutoClose
|
|
private int tickPosition;
|
|
public final org.spigotmc.SpigotWorldConfig spigotConfig; // Spigot
|
|
|
|
+ public final SpigotTimings.WorldTimingsHandler timings; // Spigot
|
|
+
|
|
public CraftWorld getWorld() {
|
|
return this.world;
|
|
}
|
|
@@ -160,6 +163,7 @@ public abstract class World implements GeneratorAccess, IIBlockAccess, AutoClose
|
|
});
|
|
this.getServer().addWorld(this.world);
|
|
// CraftBukkit end
|
|
+ timings = new SpigotTimings.WorldTimingsHandler(this); // Spigot - code below can generate new world and access timings
|
|
}
|
|
|
|
public GeneratorAccess b() {
|
|
@@ -1061,6 +1065,7 @@ public abstract class World implements GeneratorAccess, IIBlockAccess, AutoClose
|
|
CrashReportSystemDetails crashreportsystemdetails1;
|
|
CrashReport crashreport1;
|
|
|
|
+ timings.entityTick.startTiming(); // Spigot
|
|
// 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);
|
|
@@ -1078,7 +1083,9 @@ public abstract class World implements GeneratorAccess, IIBlockAccess, AutoClose
|
|
this.methodProfiler.a("tick");
|
|
if (!entity.dead && !(entity instanceof EntityPlayer)) {
|
|
try {
|
|
+ SpigotTimings.tickEntityTimer.startTiming(); // Spigot
|
|
this.g(entity);
|
|
+ SpigotTimings.tickEntityTimer.stopTiming(); // Spigot
|
|
} catch (Throwable throwable1) {
|
|
crashreport1 = CrashReport.a(throwable1, "Ticking entity");
|
|
crashreportsystemdetails1 = crashreport1.a("Entity being ticked");
|
|
@@ -1104,7 +1111,9 @@ public abstract class World implements GeneratorAccess, IIBlockAccess, AutoClose
|
|
this.methodProfiler.e();
|
|
}
|
|
|
|
+ timings.entityTick.stopTiming(); // Spigot
|
|
this.methodProfiler.c("blockEntities");
|
|
+ timings.tileEntityTick.startTiming(); // Spigot
|
|
if (!this.tileEntityListUnload.isEmpty()) {
|
|
this.tileEntityListTick.removeAll(this.tileEntityListUnload);
|
|
this.tileEntityList.removeAll(this.tileEntityListUnload);
|
|
@@ -1125,6 +1134,7 @@ public abstract class World implements GeneratorAccess, IIBlockAccess, AutoClose
|
|
this.methodProfiler.a(() -> {
|
|
return String.valueOf(TileEntityTypes.a(tileentity.C()));
|
|
});
|
|
+ tileentity.tickTimer.startTiming(); // Spigot
|
|
((ITickable) tileentity).Y_();
|
|
this.methodProfiler.e();
|
|
} catch (Throwable throwable2) {
|
|
@@ -1133,6 +1143,11 @@ public abstract class World implements GeneratorAccess, IIBlockAccess, AutoClose
|
|
tileentity.a(crashreportsystemdetails1);
|
|
throw new ReportedException(crashreport1);
|
|
}
|
|
+ // Spigot start
|
|
+ finally {
|
|
+ tileentity.tickTimer.stopTiming();
|
|
+ }
|
|
+ // Spigot end
|
|
}
|
|
}
|
|
|
|
@@ -1145,6 +1160,8 @@ public abstract class World implements GeneratorAccess, IIBlockAccess, AutoClose
|
|
}
|
|
}
|
|
|
|
+ timings.tileEntityTick.stopTiming(); // Spigot
|
|
+ timings.tileEntityPending.startTiming(); // Spigot
|
|
this.J = false;
|
|
this.methodProfiler.c("pendingBlockEntities");
|
|
if (!this.c.isEmpty()) {
|
|
@@ -1177,6 +1194,7 @@ public abstract class World implements GeneratorAccess, IIBlockAccess, AutoClose
|
|
this.c.clear();
|
|
}
|
|
|
|
+ timings.tileEntityPending.stopTiming(); // Spigot
|
|
this.methodProfiler.e();
|
|
this.methodProfiler.e();
|
|
}
|
|
@@ -1231,6 +1249,7 @@ public abstract class World implements GeneratorAccess, IIBlockAccess, AutoClose
|
|
}
|
|
// CraftBukkit end
|
|
|
|
+ entity.tickTimer.startTiming(); // Spigot
|
|
entity.N = entity.locX;
|
|
entity.O = entity.locY;
|
|
entity.P = entity.locZ;
|
|
@@ -1301,6 +1320,7 @@ public abstract class World implements GeneratorAccess, IIBlockAccess, AutoClose
|
|
}
|
|
}
|
|
}
|
|
+ entity.tickTimer.stopTiming(); // Spigot
|
|
|
|
}
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
|
|
index a9a257b95..4d5bede24 100644
|
|
--- a/src/main/java/net/minecraft/server/WorldServer.java
|
|
+++ b/src/main/java/net/minecraft/server/WorldServer.java
|
|
@@ -274,11 +274,14 @@ public class WorldServer extends World implements IAsyncTaskHandler {
|
|
// CraftBukkit start - Only call spawner if we have players online and the world allows for mobs or animals
|
|
long time = this.worldData.getTime();
|
|
if (this.getGameRules().getBoolean("doMobSpawning") && this.worldData.getType() != WorldType.DEBUG_ALL_BLOCK_STATES && (this.allowMonsters || this.allowAnimals) && (this instanceof WorldServer && this.players.size() > 0)) {
|
|
+ timings.mobSpawn.startTiming(); // Spigot
|
|
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);
|
|
this.getChunkProviderServer().a(this, this.allowMonsters && (this.ticksPerMonsterSpawns != 0 && time % this.ticksPerMonsterSpawns == 0L), this.allowAnimals && (this.ticksPerAnimalSpawns != 0 && time % this.ticksPerAnimalSpawns == 0L));
|
|
+ timings.mobSpawn.stopTiming(); // Spigot
|
|
// CraftBukkit end
|
|
}
|
|
|
|
+ timings.doChunkUnload.startTiming(); // Spigot
|
|
this.methodProfiler.c("chunkSource");
|
|
this.chunkProvider.unloadChunks();
|
|
int j = this.a(1.0F);
|
|
@@ -292,22 +295,37 @@ public class WorldServer extends World implements IAsyncTaskHandler {
|
|
this.worldData.setDayTime(this.worldData.getDayTime() + 1L);
|
|
}
|
|
|
|
+ timings.doChunkUnload.stopTiming(); // Spigot
|
|
this.methodProfiler.c("tickPending");
|
|
+ timings.doTickPending.startTiming(); // Spigot
|
|
this.p();
|
|
+ timings.doTickPending.stopTiming(); // Spigot
|
|
this.methodProfiler.c("tickBlocks");
|
|
+ timings.doTickTiles.startTiming(); // Spigot
|
|
this.l();
|
|
+ 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
|
|
this.portalTravelAgent.a(this.getTime());
|
|
+ timings.doPortalForcer.stopTiming(); // Spigot
|
|
this.methodProfiler.e();
|
|
+ timings.doSounds.startTiming(); // Spigot
|
|
this.am();
|
|
+ timings.doSounds.stopTiming(); // Spigot
|
|
this.Q = false;
|
|
|
|
+ timings.doChunkGC.startTiming();// Spigot
|
|
this.getWorld().processChunkGC(); // CraftBukkit
|
|
+ timings.doChunkGC.stopTiming(); // Spigot
|
|
}
|
|
|
|
public boolean j_() {
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
|
index 099bc9e34..b53223db1 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
|
@@ -1774,6 +1774,11 @@ public final class CraftServer implements Server {
|
|
private final Spigot spigot = new Spigot()
|
|
{
|
|
|
|
+ @Override
|
|
+ public YamlConfiguration getConfig()
|
|
+ {
|
|
+ return org.spigotmc.SpigotConfig.config;
|
|
+ }
|
|
};
|
|
|
|
public Spigot spigot()
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/SpigotTimings.java b/src/main/java/org/bukkit/craftbukkit/SpigotTimings.java
|
|
new file mode 100644
|
|
index 000000000..fa88be0db
|
|
--- /dev/null
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/SpigotTimings.java
|
|
@@ -0,0 +1,171 @@
|
|
+package org.bukkit.craftbukkit;
|
|
+
|
|
+import com.google.common.collect.Maps;
|
|
+import net.minecraft.server.*;
|
|
+import org.bukkit.plugin.java.JavaPluginLoader;
|
|
+import org.spigotmc.CustomTimingsHandler;
|
|
+import org.bukkit.scheduler.BukkitTask;
|
|
+
|
|
+import java.util.HashMap;
|
|
+import java.util.Map;
|
|
+
|
|
+import org.bukkit.craftbukkit.scheduler.CraftTask;
|
|
+
|
|
+public class SpigotTimings {
|
|
+
|
|
+ public static final CustomTimingsHandler serverTickTimer = new CustomTimingsHandler("** Full Server Tick");
|
|
+ public static final CustomTimingsHandler playerListTimer = new CustomTimingsHandler("Player List");
|
|
+ public static final CustomTimingsHandler commandFunctionsTimer = new CustomTimingsHandler("Command Functions");
|
|
+ public static final CustomTimingsHandler connectionTimer = new CustomTimingsHandler("Connection Handler");
|
|
+ public static final CustomTimingsHandler tickablesTimer = new CustomTimingsHandler("Tickables");
|
|
+ public static final CustomTimingsHandler schedulerTimer = new CustomTimingsHandler("Scheduler");
|
|
+ public static final CustomTimingsHandler chunkIOTickTimer = new CustomTimingsHandler("ChunkIOTick");
|
|
+ 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");
|
|
+
|
|
+ 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");
|
|
+
|
|
+ public static final CustomTimingsHandler processQueueTimer = new CustomTimingsHandler("processQueue");
|
|
+ public static final CustomTimingsHandler schedulerSyncTimer = new CustomTimingsHandler("** Scheduler - Sync Tasks", JavaPluginLoader.pluginParentTimer);
|
|
+
|
|
+ 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) {
|
|
+ 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;
|
|
+ if (period > 0) {
|
|
+ name += "(interval:" + period +")";
|
|
+ } else {
|
|
+ name += "(Single)";
|
|
+ }
|
|
+ CustomTimingsHandler result = pluginTaskTimingMap.get(name);
|
|
+ if (result == null) {
|
|
+ result = new CustomTimingsHandler(name, SpigotTimings.schedulerSyncTimer);
|
|
+ pluginTaskTimingMap.put(name, result);
|
|
+ }
|
|
+ return result;
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * Get a named timer for the specified entity type to track type specific timings.
|
|
+ * @param entity
|
|
+ * @return
|
|
+ */
|
|
+ public static CustomTimingsHandler getEntityTimings(Entity entity) {
|
|
+ String entityType = entity.getClass().getName();
|
|
+ CustomTimingsHandler result = entityTypeTimingMap.get(entityType);
|
|
+ if (result == null) {
|
|
+ result = new CustomTimingsHandler("** tickEntity - " + entity.getClass().getSimpleName(), activatedEntityTimer);
|
|
+ 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) {
|
|
+ String entityType = entity.getClass().getName();
|
|
+ CustomTimingsHandler result = tileEntityTypeTimingMap.get(entityType);
|
|
+ if (result == null) {
|
|
+ result = new CustomTimingsHandler("** tickTileEntity - " + entity.getClass().getSimpleName(), tickTileEntityTimer);
|
|
+ tileEntityTypeTimingMap.put(entityType, result);
|
|
+ }
|
|
+ return result;
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * Set of timers per world, to track world specific timings.
|
|
+ */
|
|
+ public static class WorldTimingsHandler {
|
|
+ public final CustomTimingsHandler mobSpawn;
|
|
+ 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;
|
|
+ public final CustomTimingsHandler entityTick;
|
|
+ public final CustomTimingsHandler tileEntityTick;
|
|
+ public final CustomTimingsHandler tileEntityPending;
|
|
+ public final CustomTimingsHandler tracker;
|
|
+ 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;
|
|
+
|
|
+ public WorldTimingsHandler(World server) {
|
|
+ String name = server.worldData.getName() +" - ";
|
|
+
|
|
+ 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");
|
|
+
|
|
+
|
|
+ tracker = new CustomTimingsHandler(name + "tracker");
|
|
+ doTick = new CustomTimingsHandler(name + "doTick");
|
|
+ tickEntities = new CustomTimingsHandler(name + "tickEntities");
|
|
+ }
|
|
+ }
|
|
+}
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java
|
|
index 7b4dab914..24ebc91da 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java
|
|
@@ -357,7 +357,9 @@ public class CraftScheduler implements BukkitScheduler {
|
|
if (task.isSync()) {
|
|
currentTask = task;
|
|
try {
|
|
+ task.timings.startTiming(); // Spigot
|
|
task.run();
|
|
+ task.timings.stopTiming(); // Spigot
|
|
} catch (final Throwable throwable) {
|
|
task.getOwner().getLogger().log(
|
|
Level.WARNING,
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftTask.java b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftTask.java
|
|
index a3ec23017..7e7ce9a81 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftTask.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftTask.java
|
|
@@ -1,11 +1,13 @@
|
|
package org.bukkit.craftbukkit.scheduler;
|
|
|
|
import org.bukkit.Bukkit;
|
|
+import org.bukkit.craftbukkit.SpigotTimings; // Spigot
|
|
+import org.spigotmc.CustomTimingsHandler; // Spigot
|
|
import org.bukkit.plugin.Plugin;
|
|
import org.bukkit.scheduler.BukkitTask;
|
|
|
|
|
|
-class CraftTask implements BukkitTask, Runnable {
|
|
+public class CraftTask implements BukkitTask, Runnable { // Spigot
|
|
|
|
private volatile CraftTask next = null;
|
|
public static final int ERROR = 0;
|
|
@@ -27,6 +29,7 @@ class CraftTask implements BukkitTask, Runnable {
|
|
private final Plugin plugin;
|
|
private final int id;
|
|
|
|
+ final CustomTimingsHandler timings; // Spigot
|
|
CraftTask() {
|
|
this(null, null, CraftTask.NO_REPEATING, CraftTask.NO_REPEATING);
|
|
}
|
|
@@ -35,11 +38,26 @@ class CraftTask implements BukkitTask, Runnable {
|
|
this(null, task, CraftTask.NO_REPEATING, CraftTask.NO_REPEATING);
|
|
}
|
|
|
|
- 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
|
|
}
|
|
|
|
public final int getTaskId() {
|
|
@@ -104,4 +122,13 @@ class CraftTask implements BukkitTask, Runnable {
|
|
setPeriod(CraftTask.CANCEL);
|
|
return true;
|
|
}
|
|
+
|
|
+ // Spigot start
|
|
+ public String getTaskName() {
|
|
+ if (timingName != null) {
|
|
+ return timingName;
|
|
+ }
|
|
+ return task.getClass().getName();
|
|
+ }
|
|
+ // Spigot end
|
|
}
|
|
--
|
|
2.17.1
|
|
|