2013-06-07 23:21:38 +00:00
|
|
|
From bd13994293a8c2208638965e6072a486e2c0188e Mon Sep 17 00:00:00 2001
|
2013-02-26 17:21:40 +00:00
|
|
|
From: Aikar <aikar@aikar.co>
|
|
|
|
Date: Thu, 10 Jan 2013 00:18:11 -0500
|
|
|
|
Subject: [PATCH] Improved Timings System
|
|
|
|
|
|
|
|
Tracks nearly every point of minecraft internals and plugin events to give a good quick overview on what is causing TPS loss.
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java
|
2013-04-30 22:33:27 +00:00
|
|
|
index b73f69c..17934c0 100644
|
2013-02-26 17:21:40 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/ChunkProviderServer.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java
|
2013-03-25 07:57:00 +00:00
|
|
|
@@ -102,6 +102,7 @@ public class ChunkProviderServer implements IChunkProvider {
|
2013-02-26 17:21:40 +00:00
|
|
|
// CraftBukkit end
|
|
|
|
|
|
|
|
if (chunk == null) {
|
|
|
|
+ org.bukkit.craftbukkit.SpigotTimings.syncChunkLoadTimer.startTiming(); // Spigot
|
|
|
|
chunk = this.loadChunk(i, j);
|
|
|
|
if (chunk == null) {
|
|
|
|
if (this.chunkProvider == null) {
|
2013-03-25 07:57:00 +00:00
|
|
|
@@ -140,6 +141,7 @@ public class ChunkProviderServer implements IChunkProvider {
|
2013-02-26 17:21:40 +00:00
|
|
|
// CraftBukkit end
|
|
|
|
|
|
|
|
chunk.a(this, this, i, j);
|
|
|
|
+ org.bukkit.craftbukkit.SpigotTimings.syncChunkLoadTimer.stopTiming(); // Spigot
|
|
|
|
}
|
|
|
|
|
|
|
|
// CraftBukkit start - If we didn't need to load the chunk run the callback now
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
|
2013-06-02 01:29:44 +00:00
|
|
|
index 0f7be97..978b6ef 100644
|
2013-02-26 17:21:40 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/Entity.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/Entity.java
|
2013-03-15 21:35:56 +00:00
|
|
|
@@ -14,6 +14,7 @@ import org.bukkit.block.BlockFace;
|
2013-02-26 17:21:40 +00:00
|
|
|
import org.bukkit.entity.LivingEntity;
|
|
|
|
import org.bukkit.entity.Painting;
|
|
|
|
import org.bukkit.entity.Vehicle;
|
2013-06-02 01:29:44 +00:00
|
|
|
+import org.spigotmc.CustomTimingsHandler; // Spigot
|
2013-02-26 17:21:40 +00:00
|
|
|
import org.bukkit.event.entity.EntityCombustByEntityEvent;
|
|
|
|
import org.bukkit.event.painting.PaintingBreakByEntityEvent;
|
|
|
|
import org.bukkit.event.vehicle.VehicleBlockCollisionEvent;
|
2013-04-12 03:57:00 +00:00
|
|
|
@@ -110,6 +111,8 @@ public abstract class Entity {
|
2013-03-15 21:35:56 +00:00
|
|
|
public EnumEntitySize at;
|
2013-02-26 17:21:40 +00:00
|
|
|
public boolean valid = false; // CraftBukkit
|
|
|
|
|
|
|
|
+ public CustomTimingsHandler tickTimer = org.bukkit.craftbukkit.SpigotTimings.getEntityTimings(this); // Spigot
|
|
|
|
+
|
|
|
|
public Entity(World world) {
|
|
|
|
this.id = entityCount++;
|
|
|
|
this.l = 1.0D;
|
2013-04-13 07:06:23 +00:00
|
|
|
@@ -423,6 +426,7 @@ public abstract class Entity {
|
|
|
|
}
|
|
|
|
// CraftBukkit end
|
2013-02-26 17:21:40 +00:00
|
|
|
|
|
|
|
+ org.bukkit.craftbukkit.SpigotTimings.entityMoveTimer.startTiming(); // Spigot
|
2013-03-15 21:35:56 +00:00
|
|
|
if (this.Z) {
|
2013-02-26 17:21:40 +00:00
|
|
|
this.boundingBox.d(d0, d1, d2);
|
|
|
|
this.locX = (this.boundingBox.a + this.boundingBox.d) / 2.0D;
|
2013-04-13 07:06:23 +00:00
|
|
|
@@ -722,6 +726,7 @@ public abstract class Entity {
|
2013-02-26 17:21:40 +00:00
|
|
|
|
|
|
|
this.world.methodProfiler.b();
|
|
|
|
}
|
|
|
|
+ org.bukkit.craftbukkit.SpigotTimings.entityMoveTimer.stopTiming(); // Spigot
|
|
|
|
}
|
|
|
|
|
2013-03-15 21:35:56 +00:00
|
|
|
protected void C() {
|
2013-02-26 17:21:40 +00:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java
|
2013-04-30 22:33:27 +00:00
|
|
|
index 965e6ce..58a4acb 100644
|
2013-02-26 17:21:40 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/EntityLiving.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
|
2013-04-12 03:57:00 +00:00
|
|
|
@@ -497,6 +497,7 @@ public abstract class EntityLiving extends Entity {
|
2013-02-26 17:21:40 +00:00
|
|
|
}
|
|
|
|
|
2013-03-15 21:35:56 +00:00
|
|
|
public void l_() {
|
2013-02-26 17:21:40 +00:00
|
|
|
+ org.bukkit.craftbukkit.SpigotTimings.timerEntityBaseTick.startTiming(); // Spigot
|
2013-03-15 21:35:56 +00:00
|
|
|
super.l_();
|
2013-02-26 17:21:40 +00:00
|
|
|
if (!this.world.isStatic) {
|
|
|
|
int i;
|
2013-04-12 03:57:00 +00:00
|
|
|
@@ -523,7 +524,9 @@ public abstract class EntityLiving extends Entity {
|
2013-02-26 17:21:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
+ org.bukkit.craftbukkit.SpigotTimings.timerEntityBaseTick.stopTiming(); // Spigot
|
|
|
|
this.c();
|
|
|
|
+ org.bukkit.craftbukkit.SpigotTimings.timerEntityTickRest.startTiming(); // Spigot
|
|
|
|
double d0 = this.locX - this.lastX;
|
|
|
|
double d1 = this.locZ - this.lastZ;
|
|
|
|
float f = (float) (d0 * d0 + d1 * d1);
|
2013-04-12 03:57:00 +00:00
|
|
|
@@ -614,6 +617,7 @@ public abstract class EntityLiving extends Entity {
|
2013-02-26 17:21:40 +00:00
|
|
|
|
|
|
|
this.world.methodProfiler.b();
|
2013-03-15 21:35:56 +00:00
|
|
|
this.aE += f2;
|
2013-02-26 17:21:40 +00:00
|
|
|
+ org.bukkit.craftbukkit.SpigotTimings.timerEntityTickRest.stopTiming(); // Spigot
|
|
|
|
}
|
|
|
|
|
2013-03-25 07:57:00 +00:00
|
|
|
// CraftBukkit start - Delegate so we can handle providing a reason for health being regained
|
2013-04-13 07:06:23 +00:00
|
|
|
@@ -1254,6 +1258,7 @@ public abstract class EntityLiving extends Entity {
|
2013-02-26 17:21:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void c() {
|
|
|
|
+ org.bukkit.craftbukkit.SpigotTimings.timerEntityAI.startTiming(); // Spigot
|
2013-03-15 21:35:56 +00:00
|
|
|
if (this.bX > 0) {
|
|
|
|
--this.bX;
|
2013-02-26 17:21:40 +00:00
|
|
|
}
|
2013-04-13 07:06:23 +00:00
|
|
|
@@ -1305,6 +1310,7 @@ public abstract class EntityLiving extends Entity {
|
2013-03-15 21:35:56 +00:00
|
|
|
this.aA = this.yaw;
|
2013-02-26 17:21:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
+ org.bukkit.craftbukkit.SpigotTimings.timerEntityAI.stopTiming(); // Spigot
|
|
|
|
|
|
|
|
this.world.methodProfiler.b();
|
|
|
|
this.world.methodProfiler.a("jump");
|
2013-04-13 07:06:23 +00:00
|
|
|
@@ -1323,6 +1329,7 @@ public abstract class EntityLiving extends Entity {
|
2013-02-26 17:21:40 +00:00
|
|
|
|
|
|
|
this.world.methodProfiler.b();
|
|
|
|
this.world.methodProfiler.a("travel");
|
|
|
|
+ org.bukkit.craftbukkit.SpigotTimings.timerEntityAIMove.startTiming(); // Spigot
|
|
|
|
this.bD *= 0.98F;
|
2013-03-15 21:35:56 +00:00
|
|
|
this.bE *= 0.98F;
|
|
|
|
this.bF *= 0.9F;
|
2013-04-13 07:06:23 +00:00
|
|
|
@@ -1331,11 +1338,14 @@ public abstract class EntityLiving extends Entity {
|
2013-03-15 21:35:56 +00:00
|
|
|
this.aO *= this.bE();
|
|
|
|
this.e(this.bD, this.bE);
|
|
|
|
this.aO = f;
|
2013-02-26 17:21:40 +00:00
|
|
|
+ org.bukkit.craftbukkit.SpigotTimings.timerEntityAIMove.stopTiming(); // Spigot
|
|
|
|
this.world.methodProfiler.b();
|
|
|
|
this.world.methodProfiler.a("push");
|
|
|
|
+ org.bukkit.craftbukkit.SpigotTimings.timerEntityAICollision.startTiming(); // Spigot
|
|
|
|
if (!this.world.isStatic) {
|
2013-03-15 21:35:56 +00:00
|
|
|
this.bg();
|
2013-02-26 17:21:40 +00:00
|
|
|
}
|
|
|
|
+ org.bukkit.craftbukkit.SpigotTimings.timerEntityAICollision.stopTiming(); // Spigot
|
|
|
|
|
|
|
|
this.world.methodProfiler.b();
|
|
|
|
this.world.methodProfiler.a("looting");
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
2013-06-07 23:20:25 +00:00
|
|
|
index 16df63f..523d83e 100644
|
2013-02-26 17:21:40 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
|
|
@@ -6,7 +6,6 @@ import java.security.KeyPair;
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Date;
|
|
|
|
-import java.util.Iterator;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.concurrent.Callable;
|
|
|
|
import java.util.logging.Level;
|
2013-03-25 07:57:00 +00:00
|
|
|
@@ -19,6 +18,7 @@ import jline.console.ConsoleReader;
|
2013-02-26 17:21:40 +00:00
|
|
|
import joptsimple.OptionSet;
|
|
|
|
|
|
|
|
import org.bukkit.World.Environment;
|
|
|
|
+import org.bukkit.craftbukkit.SpigotTimings; // Spigot
|
|
|
|
import org.bukkit.craftbukkit.util.Waitable;
|
|
|
|
import org.bukkit.event.server.RemoteServerCommandEvent;
|
|
|
|
import org.bukkit.event.world.WorldSaveEvent;
|
2013-06-07 23:20:25 +00:00
|
|
|
@@ -402,7 +402,10 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
|
2013-02-26 17:21:40 +00:00
|
|
|
currentTPS = (currentTPS * 0.95) + (1E9 / (curTime - lastTick) * 0.05);
|
|
|
|
lastTick = curTime;
|
|
|
|
MinecraftServer.currentTick++;
|
|
|
|
+ SpigotTimings.serverTickTimer.startTiming();
|
|
|
|
this.q();
|
|
|
|
+ SpigotTimings.serverTickTimer.stopTiming();
|
2013-06-02 01:29:44 +00:00
|
|
|
+ org.spigotmc.CustomTimingsHandler.tick();
|
2013-02-26 17:21:40 +00:00
|
|
|
}
|
|
|
|
// Spigot end
|
|
|
|
} else {
|
2013-06-07 23:20:25 +00:00
|
|
|
@@ -501,6 +504,7 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
|
2013-03-25 07:57:00 +00:00
|
|
|
public void r() {
|
2013-02-26 17:21:40 +00:00
|
|
|
this.methodProfiler.a("levels");
|
|
|
|
|
|
|
|
+ SpigotTimings.schedulerTimer.startTiming(); // Spigot
|
2013-03-25 07:57:00 +00:00
|
|
|
// CraftBukkit start
|
2013-02-26 17:21:40 +00:00
|
|
|
this.server.getScheduler().mainThreadHeartbeat(this.ticks);
|
|
|
|
|
2013-06-07 23:20:25 +00:00
|
|
|
@@ -509,7 +513,10 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
|
2013-02-26 17:21:40 +00:00
|
|
|
processQueue.remove().run();
|
|
|
|
}
|
|
|
|
|
|
|
|
+ SpigotTimings.schedulerTimer.stopTiming(); // Spigot
|
|
|
|
+ SpigotTimings.chunkIOTickTimer.startTiming(); // Spigot
|
|
|
|
org.bukkit.craftbukkit.chunkio.ChunkIOExecutor.tick();
|
|
|
|
+ SpigotTimings.chunkIOTickTimer.stopTiming(); // Spigot
|
|
|
|
|
2013-03-25 07:57:00 +00:00
|
|
|
// Send time updates to everyone, it will get the right time from the world the player is in.
|
2013-02-26 17:21:40 +00:00
|
|
|
if (this.ticks % 20 == 0) {
|
2013-06-07 23:20:25 +00:00
|
|
|
@@ -561,7 +568,9 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
|
2013-02-26 17:21:40 +00:00
|
|
|
|
|
|
|
this.methodProfiler.b();
|
|
|
|
this.methodProfiler.a("tracker");
|
|
|
|
+ worldserver.timings.tracker.startTiming(); // Spigot
|
|
|
|
worldserver.getTracker().updatePlayers();
|
|
|
|
+ worldserver.timings.tracker.stopTiming(); // Spigot
|
|
|
|
this.methodProfiler.b();
|
|
|
|
this.methodProfiler.b();
|
|
|
|
// } // CraftBukkit
|
2013-06-07 23:20:25 +00:00
|
|
|
@@ -570,14 +579,20 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
|
2013-02-26 17:21:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
this.methodProfiler.c("connection");
|
|
|
|
+ SpigotTimings.connectionTimer.startTiming(); // Spigot
|
|
|
|
this.ae().b();
|
|
|
|
+ SpigotTimings.connectionTimer.stopTiming(); // Spigot
|
|
|
|
this.methodProfiler.c("players");
|
|
|
|
+ SpigotTimings.playerListTimer.startTiming(); // Spigot
|
2013-03-15 21:35:56 +00:00
|
|
|
this.s.tick();
|
2013-02-26 17:21:40 +00:00
|
|
|
+ SpigotTimings.playerListTimer.stopTiming(); // Spigot
|
|
|
|
this.methodProfiler.c("tickables");
|
|
|
|
|
|
|
|
+ SpigotTimings.tickablesTimer.startTiming(); // Spigot
|
2013-03-15 21:35:56 +00:00
|
|
|
for (i = 0; i < this.o.size(); ++i) {
|
|
|
|
((IUpdatePlayerListBox) this.o.get(i)).a();
|
2013-02-26 17:21:40 +00:00
|
|
|
}
|
|
|
|
+ SpigotTimings.tickablesTimer.stopTiming(); // Spigot
|
|
|
|
|
|
|
|
this.methodProfiler.b();
|
|
|
|
}
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
|
2013-06-07 23:20:25 +00:00
|
|
|
index 1697b18..a2b63c1 100644
|
2013-02-26 17:21:40 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
|
2013-06-04 07:44:12 +00:00
|
|
|
@@ -968,6 +968,7 @@ public class PlayerConnection extends Connection {
|
2013-02-26 17:21:40 +00:00
|
|
|
// CraftBukkit end
|
|
|
|
|
|
|
|
private void handleCommand(String s) {
|
|
|
|
+ org.bukkit.craftbukkit.SpigotTimings.playerCommandTimer.startTiming(); // Spigot
|
|
|
|
// CraftBukkit start
|
|
|
|
CraftPlayer player = this.getPlayer();
|
|
|
|
|
2013-06-04 07:44:12 +00:00
|
|
|
@@ -975,19 +976,23 @@ public class PlayerConnection extends Connection {
|
2013-02-26 17:21:40 +00:00
|
|
|
this.server.getPluginManager().callEvent(event);
|
|
|
|
|
|
|
|
if (event.isCancelled()) {
|
|
|
|
+ org.bukkit.craftbukkit.SpigotTimings.playerCommandTimer.stopTiming(); // Spigot
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
2013-03-15 21:35:56 +00:00
|
|
|
if (server.logCommands) this.minecraftServer.getLogger().info(event.getPlayer().getName() + " issued server command: " + event.getMessage()); // Spigot
|
2013-02-26 17:21:40 +00:00
|
|
|
if (this.server.dispatchCommand(event.getPlayer(), event.getMessage().substring(1))) {
|
|
|
|
+ org.bukkit.craftbukkit.SpigotTimings.playerCommandTimer.stopTiming(); // Spigot
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
} catch (org.bukkit.command.CommandException ex) {
|
|
|
|
player.sendMessage(org.bukkit.ChatColor.RED + "An internal error occurred while attempting to perform this command");
|
2013-03-25 07:57:00 +00:00
|
|
|
java.util.logging.Logger.getLogger(PlayerConnection.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
2013-02-26 17:21:40 +00:00
|
|
|
+ org.bukkit.craftbukkit.SpigotTimings.playerCommandTimer.stopTiming(); // Spigot
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
+ org.bukkit.craftbukkit.SpigotTimings.playerCommandTimer.stopTiming(); // Spigot
|
|
|
|
// CraftBukkit end
|
|
|
|
|
|
|
|
/* CraftBukkit start - No longer needed as we have already handled it in server.dispatchServerCommand above.
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/TileEntity.java b/src/main/java/net/minecraft/server/TileEntity.java
|
2013-06-02 01:29:44 +00:00
|
|
|
index db3fc42..ffa9bb6 100644
|
2013-02-26 17:21:40 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/TileEntity.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/TileEntity.java
|
|
|
|
@@ -4,10 +4,12 @@ import java.util.HashMap;
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.concurrent.Callable;
|
|
|
|
|
2013-06-02 01:29:44 +00:00
|
|
|
+import org.spigotmc.CustomTimingsHandler; // Spigot
|
2013-02-26 17:21:40 +00:00
|
|
|
import org.bukkit.inventory.InventoryHolder; // CraftBukkit
|
|
|
|
|
|
|
|
public class TileEntity {
|
|
|
|
|
|
|
|
+ public CustomTimingsHandler tickTimer = org.bukkit.craftbukkit.SpigotTimings.getTileEntityTimings(this); // Spigot
|
|
|
|
private static Map a = new HashMap();
|
|
|
|
private static Map b = new HashMap();
|
2013-03-15 21:35:56 +00:00
|
|
|
protected World world;
|
2013-02-26 17:21:40 +00:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
|
2013-05-03 23:24:15 +00:00
|
|
|
index 6d59bc3..feb657b 100644
|
2013-02-26 17:21:40 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/World.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/World.java
|
|
|
|
@@ -13,6 +13,7 @@ import java.util.concurrent.Callable;
|
|
|
|
// CraftBukkit start
|
|
|
|
import org.bukkit.Bukkit;
|
|
|
|
import org.bukkit.craftbukkit.util.LongHashSet;
|
|
|
|
+import org.bukkit.craftbukkit.SpigotTimings; // Spigot
|
|
|
|
import org.bukkit.craftbukkit.util.UnsafeList;
|
|
|
|
import org.bukkit.generator.ChunkGenerator;
|
|
|
|
import org.bukkit.craftbukkit.CraftServer;
|
2013-04-13 07:06:23 +00:00
|
|
|
@@ -114,6 +115,8 @@ public abstract class World implements IBlockAccess {
|
2013-02-26 17:21:40 +00:00
|
|
|
final Object chunkLock = new Object();
|
|
|
|
private byte chunkTickRadius;
|
|
|
|
|
|
|
|
+ public final SpigotTimings.WorldTimingsHandler timings; // Spigot
|
|
|
|
+
|
|
|
|
public CraftWorld getWorld() {
|
|
|
|
return this.world;
|
|
|
|
}
|
2013-04-13 07:06:23 +00:00
|
|
|
@@ -193,6 +196,7 @@ public abstract class World implements IBlockAccess {
|
2013-02-26 17:21:40 +00:00
|
|
|
this.a();
|
|
|
|
|
|
|
|
this.getServer().addWorld(this.world); // CraftBukkit
|
|
|
|
+ timings = new SpigotTimings.WorldTimingsHandler(this); // Spigot
|
|
|
|
}
|
|
|
|
|
|
|
|
protected abstract IChunkProvider j();
|
2013-04-13 07:06:23 +00:00
|
|
|
@@ -1271,6 +1275,7 @@ public abstract class World implements IBlockAccess {
|
2013-02-26 17:21:40 +00:00
|
|
|
this.f.clear();
|
|
|
|
this.methodProfiler.c("regular");
|
|
|
|
|
|
|
|
+ timings.entityTick.startTiming(); // Spigot
|
|
|
|
for (i = 0; i < this.entityList.size(); ++i) {
|
|
|
|
entity = (Entity) this.entityList.get(i);
|
|
|
|
|
2013-04-13 07:06:23 +00:00
|
|
|
@@ -1293,7 +1298,9 @@ public abstract class World implements IBlockAccess {
|
2013-02-26 17:21:40 +00:00
|
|
|
this.methodProfiler.a("tick");
|
|
|
|
if (!entity.dead) {
|
|
|
|
try {
|
|
|
|
+ SpigotTimings.tickEntityTimer.startTiming(); // Spigot
|
|
|
|
this.playerJoinedWorld(entity);
|
|
|
|
+ SpigotTimings.tickEntityTimer.stopTiming(); // Spigot
|
|
|
|
} catch (Throwable throwable1) {
|
|
|
|
crashreport = CrashReport.a(throwable1, "Ticking entity");
|
|
|
|
crashreportsystemdetails = crashreport.a("Entity being ticked");
|
2013-04-13 07:06:23 +00:00
|
|
|
@@ -1318,7 +1325,9 @@ public abstract class World implements IBlockAccess {
|
2013-02-26 17:21:40 +00:00
|
|
|
this.methodProfiler.b();
|
|
|
|
}
|
|
|
|
|
|
|
|
+ timings.entityTick.stopTiming(); // Spigot
|
|
|
|
this.methodProfiler.c("tileEntities");
|
|
|
|
+ timings.tileEntityTick.startTiming(); // Spigot
|
2013-03-15 21:35:56 +00:00
|
|
|
this.N = true;
|
2013-02-26 17:21:40 +00:00
|
|
|
Iterator iterator = this.tileEntityList.iterator();
|
|
|
|
|
2013-04-13 07:06:23 +00:00
|
|
|
@@ -1333,8 +1342,11 @@ public abstract class World implements IBlockAccess {
|
2013-02-26 17:21:40 +00:00
|
|
|
|
|
|
|
if (!tileentity.r() && tileentity.o() && this.isLoaded(tileentity.x, tileentity.y, tileentity.z)) {
|
|
|
|
try {
|
|
|
|
+ tileentity.tickTimer.startTiming(); // Spigot
|
2013-03-15 21:35:56 +00:00
|
|
|
tileentity.h();
|
2013-02-26 17:21:40 +00:00
|
|
|
+ tileentity.tickTimer.stopTiming(); // Spigot
|
|
|
|
} catch (Throwable throwable2) {
|
|
|
|
+ tileentity.tickTimer.stopTiming(); // Spigot
|
|
|
|
crashreport = CrashReport.a(throwable2, "Ticking tile entity");
|
|
|
|
crashreportsystemdetails = crashreport.a("Tile entity being ticked");
|
2013-03-15 21:35:56 +00:00
|
|
|
tileentity.a(crashreportsystemdetails);
|
2013-04-13 07:06:23 +00:00
|
|
|
@@ -1354,6 +1366,8 @@ public abstract class World implements IBlockAccess {
|
2013-02-26 17:21:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
+ timings.tileEntityTick.stopTiming(); // Spigot
|
|
|
|
+ timings.tileEntityPending.startTiming(); // Spigot
|
2013-03-15 21:35:56 +00:00
|
|
|
this.N = false;
|
2013-02-26 17:21:40 +00:00
|
|
|
if (!this.b.isEmpty()) {
|
|
|
|
this.tileEntityList.removeAll(this.b);
|
2013-04-13 07:06:23 +00:00
|
|
|
@@ -1392,6 +1406,7 @@ public abstract class World implements IBlockAccess {
|
2013-02-26 17:21:40 +00:00
|
|
|
this.a.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
+ timings.tileEntityPending.stopTiming(); // Spigot
|
|
|
|
this.methodProfiler.b();
|
|
|
|
this.methodProfiler.b();
|
|
|
|
}
|
2013-04-13 07:06:23 +00:00
|
|
|
@@ -1414,6 +1429,7 @@ public abstract class World implements IBlockAccess {
|
2013-02-26 17:21:40 +00:00
|
|
|
byte b0 = 32;
|
|
|
|
|
2013-03-15 21:35:56 +00:00
|
|
|
if (!flag || this.e(i - b0, 0, j - b0, i + b0, 0, j + b0)) {
|
2013-02-26 17:21:40 +00:00
|
|
|
+ entity.tickTimer.startTiming(); // Spigot
|
2013-03-15 21:35:56 +00:00
|
|
|
entity.U = entity.locX;
|
|
|
|
entity.V = entity.locY;
|
|
|
|
entity.W = entity.locZ;
|
2013-04-13 07:06:23 +00:00
|
|
|
@@ -1475,6 +1491,7 @@ public abstract class World implements IBlockAccess {
|
2013-02-26 17:21:40 +00:00
|
|
|
entity.passenger = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
+ entity.tickTimer.stopTiming(); // Spigot
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
|
2013-06-07 23:21:38 +00:00
|
|
|
index 3a321da..5bbf775 100644
|
2013-02-26 17:21:40 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/WorldServer.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/WorldServer.java
|
2013-04-03 07:20:29 +00:00
|
|
|
@@ -186,9 +186,12 @@ public class WorldServer extends World implements org.bukkit.BlockChangeDelegate
|
2013-02-26 17:21:40 +00:00
|
|
|
// 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.allowMonsters || this.allowAnimals) && (this instanceof WorldServer && this.players.size() > 0)) {
|
|
|
|
+ timings.mobSpawn.startTiming(); // Spigot
|
|
|
|
SpawnerCreature.spawnEntities(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
|
2013-06-07 23:21:38 +00:00
|
|
|
+ timings.doChunkUnload.startTiming(); // Spigot
|
2013-02-26 17:21:40 +00:00
|
|
|
this.methodProfiler.c("chunkSource");
|
|
|
|
this.chunkProvider.unloadChunks();
|
|
|
|
int j = this.a(1.0F);
|
2013-06-07 23:21:38 +00:00
|
|
|
@@ -199,21 +202,36 @@ public class WorldServer extends World implements org.bukkit.BlockChangeDelegate
|
|
|
|
|
|
|
|
this.worldData.setTime(this.worldData.getTime() + 1L);
|
|
|
|
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("tickTiles");
|
|
|
|
+ timings.doTickTiles.startTiming(); // Spigot
|
|
|
|
this.g();
|
|
|
|
+ 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.P.a(this.getTime());
|
|
|
|
+ timings.doPortalForcer.stopTiming(); // Spigot
|
|
|
|
this.methodProfiler.b();
|
|
|
|
+ timings.doSounds.startTiming(); // Spigot
|
2013-04-30 22:33:27 +00:00
|
|
|
this.Z();
|
2013-06-07 23:21:38 +00:00
|
|
|
-
|
|
|
|
+ timings.doSounds.stopTiming(); // Spigot
|
|
|
|
+ timings.doChunkGC.startTiming(); // Spigot
|
2013-02-26 17:21:40 +00:00
|
|
|
this.getWorld().processChunkGC(); // CraftBukkit
|
2013-06-07 23:21:38 +00:00
|
|
|
+ timings.doChunkGC.stopTiming(); // Spigot
|
|
|
|
+
|
2013-02-26 17:21:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public BiomeMeta a(EnumCreatureType enumcreaturetype, int i, int j, int k) {
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/SpigotTimings.java b/src/main/java/org/bukkit/craftbukkit/SpigotTimings.java
|
|
|
|
new file mode 100644
|
2013-06-07 23:21:38 +00:00
|
|
|
index 0000000..f6e507e
|
2013-02-26 17:21:40 +00:00
|
|
|
--- /dev/null
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/SpigotTimings.java
|
2013-06-07 23:21:38 +00:00
|
|
|
@@ -0,0 +1,124 @@
|
2013-02-26 17:21:40 +00:00
|
|
|
+package org.bukkit.craftbukkit;
|
|
|
|
+
|
|
|
|
+import net.minecraft.server.*;
|
2013-06-02 01:29:44 +00:00
|
|
|
+import org.spigotmc.CustomTimingsHandler;
|
2013-02-26 17:21:40 +00:00
|
|
|
+import org.bukkit.scheduler.BukkitTask;
|
|
|
|
+
|
|
|
|
+import java.util.HashMap;
|
|
|
|
+
|
|
|
|
+public class SpigotTimings {
|
|
|
|
+
|
|
|
|
+ public static final CustomTimingsHandler serverTickTimer = new CustomTimingsHandler("** Full Server Tick");
|
|
|
|
+ public static final CustomTimingsHandler playerListTimer = new CustomTimingsHandler("Player List");
|
2013-03-01 23:40:13 +00:00
|
|
|
+ public static final CustomTimingsHandler connectionTimer = new CustomTimingsHandler("Player Tick");
|
2013-02-26 17:21:40 +00:00
|
|
|
+ public static final CustomTimingsHandler tickablesTimer = new CustomTimingsHandler("Tickables");
|
|
|
|
+ public static final CustomTimingsHandler schedulerTimer = new CustomTimingsHandler("Scheduler");
|
|
|
|
+ public static final CustomTimingsHandler chunkIOTickTimer = new CustomTimingsHandler("ChunkIOTick");
|
|
|
|
+ public static final CustomTimingsHandler syncChunkLoadTimer = new CustomTimingsHandler("syncChunkLoad");
|
|
|
|
+
|
|
|
|
+ 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 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) {
|
|
|
|
+ String plugin = task.getOwner().getDescription().getFullName();
|
2013-02-27 05:39:53 +00:00
|
|
|
+ String name = "Task: " + plugin +" Id:";
|
2013-02-26 17:21:40 +00:00
|
|
|
+ if (period > 0) {
|
2013-02-27 05:39:53 +00:00
|
|
|
+ name += "(interval:" + period +")";
|
2013-02-26 17:21:40 +00:00
|
|
|
+ } else {
|
2013-02-27 05:39:53 +00:00
|
|
|
+ name += "(Single)";
|
2013-02-26 17:21:40 +00:00
|
|
|
+ }
|
2013-02-27 05:39:53 +00:00
|
|
|
+ CustomTimingsHandler result = pluginTaskTimingMap.get(name);
|
|
|
|
+ if (result == null) {
|
|
|
|
+ result = new CustomTimingsHandler(name);
|
|
|
|
+ pluginTaskTimingMap.put(name, result);
|
|
|
|
+ }
|
|
|
|
+ return result;
|
2013-02-26 17:21:40 +00:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 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;
|
2013-06-07 23:21:38 +00:00
|
|
|
+ public final CustomTimingsHandler doChunkUnload;
|
|
|
|
+ public final CustomTimingsHandler doPortalForcer;
|
|
|
|
+ public final CustomTimingsHandler doTickPending;
|
|
|
|
+ public final CustomTimingsHandler doTickTiles;
|
|
|
|
+ public final CustomTimingsHandler doVillages;
|
|
|
|
+ public final CustomTimingsHandler doChunkMap;
|
|
|
|
+ public final CustomTimingsHandler doChunkGC;
|
|
|
|
+ public final CustomTimingsHandler doSounds;
|
2013-02-26 17:21:40 +00:00
|
|
|
+ public final CustomTimingsHandler entityTick;
|
|
|
|
+ public final CustomTimingsHandler tileEntityTick;
|
|
|
|
+ public final CustomTimingsHandler tileEntityPending;
|
|
|
|
+ public final CustomTimingsHandler tracker;
|
|
|
|
+
|
|
|
|
+ public WorldTimingsHandler(World server) {
|
|
|
|
+ String name = server.worldData.getName() +" - ";
|
|
|
|
+
|
|
|
|
+ mobSpawn = new CustomTimingsHandler(name + "mobSpawn");
|
2013-06-07 23:21:38 +00:00
|
|
|
+ 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");
|
2013-02-26 17:21:40 +00:00
|
|
|
+ entityTick = new CustomTimingsHandler(name + "entityTick");
|
|
|
|
+ tileEntityTick = new CustomTimingsHandler(name + "tileEntityTick");
|
|
|
|
+ tileEntityPending = new CustomTimingsHandler(name + "tileEntityPending");
|
|
|
|
+ tracker = new CustomTimingsHandler(name + "tracker");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftTask.java b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftTask.java
|
2013-06-02 01:29:44 +00:00
|
|
|
index 55db3ff..d644d08 100644
|
2013-02-26 17:21:40 +00:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftTask.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftTask.java
|
|
|
|
@@ -1,6 +1,8 @@
|
|
|
|
package org.bukkit.craftbukkit.scheduler;
|
|
|
|
|
|
|
|
import org.bukkit.Bukkit;
|
|
|
|
+import org.bukkit.craftbukkit.SpigotTimings; // Spigot
|
2013-06-02 01:29:44 +00:00
|
|
|
+import org.spigotmc.CustomTimingsHandler; // Spigot
|
2013-02-26 17:21:40 +00:00
|
|
|
import org.bukkit.plugin.Plugin;
|
|
|
|
import org.bukkit.scheduler.BukkitTask;
|
|
|
|
|
|
|
|
@@ -22,6 +24,7 @@ class CraftTask implements BukkitTask, Runnable {
|
|
|
|
private final Plugin plugin;
|
|
|
|
private final int id;
|
|
|
|
|
|
|
|
+ CustomTimingsHandler timings = null; // Spigot
|
|
|
|
CraftTask() {
|
|
|
|
this(null, null, -1, -1);
|
|
|
|
}
|
|
|
|
@@ -50,7 +53,22 @@ class CraftTask implements BukkitTask, Runnable {
|
|
|
|
}
|
|
|
|
|
|
|
|
public void run() {
|
|
|
|
+ // Spigot start - Wrap custom timings on Tasks
|
|
|
|
+ if (!Bukkit.getServer().getPluginManager().useTimings()) {
|
|
|
|
+ task.run();
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ if (timings == null && this.getOwner() != null && this.isSync()) {
|
|
|
|
+ timings = SpigotTimings.getPluginTaskTimings(this, period);
|
|
|
|
+ }
|
|
|
|
+ if (timings != null) {
|
|
|
|
+ timings.startTiming();
|
|
|
|
+ }
|
|
|
|
task.run();
|
|
|
|
+ if (timings != null) {
|
|
|
|
+ timings.stopTiming();
|
|
|
|
+ }
|
|
|
|
+ // Spigot end
|
|
|
|
}
|
|
|
|
|
|
|
|
long getPeriod() {
|
|
|
|
--
|
2013-06-02 01:29:44 +00:00
|
|
|
1.8.1.2
|
2013-02-26 17:21:40 +00:00
|
|
|
|