testserver/CraftBukkit-Patches/0010-Spigot-Timings.patch

878 lines
40 KiB
Diff
Raw Normal View History

From a5e080be0b23f8bfacc9d1405d8161ca731f36c0 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/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
index 582e684..7980e80 100644
--- a/src/main/java/net/minecraft/server/Chunk.java
+++ b/src/main/java/net/minecraft/server/Chunk.java
2016-02-29 21:33:06 +00:00
@@ -834,6 +834,7 @@ public class Chunk {
}
2016-02-29 21:33:06 +00:00
public void loadNearby(IChunkProvider ichunkprovider, ChunkGenerator chunkgenerator) {
+ world.timings.syncChunkLoadPostTimer.startTiming(); // Spigot
2016-02-29 21:33:06 +00:00
Chunk chunk = ichunkprovider.getLoadedChunkAt(this.locX, this.locZ - 1);
Chunk chunk1 = ichunkprovider.getLoadedChunkAt(this.locX + 1, this.locZ);
Chunk chunk2 = ichunkprovider.getLoadedChunkAt(this.locX, this.locZ + 1);
@@ -858,6 +859,7 @@ public class Chunk {
chunk4.a(chunkgenerator);
}
}
+ world.timings.syncChunkLoadPostTimer.stopTiming(); // Spigot
}
diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java
2016-03-05 07:51:20 +00:00
index 22c17db..162613b 100644
--- a/src/main/java/net/minecraft/server/ChunkProviderServer.java
+++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java
2016-03-05 07:51:20 +00:00
@@ -154,6 +154,7 @@ public class ChunkProviderServer implements IChunkProvider {
2014-11-28 01:17:45 +00:00
// CraftBukkit end
if (chunk == null) {
+ world.timings.syncChunkLoadTimer.startTiming(); // Spigot
2016-02-29 21:33:06 +00:00
long k = ChunkCoordIntPair.a(i, j);
chunk = this.loadChunk(i, j);
2016-03-05 07:51:20 +00:00
@@ -202,6 +203,7 @@ public class ChunkProviderServer implements IChunkProvider {
2015-02-28 11:36:22 +00:00
}
// CraftBukkit end
2016-02-29 21:33:06 +00:00
chunk.loadNearby(this, this.chunkGenerator);
+ world.timings.syncChunkLoadTimer.stopTiming(); // Spigot
}
return chunk;
diff --git a/src/main/java/net/minecraft/server/ChunkRegionLoader.java b/src/main/java/net/minecraft/server/ChunkRegionLoader.java
2016-03-01 00:23:45 +00:00
index 003aee0..53b5296 100644
--- a/src/main/java/net/minecraft/server/ChunkRegionLoader.java
+++ b/src/main/java/net/minecraft/server/ChunkRegionLoader.java
2016-02-29 21:33:06 +00:00
@@ -44,7 +44,9 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver {
// CraftBukkit start - Add async variant, provide compatibility
2015-02-28 11:36:22 +00:00
public Chunk a(World world, int i, int j) throws IOException {
+ world.timings.syncChunkLoadDataTimer.startTiming(); // Spigot
2014-11-28 01:17:45 +00:00
Object[] data = loadChunk(world, i, j);
+ world.timings.syncChunkLoadDataTimer.stopTiming(); // Spigot
if (data != null) {
Chunk chunk = (Chunk) data[0];
NBTTagCompound nbttagcompound = (NBTTagCompound) data[1];
2016-02-29 21:33:06 +00:00
@@ -347,7 +349,7 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver {
2015-03-22 19:50:13 +00:00
public void loadEntities(Chunk chunk, NBTTagCompound nbttagcompound, World world) {
// CraftBukkit end
2015-02-28 11:36:22 +00:00
-
+ world.timings.syncChunkLoadEntitiesTimer.startTiming(); // Spigot
NBTTagList nbttaglist1 = nbttagcompound.getList("Entities", 10);
if (nbttaglist1 != null) {
2016-02-29 21:33:06 +00:00
@@ -358,7 +360,8 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver {
chunk.g(true);
}
}
-
+ world.timings.syncChunkLoadEntitiesTimer.stopTiming(); // Spigot
+ world.timings.syncChunkLoadTileEntitiesTimer.startTiming(); // Spigot
NBTTagList nbttaglist2 = nbttagcompound.getList("TileEntities", 10);
if (nbttaglist2 != null) {
2016-02-29 21:33:06 +00:00
@@ -371,6 +374,8 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver {
}
}
}
+ world.timings.syncChunkLoadTileEntitiesTimer.stopTiming(); // Spigot
+ world.timings.syncChunkLoadTileTicksTimer.startTiming(); // Spigot
if (nbttagcompound.hasKeyOfType("TileTicks", 9)) {
NBTTagList nbttaglist3 = nbttagcompound.getList("TileTicks", 10);
2016-02-29 21:33:06 +00:00
@@ -390,6 +395,7 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver {
}
}
}
+ world.timings.syncChunkLoadTileTicksTimer.stopTiming(); // Spigot
2015-02-28 11:36:22 +00:00
// return chunk; // CraftBukkit
}
diff --git a/src/main/java/net/minecraft/server/DedicatedServer.java b/src/main/java/net/minecraft/server/DedicatedServer.java
2016-03-03 06:04:36 +00:00
index 9c17951..db78855 100644
--- a/src/main/java/net/minecraft/server/DedicatedServer.java
+++ b/src/main/java/net/minecraft/server/DedicatedServer.java
2016-02-29 21:33:06 +00:00
@@ -22,6 +22,7 @@ import java.io.PrintStream;
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;
2016-02-29 21:33:06 +00:00
@@ -394,6 +395,7 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer
}
2016-02-29 21:33:06 +00:00
public void aL() {
+ SpigotTimings.serverCommandTimer.startTiming(); // Spigot
2016-02-29 21:33:06 +00:00
while (!this.serverCommandQueue.isEmpty()) {
ServerCommand servercommand = (ServerCommand) this.serverCommandQueue.remove(0);
2016-03-03 06:04:36 +00:00
@@ -408,6 +410,7 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer
// CraftBukkit end
}
2014-11-28 01:17:45 +00:00
+ SpigotTimings.serverCommandTimer.stopTiming(); // Spigot
}
2016-02-29 21:33:06 +00:00
public boolean aa() {
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
2016-02-29 21:33:06 +00:00
index 4f0098f..63cc105 100644
--- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java
2016-02-29 21:33:06 +00:00
@@ -24,6 +24,7 @@ import org.bukkit.block.BlockFace;
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;
2016-02-29 21:33:06 +00:00
import org.bukkit.event.vehicle.VehicleBlockCollisionEvent;
@@ -139,6 +140,7 @@ public abstract class Entity implements ICommandListener {
public boolean valid; // CraftBukkit
public org.bukkit.projectiles.ProjectileSource projectileSource; // CraftBukkit - For projectiles only
2015-09-01 08:07:28 +00:00
public boolean forceExplosionKnockback; // CraftBukkit - SPIGOT-949
+ public CustomTimingsHandler tickTimer = org.bukkit.craftbukkit.SpigotTimings.getEntityTimings(this); // Spigot
2016-02-29 21:33:06 +00:00
public Entity(World world) {
this.id = Entity.entityCount++;
@@ -447,6 +449,7 @@ public abstract class Entity implements ICommandListener {
2014-11-28 01:17:45 +00:00
}
public void move(double d0, double d1, double d2) {
+ org.bukkit.craftbukkit.SpigotTimings.entityMoveTimer.startTiming(); // Spigot
2015-02-28 11:36:22 +00:00
if (this.noclip) {
2014-11-28 01:17:45 +00:00
this.a(this.getBoundingBox().c(d0, d1, d2));
this.recalcPosition();
2016-02-29 21:33:06 +00:00
@@ -787,6 +790,7 @@ public abstract class Entity implements ICommandListener {
this.world.methodProfiler.b();
}
+ org.bukkit.craftbukkit.SpigotTimings.entityMoveTimer.stopTiming(); // Spigot
}
2016-02-29 21:33:06 +00:00
public void recalcPosition() {
diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java
2016-03-01 00:23:45 +00:00
index 0b851a9..dc91f0a 100644
--- a/src/main/java/net/minecraft/server/EntityLiving.java
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
2015-02-28 11:36:22 +00:00
@@ -23,6 +23,8 @@ import org.bukkit.event.entity.EntityRegainHealthEvent;
2016-02-29 21:33:06 +00:00
import org.bukkit.event.player.PlayerItemConsumeEvent;
// CraftBukkit end
+import org.bukkit.craftbukkit.SpigotTimings; // Spigot
+
public abstract class EntityLiving extends Entity {
2014-11-28 01:17:45 +00:00
private static final UUID a = UUID.fromString("662A6B8D-DA3E-4C1C-8813-96EA6097278D");
2016-02-29 21:33:06 +00:00
@@ -1673,6 +1675,7 @@ public abstract class EntityLiving extends Entity {
}
2016-02-29 21:33:06 +00:00
public void m() {
+ SpigotTimings.timerEntityBaseTick.startTiming(); // Spigot
2016-02-29 21:33:06 +00:00
super.m();
this.cu();
2015-02-28 11:36:22 +00:00
if (!this.world.isClientSide) {
2016-02-29 21:33:06 +00:00
@@ -1745,7 +1748,9 @@ public abstract class EntityLiving extends Entity {
}
}
+ SpigotTimings.timerEntityBaseTick.stopTiming(); // Spigot
2016-02-29 21:33:06 +00:00
this.n();
+ SpigotTimings.timerEntityTickRest.startTiming(); // Spigot
double d0 = this.locX - this.lastX;
double d1 = this.locZ - this.lastZ;
float f = (float) (d0 * d0 + d1 * d1);
2016-02-29 21:33:06 +00:00
@@ -1815,6 +1820,7 @@ public abstract class EntityLiving extends Entity {
this.bo = 0;
}
+ SpigotTimings.timerEntityTickRest.stopTiming(); // Spigot
}
2014-11-28 01:17:45 +00:00
protected float h(float f, float f1) {
2016-02-29 21:33:06 +00:00
@@ -1879,6 +1885,7 @@ public abstract class EntityLiving extends Entity {
}
this.world.methodProfiler.a("ai");
+ SpigotTimings.timerEntityAI.startTiming(); // Spigot
2016-02-29 21:33:06 +00:00
if (this.cf()) {
this.bc = false;
this.bd = 0.0F;
@@ -1889,6 +1896,7 @@ public abstract class EntityLiving extends Entity {
2014-11-28 01:17:45 +00:00
this.doTick();
this.world.methodProfiler.b();
}
+ SpigotTimings.timerEntityAI.stopTiming(); // Spigot
this.world.methodProfiler.b();
this.world.methodProfiler.a("jump");
2016-02-29 21:33:06 +00:00
@@ -1911,10 +1919,14 @@ public abstract class EntityLiving extends Entity {
this.be *= 0.98F;
this.bf *= 0.9F;
this.r();
+ SpigotTimings.timerEntityAIMove.startTiming(); // Spigot
2016-02-29 21:33:06 +00:00
this.g(this.bd, this.be);
+ SpigotTimings.timerEntityAIMove.stopTiming(); // Spigot
this.world.methodProfiler.b();
this.world.methodProfiler.a("push");
2016-02-29 21:33:06 +00:00
+ SpigotTimings.timerEntityAICollision.startTiming(); // Spigot
this.cn();
+ SpigotTimings.timerEntityAICollision.stopTiming(); // Spigot
this.world.methodProfiler.b();
2016-02-29 21:33:06 +00:00
}
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
2016-03-01 19:39:42 +00:00
index c226e01..d754d0d 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
2016-02-29 21:33:06 +00:00
@@ -45,6 +45,7 @@ import org.bukkit.craftbukkit.CraftServer;
2016-02-29 21:33:06 +00:00
// CraftBukkit start
2015-07-12 09:59:20 +00:00
// CraftBukkit end
2016-02-29 21:33:06 +00:00
+import org.bukkit.craftbukkit.SpigotTimings; // Spigot
2015-07-12 09:59:20 +00:00
public abstract class MinecraftServer implements Runnable, ICommandListener, IAsyncTaskHandler, IMojangStatistics {
2016-03-01 19:39:42 +00:00
@@ -622,6 +623,7 @@ public abstract class MinecraftServer implements Runnable, ICommandListener, IAs
2016-02-29 21:33:06 +00:00
protected void B() {}
protected void C() throws ExceptionWorldConflict { // CraftBukkit - added throws
+ SpigotTimings.serverTickTimer.startTiming(); // Spigot
long i = System.nanoTime();
++this.ticks;
2016-03-01 19:39:42 +00:00
@@ -648,10 +650,12 @@ public abstract class MinecraftServer implements Runnable, ICommandListener, IAs
}
2014-11-28 01:17:45 +00:00
if (autosavePeriod > 0 && this.ticks % autosavePeriod == 0) { // CraftBukkit
+ SpigotTimings.worldSaveTimer.startTiming(); // Spigot
this.methodProfiler.a("save");
2014-11-28 01:17:45 +00:00
this.v.savePlayers();
this.saveChunks(true);
this.methodProfiler.b();
+ SpigotTimings.worldSaveTimer.stopTiming(); // Spigot
}
this.methodProfiler.a("tallying");
2016-03-01 19:39:42 +00:00
@@ -668,6 +672,8 @@ public abstract class MinecraftServer implements Runnable, ICommandListener, IAs
this.methodProfiler.b();
this.methodProfiler.b();
+ SpigotTimings.serverTickTimer.stopTiming(); // Spigot
+ org.spigotmc.CustomTimingsHandler.tick(); // Spigot
}
2016-02-29 21:33:06 +00:00
public void D() {
2016-03-01 19:39:42 +00:00
@@ -682,16 +688,23 @@ public abstract class MinecraftServer implements Runnable, ICommandListener, IAs
2014-11-28 01:17:45 +00:00
this.methodProfiler.c("levels");
+ SpigotTimings.schedulerTimer.startTiming(); // Spigot
// CraftBukkit start
this.server.getScheduler().mainThreadHeartbeat(this.ticks);
+ SpigotTimings.schedulerTimer.stopTiming(); // Spigot
// 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) {
2016-03-01 19:39:42 +00:00
@@ -699,6 +712,7 @@ public abstract class MinecraftServer implements Runnable, ICommandListener, IAs
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;
2016-03-01 19:39:42 +00:00
@@ -722,7 +736,9 @@ public abstract class MinecraftServer implements Runnable, ICommandListener, IAs
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");
worldserver.a(crashreport);
2016-03-01 19:39:42 +00:00
@@ -730,7 +746,9 @@ public abstract class MinecraftServer implements Runnable, ICommandListener, IAs
}
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");
worldserver.a(crashreport);
2016-03-01 19:39:42 +00:00
@@ -739,7 +757,9 @@ public abstract class MinecraftServer implements Runnable, ICommandListener, IAs
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
2016-03-01 19:39:42 +00:00
@@ -748,14 +768,20 @@ public abstract class MinecraftServer implements Runnable, ICommandListener, IAs
}
this.methodProfiler.c("connection");
+ SpigotTimings.connectionTimer.startTiming(); // Spigot
2016-02-29 21:33:06 +00:00
this.am().c();
+ SpigotTimings.connectionTimer.stopTiming(); // Spigot
this.methodProfiler.c("players");
+ SpigotTimings.playerListTimer.startTiming(); // Spigot
2014-11-28 01:17:45 +00:00
this.v.tick();
+ SpigotTimings.playerListTimer.stopTiming(); // Spigot
this.methodProfiler.c("tickables");
+ SpigotTimings.tickablesTimer.startTiming(); // Spigot
2016-02-29 21:33:06 +00:00
for (i = 0; i < this.o.size(); ++i) {
((ITickable) this.o.get(i)).c();
}
+ 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
2016-03-04 04:26:28 +00:00
index 49b8d3a..face946 100644
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
2016-03-04 04:26:28 +00:00
@@ -1246,6 +1246,7 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
// CraftBukkit end
2015-02-28 11:36:22 +00:00
private void handleCommand(String s) {
+ org.bukkit.craftbukkit.SpigotTimings.playerCommandTimer.startTiming(); // Spigot
2014-11-28 01:17:45 +00:00
// CraftBukkit start - whole method
2016-02-29 21:33:06 +00:00
this.LOGGER.info(this.player.getName() + " issued server command: " + s);
2016-03-04 04:26:28 +00:00
@@ -1255,18 +1256,22 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
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");
java.util.logging.Logger.getLogger(PlayerConnection.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
+ org.bukkit.craftbukkit.SpigotTimings.playerCommandTimer.stopTiming(); // Spigot
return;
}
+ org.bukkit.craftbukkit.SpigotTimings.playerCommandTimer.stopTiming(); // Spigot
2014-11-28 01:17:45 +00:00
// this.minecraftServer.getCommandHandler().a(this.player, s);
// CraftBukkit end
}
diff --git a/src/main/java/net/minecraft/server/TileEntity.java b/src/main/java/net/minecraft/server/TileEntity.java
2016-02-29 21:33:06 +00:00
index baf1d73..8bbdc11 100644
--- a/src/main/java/net/minecraft/server/TileEntity.java
+++ b/src/main/java/net/minecraft/server/TileEntity.java
2014-11-28 01:17:45 +00:00
@@ -6,10 +6,12 @@ import java.util.concurrent.Callable;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
+import org.spigotmc.CustomTimingsHandler; // Spigot
import org.bukkit.inventory.InventoryHolder; // CraftBukkit
2014-11-28 01:17:45 +00:00
public abstract class TileEntity {
+ public CustomTimingsHandler tickTimer = org.bukkit.craftbukkit.SpigotTimings.getTileEntityTimings(this); // Spigot
private static final Logger a = LogManager.getLogger();
2015-02-28 11:36:22 +00:00
private static Map<String, Class<? extends TileEntity>> f = Maps.newHashMap();
private static Map<Class<? extends TileEntity>, String> g = Maps.newHashMap();
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
2016-03-05 07:51:20 +00:00
index d8ddc43..7fb34e3 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
2016-02-29 21:33:06 +00:00
@@ -18,6 +18,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;
2016-02-29 21:33:06 +00:00
import org.bukkit.craftbukkit.event.CraftEventFactory;
@@ -99,6 +100,8 @@ public abstract class World implements IBlockAccess {
private int tickPosition;
public final org.spigotmc.SpigotWorldConfig spigotConfig; // Spigot
+ public final SpigotTimings.WorldTimingsHandler timings; // Spigot
+
public CraftWorld getWorld() {
return this.world;
}
2016-03-01 00:23:45 +00:00
@@ -134,6 +137,7 @@ public abstract class World implements IBlockAccess {
this.N.world = (WorldServer) this;
this.getServer().addWorld(this.world);
// CraftBukkit end
2016-02-29 21:33:06 +00:00
+ timings = new SpigotTimings.WorldTimingsHandler(this); // Spigot - code below can generate new world and access timings
2014-11-28 01:17:45 +00:00
}
public World b() {
2016-03-01 00:23:45 +00:00
@@ -1306,6 +1310,7 @@ public abstract class World implements IBlockAccess {
2016-02-29 21:33:06 +00:00
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);
2016-03-01 00:23:45 +00:00
@@ -1323,7 +1328,9 @@ public abstract class World implements IBlockAccess {
this.methodProfiler.a("tick");
2016-02-29 21:33:06 +00:00
if (!entity.dead && !(entity instanceof EntityPlayer)) {
try {
+ SpigotTimings.tickEntityTimer.startTiming(); // Spigot
2014-11-28 01:17:45 +00:00
this.g(entity);
+ SpigotTimings.tickEntityTimer.stopTiming(); // Spigot
} catch (Throwable throwable1) {
2016-02-29 21:33:06 +00:00
crashreport1 = CrashReport.a(throwable1, "Ticking entity");
crashreportsystemdetails1 = crashreport1.a("Entity being ticked");
2016-03-01 00:23:45 +00:00
@@ -1349,6 +1356,7 @@ public abstract class World implements IBlockAccess {
this.methodProfiler.b();
}
+ timings.entityTick.stopTiming(); // Spigot
this.methodProfiler.c("blockEntities");
2015-02-28 11:36:22 +00:00
this.M = true;
// CraftBukkit start - From below, clean up tile entities before ticking them
2016-03-01 00:23:45 +00:00
@@ -1369,6 +1377,7 @@ public abstract class World implements IBlockAccess {
2015-02-28 11:36:22 +00:00
if (this.isLoaded(blockposition) && this.N.a(blockposition)) {
2014-11-28 01:17:45 +00:00
try {
2016-02-29 21:33:06 +00:00
this.methodProfiler.a(tileentity.getClass().getSimpleName());
2014-11-28 01:17:45 +00:00
+ tileentity.tickTimer.startTiming(); // Spigot
2016-02-29 21:33:06 +00:00
((ITickable) tileentity).c();
this.methodProfiler.b();
2014-11-28 01:17:45 +00:00
} catch (Throwable throwable2) {
2016-03-01 00:23:45 +00:00
@@ -1377,6 +1386,11 @@ public abstract class World implements IBlockAccess {
2014-11-28 01:17:45 +00:00
tileentity.a(crashreportsystemdetails1);
throw new ReportedException(crashreport1);
}
+ // Spigot start
+ finally {
+ tileentity.tickTimer.stopTiming();
+ }
+ // Spigot end
}
}
2016-03-01 00:23:45 +00:00
@@ -1389,6 +1403,8 @@ public abstract class World implements IBlockAccess {
}
}
+ timings.tileEntityTick.stopTiming(); // Spigot
+ timings.tileEntityPending.startTiming(); // Spigot
2015-02-28 11:36:22 +00:00
this.M = false;
/* CraftBukkit start - Moved up
2016-02-29 21:33:06 +00:00
if (!this.tileEntityListUnload.isEmpty()) {
2016-03-01 00:23:45 +00:00
@@ -1423,6 +1439,7 @@ public abstract class World implements IBlockAccess {
2015-02-28 11:36:22 +00:00
this.b.clear();
}
+ timings.tileEntityPending.stopTiming(); // Spigot
this.methodProfiler.b();
this.methodProfiler.b();
}
2016-03-01 00:23:45 +00:00
@@ -1466,6 +1483,7 @@ public abstract class World implements IBlockAccess {
// CraftBukkit start - Use neighbor cache instead of looking up
Chunk startingChunk = this.getChunkIfLoaded(i >> 4, j >> 4);
2014-11-28 01:17:45 +00:00
if (!flag || (startingChunk != null && startingChunk.areNeighborsLoaded(2)) /* this.isAreaLoaded(i - b0, 0, j - b0, i + b0, 0, j + b0) */) {
+ entity.tickTimer.startTiming(); // Spigot
// CraftBukkit end
2016-02-29 21:33:06 +00:00
entity.M = entity.locX;
entity.N = entity.locY;
2016-03-01 00:23:45 +00:00
@@ -1533,6 +1551,7 @@ public abstract class World implements IBlockAccess {
}
}
2014-11-28 01:17:45 +00:00
+ 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 250a9f0..ca04f24 100644
--- a/src/main/java/net/minecraft/server/WorldServer.java
+++ b/src/main/java/net/minecraft/server/WorldServer.java
2016-02-29 21:33:06 +00:00
@@ -219,10 +219,13 @@ 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();
2014-11-28 01:17:45 +00: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)) {
+ timings.mobSpawn.startTiming(); // Spigot
2016-02-29 21:33:06 +00: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);
+ timings.mobSpawn.stopTiming(); // Spigot
// CraftBukkit end
}
2016-02-29 21:33:06 +00:00
+ timings.doChunkUnload.startTiming(); // Spigot
this.methodProfiler.c("chunkSource");
this.chunkProvider.unloadChunks();
int j = this.a(1.0F);
@@ -236,21 +239,36 @@ 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.a(false);
+ timings.doTickPending.stopTiming(); // Spigot
this.methodProfiler.c("tickBlocks");
+ timings.doTickTiles.startTiming(); // Spigot
2016-02-29 21:33:06 +00:00
this.j();
+ 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-02-29 21:33:06 +00:00
this.portalTravelAgent.a(this.getTime());
+ timings.doPortalForcer.stopTiming(); // Spigot
this.methodProfiler.b();
+ timings.doSounds.startTiming(); // Spigot
2016-02-29 21:33:06 +00:00
this.ao();
+ timings.doSounds.stopTiming(); // Spigot
2015-02-28 11:36:22 +00:00
+ timings.doChunkGC.startTiming();// Spigot
this.getWorld().processChunkGC(); // CraftBukkit
+ timings.doChunkGC.stopTiming(); // Spigot
}
2015-02-28 11:36:22 +00:00
public BiomeBase.BiomeMeta a(EnumCreatureType enumcreaturetype, BlockPosition blockposition) {
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
2016-02-29 21:33:06 +00:00
index 91965c0..261b423 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
2016-02-29 21:33:06 +00:00
@@ -1663,6 +1663,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/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
2016-03-03 06:04:36 +00:00
index 9947f9c..83d228a 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
2016-02-29 21:33:06 +00:00
@@ -252,7 +252,9 @@ public class CraftWorld implements World {
net.minecraft.server.Chunk chunk = world.getChunkProviderServer().chunks.get(LongHash.toLong(x, z));
if (chunk == null) {
+ world.timings.syncChunkLoadTimer.startTiming(); // Spigot
2016-02-29 21:33:06 +00:00
chunk = world.getChunkProviderServer().getOrLoadChunkAt(x, z);
+ world.timings.syncChunkLoadTimer.stopTiming(); // Spigot
}
return chunk != null;
}
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 0000000..558574f
--- /dev/null
+++ b/src/main/java/org/bukkit/craftbukkit/SpigotTimings.java
@@ -0,0 +1,170 @@
+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 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().getSimpleName();
+ CustomTimingsHandler result = entityTypeTimingMap.get(entityType);
+ if (result == null) {
+ result = new CustomTimingsHandler("** tickEntity - " + entityType, 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().getSimpleName();
+ CustomTimingsHandler result = tileEntityTypeTimingMap.get(entityType);
+ if (result == null) {
+ result = new CustomTimingsHandler("** tickTileEntity - " + entityType, 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/chunkio/ChunkIOProvider.java b/src/main/java/org/bukkit/craftbukkit/chunkio/ChunkIOProvider.java
2016-02-29 21:33:06 +00:00
index 6dfef44..482af17 100644
--- a/src/main/java/org/bukkit/craftbukkit/chunkio/ChunkIOProvider.java
+++ b/src/main/java/org/bukkit/craftbukkit/chunkio/ChunkIOProvider.java
2016-02-29 21:33:06 +00:00
@@ -45,7 +45,9 @@ class ChunkIOProvider implements AsynchronousExecutor.CallBackProvider<QueuedChu
chunk.addEntities();
2016-02-29 21:33:06 +00:00
if (queuedChunk.provider.chunkGenerator != null) {
+ queuedChunk.provider.world.timings.syncChunkLoadStructuresTimer.startTiming(); // Spigot
2016-02-29 21:33:06 +00:00
queuedChunk.provider.chunkGenerator.recreateStructures(chunk, queuedChunk.x, queuedChunk.z);
+ queuedChunk.provider.world.timings.syncChunkLoadStructuresTimer.stopTiming(); // Spigot
}
Server server = queuedChunk.provider.world.getServer();
diff --git a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java
index 9fea4fb..8442ecb 100644
--- a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java
+++ b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java
@@ -346,7 +346,9 @@ public class CraftScheduler implements BukkitScheduler {
}
if (task.isSync()) {
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 55db3ff..220e39a 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;
/**
@@ -22,6 +24,7 @@ class CraftTask implements BukkitTask, Runnable {
private final Plugin plugin;
private final int id;
+ final CustomTimingsHandler timings; // Spigot
CraftTask() {
this(null, null, -1, -1);
}
@@ -30,11 +33,26 @@ class CraftTask implements BukkitTask, Runnable {
this(null, task, -1, -1);
}
- 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() {
@@ -94,4 +112,13 @@ class CraftTask implements BukkitTask, Runnable {
setPeriod(-2l);
return true;
}
+
+ // Spigot start
+ public String getTaskName() {
+ if (timingName != null) {
+ return timingName;
+ }
+ return task.getClass().getName();
+ }
+ // Spigot end
}
--
2.5.0