2019-05-20 03:32:41 +02:00
From 20fc8f74ff6be390fce1225aa08b949898f635cf Mon Sep 17 00:00:00 2001
2016-01-09 07:32:38 +01:00
From: Aikar <aikar@aikar.co>
2016-03-03 10:46:26 +01:00
Date: Thu, 3 Mar 2016 04:00:11 -0600
2016-01-09 07:32:38 +01:00
Subject: [PATCH] Timings v2
2016-04-30 03:23:40 +02:00
diff --git a/src/main/java/co/aikar/timings/MinecraftTimings.java b/src/main/java/co/aikar/timings/MinecraftTimings.java
2016-01-10 08:33:27 +01:00
new file mode 100644
2019-05-14 04:20:58 +02:00
index 000000000..3f9fb6f90
2016-01-10 08:33:27 +01:00
--- /dev/null
2016-04-30 03:23:40 +02:00
+++ b/src/main/java/co/aikar/timings/MinecraftTimings.java
2019-04-24 03:00:24 +02:00
@@ -0,0 +1,133 @@
2018-09-03 16:38:28 +02:00
+package co.aikar.timings;
2016-01-10 08:33:27 +01:00
+
2018-09-03 16:04:50 +02:00
+import com.google.common.collect.MapMaker;
2016-01-10 08:33:27 +01:00
+import net.minecraft.server.*;
+import org.bukkit.plugin.Plugin;
+import org.bukkit.scheduler.BukkitTask;
+
+import org.bukkit.craftbukkit.scheduler.CraftTask;
+
2018-09-03 16:04:50 +02:00
+import java.util.Map;
+
2019-04-24 03:00:24 +02:00
+// TODO: Re-implement missing timers
2016-04-30 03:23:40 +02:00
+public final class MinecraftTimings {
2016-01-10 08:33:27 +01:00
+
+ public static final Timing playerListTimer = Timings.ofSafe("Player List");
2017-05-14 20:05:01 +02:00
+ public static final Timing commandFunctionsTimer = Timings.ofSafe("Command Functions");
2016-01-10 08:33:27 +01:00
+ public static final Timing connectionTimer = Timings.ofSafe("Connection Handler");
+ public static final Timing tickablesTimer = Timings.ofSafe("Tickables");
2016-02-24 05:35:34 +01:00
+ public static final Timing minecraftSchedulerTimer = Timings.ofSafe("Minecraft Scheduler");
+ public static final Timing bukkitSchedulerTimer = Timings.ofSafe("Bukkit Scheduler");
2017-02-05 06:13:16 +01:00
+ public static final Timing bukkitSchedulerPendingTimer = Timings.ofSafe("Bukkit Scheduler - Pending");
+ public static final Timing bukkitSchedulerFinishTimer = Timings.ofSafe("Bukkit Scheduler - Finishing");
2016-01-10 08:33:27 +01:00
+ public static final Timing chunkIOTickTimer = Timings.ofSafe("ChunkIOTick");
+ public static final Timing timeUpdateTimer = Timings.ofSafe("Time Update");
+ public static final Timing serverCommandTimer = Timings.ofSafe("Server Command");
2016-10-21 22:42:49 +02:00
+ public static final Timing savePlayers = Timings.ofSafe("Save Players");
2016-01-10 08:33:27 +01:00
+
+ public static final Timing tickEntityTimer = Timings.ofSafe("## tickEntity");
+ public static final Timing tickTileEntityTimer = Timings.ofSafe("## tickTileEntity");
2017-02-05 06:13:16 +01:00
+ public static final Timing packetProcessTimer = Timings.ofSafe("## Packet Processing");
+ public static final Timing scheduledBlocksTimer = Timings.ofSafe("## Scheduled Blocks");
+ public static final Timing structureGenerationTimer = Timings.ofSafe("Structure Generation");
2016-01-10 08:33:27 +01:00
+
+ public static final Timing processQueueTimer = Timings.ofSafe("processQueue");
+
+ public static final Timing playerCommandTimer = Timings.ofSafe("playerCommand");
+
+ public static final Timing entityActivationCheckTimer = Timings.ofSafe("entityActivationCheck");
+
+ public static final Timing antiXrayUpdateTimer = Timings.ofSafe("anti-xray - update");
+ public static final Timing antiXrayObfuscateTimer = Timings.ofSafe("anti-xray - obfuscate");
+
2018-11-24 06:28:04 +01:00
+ private static final Map<Class<?>, String> taskNameCache = new MapMaker().weakKeys().makeMap();
2018-09-03 16:04:50 +02:00
+
2016-04-30 03:23:40 +02:00
+ private MinecraftTimings() {}
2016-01-10 08:33:27 +01:00
+
+ /**
+ * Gets a timer associated with a plugins tasks.
+ * @param bukkitTask
+ * @param period
+ * @return
+ */
+ public static Timing getPluginTaskTimings(BukkitTask bukkitTask, long period) {
+ if (!bukkitTask.isSync()) {
2019-03-26 06:31:59 +01:00
+ return NullTimingHandler.NULL;
2016-01-10 08:33:27 +01:00
+ }
+ Plugin plugin;
+
2018-11-24 06:28:04 +01:00
+ CraftTask craftTask = (CraftTask) bukkitTask;
2016-01-10 08:33:27 +01:00
+
2018-11-24 06:28:04 +01:00
+ final Class<?> taskClass = craftTask.getTaskClass();
2016-01-10 08:33:27 +01:00
+ if (bukkitTask.getOwner() != null) {
+ plugin = bukkitTask.getOwner();
+ } else {
+ plugin = TimingsManager.getPluginByClassloader(taskClass);
+ }
+
2018-09-03 16:04:50 +02:00
+ final String taskname = taskNameCache.computeIfAbsent(taskClass, clazz ->
+ clazz.isAnonymousClass() || clazz.isLocalClass()
+ ? clazz.getName()
+ : clazz.getCanonicalName());
2016-01-10 08:33:27 +01:00
+
2017-02-05 06:13:16 +01:00
+ StringBuilder name = new StringBuilder(64);
+ name.append("Task: ").append(taskname);
2016-01-10 08:33:27 +01:00
+ if (period > 0) {
2017-02-05 06:13:16 +01:00
+ name.append(" (interval:").append(period).append(")");
2016-01-10 08:33:27 +01:00
+ } else {
2017-02-05 06:13:16 +01:00
+ name.append(" (Single)");
2016-01-10 08:33:27 +01:00
+ }
+
+ if (plugin == null) {
2017-02-05 06:13:16 +01:00
+ return Timings.ofSafe(null, name.toString());
2016-01-10 08:33:27 +01:00
+ }
+
2017-02-05 06:13:16 +01:00
+ return Timings.ofSafe(plugin, name.toString());
2016-01-10 08:33:27 +01:00
+ }
+
+ /**
+ * Get a named timer for the specified entity type to track type specific timings.
+ * @param entity
+ * @return
+ */
+ public static Timing getEntityTimings(Entity entity) {
+ String entityType = entity.getClass().getName();
+ return Timings.ofSafe("Minecraft", "## tickEntity - " + entityType, tickEntityTimer);
+ }
+
+ /**
+ * Get a named timer for the specified tile entity type to track type specific timings.
+ * @param entity
+ * @return
+ */
+ public static Timing getTileEntityTimings(TileEntity entity) {
+ String entityType = entity.getClass().getName();
+ return Timings.ofSafe("Minecraft", "## tickTileEntity - " + entityType, tickTileEntityTimer);
+ }
+ public static Timing getCancelTasksTimer() {
+ return Timings.ofSafe("Cancel Tasks");
+ }
+ public static Timing getCancelTasksTimer(Plugin plugin) {
+ return Timings.ofSafe(plugin, "Cancel Tasks");
+ }
+
+ public static void stopServer() {
+ TimingsManager.stopServer();
+ }
+
+ public static Timing getBlockTiming(Block block) {
2018-07-15 03:53:17 +02:00
+ return Timings.ofSafe("## Scheduled Block: " + block.toString(), scheduledBlocksTimer);
2016-01-10 08:33:27 +01:00
+ }
2018-07-15 03:53:17 +02:00
+/*
2016-08-28 02:36:26 +02:00
+ public static Timing getStructureTiming(StructureGenerator structureGenerator) {
2017-02-05 06:13:16 +01:00
+ return Timings.ofSafe("Structure Generator - " + structureGenerator.getName(), structureGenerationTimer);
2018-07-15 03:53:17 +02:00
+ }*/
2017-02-05 06:13:16 +01:00
+
+ public static Timing getPacketTiming(Packet packet) {
+ return Timings.ofSafe("## Packet - " + packet.getClass().getSimpleName(), packetProcessTimer);
2016-08-28 02:36:26 +02:00
+ }
2018-08-28 00:30:58 +02:00
+
+ public static Timing getCommandFunctionTiming(CustomFunction function) {
+ return Timings.ofSafe("Command Function - " + function.getMinecraftKey().toString());
+ }
2016-08-28 02:36:26 +02:00
+}
2016-01-10 08:33:27 +01:00
diff --git a/src/main/java/co/aikar/timings/WorldTimingsHandler.java b/src/main/java/co/aikar/timings/WorldTimingsHandler.java
new file mode 100644
2019-05-14 04:20:58 +02:00
index 000000000..d5d3b2a20
2016-01-10 08:33:27 +01:00
--- /dev/null
+++ b/src/main/java/co/aikar/timings/WorldTimingsHandler.java
2019-04-24 03:00:24 +02:00
@@ -0,0 +1,105 @@
2016-01-10 08:33:27 +01:00
+package co.aikar.timings;
+
+import net.minecraft.server.World;
2018-07-15 03:53:17 +02:00
+import net.minecraft.server.WorldServer;
2016-01-10 08:33:27 +01:00
+
+/**
+ * Set of timers per world, to track world specific timings.
+ */
2019-04-24 03:00:24 +02:00
+// TODO: Re-implement missing timers
2016-01-10 08:33:27 +01:00
+public class WorldTimingsHandler {
+ public final Timing mobSpawn;
+ public final Timing doChunkUnload;
+ public final Timing doPortalForcer;
+ public final Timing scheduledBlocks;
+ public final Timing scheduledBlocksCleanup;
+ public final Timing scheduledBlocksTicking;
+ public final Timing chunkTicks;
2016-08-28 02:36:26 +02:00
+ public final Timing lightChunk;
2016-01-10 08:33:27 +01:00
+ public final Timing chunkTicksBlocks;
+ public final Timing doVillages;
+ public final Timing doChunkMap;
2016-06-05 06:10:50 +02:00
+ public final Timing doChunkMapUpdate;
+ public final Timing doChunkMapToUpdate;
+ public final Timing doChunkMapSortMissing;
+ public final Timing doChunkMapSortSendToPlayers;
+ public final Timing doChunkMapPlayersNeedingChunks;
+ public final Timing doChunkMapPendingSendToPlayers;
+ public final Timing doChunkMapUnloadChunks;
2016-01-10 08:33:27 +01:00
+ public final Timing doChunkGC;
+ public final Timing doSounds;
+ public final Timing entityRemoval;
+ public final Timing entityTick;
+ public final Timing tileEntityTick;
+ public final Timing tileEntityPending;
2016-04-30 03:23:40 +02:00
+ public final Timing tracker1;
+ public final Timing tracker2;
2016-01-10 08:33:27 +01:00
+ public final Timing doTick;
+ public final Timing tickEntities;
+
+ public final Timing syncChunkLoadTimer;
+ public final Timing syncChunkLoadDataTimer;
+ public final Timing syncChunkLoadStructuresTimer;
+ public final Timing syncChunkLoadPostTimer;
2018-07-15 03:53:17 +02:00
+ public final Timing syncChunkLoadPopulateTimer;
+ public final Timing chunkLoadLevelTimer;
2016-08-28 02:36:26 +02:00
+ public final Timing chunkGeneration;
+ public final Timing chunkIOStage1;
+ public final Timing chunkIOStage2;
2016-10-21 22:42:49 +02:00
+ public final Timing worldSave;
+ public final Timing worldSaveChunks;
+ public final Timing worldSaveLevel;
+ public final Timing chunkSaveData;
2016-01-10 08:33:27 +01:00
+
+ public WorldTimingsHandler(World server) {
+ String name = server.worldData.getName() +" - ";
+
+ mobSpawn = Timings.ofSafe(name + "mobSpawn");
+ doChunkUnload = Timings.ofSafe(name + "doChunkUnload");
+ scheduledBlocks = Timings.ofSafe(name + "Scheduled Blocks");
+ scheduledBlocksCleanup = Timings.ofSafe(name + "Scheduled Blocks - Cleanup");
+ scheduledBlocksTicking = Timings.ofSafe(name + "Scheduled Blocks - Ticking");
+ chunkTicks = Timings.ofSafe(name + "Chunk Ticks");
2016-08-28 02:36:26 +02:00
+ lightChunk = Timings.ofSafe(name + "Light Chunk");
2016-01-10 08:33:27 +01:00
+ chunkTicksBlocks = Timings.ofSafe(name + "Chunk Ticks - Blocks");
+ doVillages = Timings.ofSafe(name + "doVillages");
+ doChunkMap = Timings.ofSafe(name + "doChunkMap");
2016-06-05 06:10:50 +02:00
+ doChunkMapUpdate = Timings.ofSafe(name + "doChunkMap - Update");
+ doChunkMapToUpdate = Timings.ofSafe(name + "doChunkMap - To Update");
+ doChunkMapSortMissing = Timings.ofSafe(name + "doChunkMap - Sort Missing");
+ doChunkMapSortSendToPlayers = Timings.ofSafe(name + "doChunkMap - Sort Send To Players");
+ doChunkMapPlayersNeedingChunks = Timings.ofSafe(name + "doChunkMap - Players Needing Chunks");
+ doChunkMapPendingSendToPlayers = Timings.ofSafe(name + "doChunkMap - Pending Send To Players");
+ doChunkMapUnloadChunks = Timings.ofSafe(name + "doChunkMap - Unload Chunks");
2016-01-10 08:33:27 +01:00
+ doSounds = Timings.ofSafe(name + "doSounds");
+ doChunkGC = Timings.ofSafe(name + "doChunkGC");
+ doPortalForcer = Timings.ofSafe(name + "doPortalForcer");
+ entityTick = Timings.ofSafe(name + "entityTick");
+ entityRemoval = Timings.ofSafe(name + "entityRemoval");
+ tileEntityTick = Timings.ofSafe(name + "tileEntityTick");
+ tileEntityPending = Timings.ofSafe(name + "tileEntityPending");
+
+ syncChunkLoadTimer = Timings.ofSafe(name + "syncChunkLoad");
+ syncChunkLoadDataTimer = Timings.ofSafe(name + "syncChunkLoad - Data");
2016-08-28 02:36:26 +02:00
+ syncChunkLoadStructuresTimer = Timings.ofSafe(name + "chunkLoad - recreateStructures");
2016-01-10 08:33:27 +01:00
+ syncChunkLoadPostTimer = Timings.ofSafe(name + "chunkLoad - Post");
2018-07-15 03:53:17 +02:00
+ syncChunkLoadPopulateTimer = Timings.ofSafe(name + "chunkLoad - Populate");
+ chunkLoadLevelTimer = Timings.ofSafe(name + "chunkLoad - Load Level");
2016-08-28 02:36:26 +02:00
+ chunkGeneration = Timings.ofSafe(name + "chunkGeneration");
+ chunkIOStage1 = Timings.ofSafe(name + "ChunkIO Stage 1 - DiskIO");
+ chunkIOStage2 = Timings.ofSafe(name + "ChunkIO Stage 2 - Post Load");
2016-10-21 22:42:49 +02:00
+ worldSave = Timings.ofSafe(name + "World Save");
+ worldSaveLevel = Timings.ofSafe(name + "World Save - Level");
+ worldSaveChunks = Timings.ofSafe(name + "World Save - Chunks");
+ chunkSaveData = Timings.ofSafe(name + "Chunk Save - Data");
2016-01-10 08:33:27 +01:00
+
2016-04-30 03:23:40 +02:00
+ tracker1 = Timings.ofSafe(name + "tracker stage 1");
+ tracker2 = Timings.ofSafe(name + "tracker stage 2");
2016-01-10 08:33:27 +01:00
+ doTick = Timings.ofSafe(name + "doTick");
+ tickEntities = Timings.ofSafe(name + "tickEntities");
+ }
2018-07-15 03:53:17 +02:00
+
+ public static Timing getTickList(WorldServer worldserver, String timingsType) {
+ return Timings.ofSafe(worldserver.getWorldData().getName() + " - Scheduled " + timingsType);
+ }
2016-01-10 08:33:27 +01:00
+}
2016-03-01 00:09:49 +01:00
diff --git a/src/main/java/com/destroystokyo/paper/PaperConfig.java b/src/main/java/com/destroystokyo/paper/PaperConfig.java
2019-05-14 04:20:58 +02:00
index 5518ec1e5..0c65afccf 100644
2016-03-01 00:09:49 +01:00
--- a/src/main/java/com/destroystokyo/paper/PaperConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java
2016-05-02 05:54:08 +02:00
@@ -14,11 +14,14 @@ import java.util.concurrent.TimeUnit;
2016-03-01 00:09:49 +01:00
import java.util.logging.Level;
2016-05-02 05:54:08 +02:00
import java.util.regex.Pattern;
2016-03-01 00:09:49 +01:00
+import com.google.common.collect.Lists;
import net.minecraft.server.MinecraftServer;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.YamlConfiguration;
+import co.aikar.timings.Timings;
+import co.aikar.timings.TimingsManager;
public class PaperConfig {
2019-05-06 09:20:16 +02:00
@@ -187,4 +190,27 @@ public class PaperConfig {
2016-03-25 05:59:37 +01:00
config.addDefault(path, def);
return config.getString(path, config.getString(path));
2016-03-01 00:09:49 +01:00
}
+
2019-05-06 09:20:16 +02:00
+ public static String timingsServerName;
2016-03-01 00:09:49 +01:00
+ private static void timings() {
+ boolean timings = getBoolean("timings.enabled", true);
+ boolean verboseTimings = getBoolean("timings.verbose", true);
+ TimingsManager.privacy = getBoolean("timings.server-name-privacy", false);
+ TimingsManager.hiddenConfigs = getList("timings.hidden-config-entries", Lists.newArrayList("database", "settings.bungeecord-addresses"));
+ int timingHistoryInterval = getInt("timings.history-interval", 300);
+ int timingHistoryLength = getInt("timings.history-length", 3600);
2019-05-06 09:20:16 +02:00
+ timingsServerName = getString("timings.server-name", "Unknown Server");
2016-03-01 00:09:49 +01:00
+
+
+ Timings.setVerboseTimingsEnabled(verboseTimings);
+ Timings.setTimingsEnabled(timings);
+ Timings.setHistoryInterval(timingHistoryInterval * 20);
+ Timings.setHistoryLength(timingHistoryLength * 20);
+
2017-03-25 04:18:58 +01:00
+ log("Timings: " + timings +
2016-03-01 00:09:49 +01:00
+ " - Verbose: " + verboseTimings +
+ " - Interval: " + timeSummary(Timings.getHistoryInterval() / 20) +
2019-05-06 09:20:16 +02:00
+ " - Length: " + timeSummary(Timings.getHistoryLength() / 20) +
+ " - Server Name: " + timingsServerName);
2016-03-01 00:09:49 +01:00
+ }
}
2016-01-09 07:32:38 +01:00
diff --git a/src/main/java/net/minecraft/server/Block.java b/src/main/java/net/minecraft/server/Block.java
2019-05-14 04:20:58 +02:00
index afa9f0c1e..85a5776b0 100644
2016-01-09 07:32:38 +01:00
--- a/src/main/java/net/minecraft/server/Block.java
+++ b/src/main/java/net/minecraft/server/Block.java
2019-05-14 04:20:58 +02:00
@@ -32,6 +32,15 @@ public class Block implements IMaterial {
2019-04-24 03:00:24 +02:00
protected final boolean q;
2018-08-26 20:11:49 +02:00
protected final SoundEffectType stepSound;
protected final Material material;
+ // Paper start
2016-01-10 08:33:27 +01:00
+ public co.aikar.timings.Timing timing;
+ public co.aikar.timings.Timing getTiming() {
2016-01-09 07:32:38 +01:00
+ if (timing == null) {
2016-04-30 03:23:40 +02:00
+ timing = co.aikar.timings.MinecraftTimings.getBlockTiming(this);
2016-01-09 07:32:38 +01:00
+ }
+ return timing;
+ }
2016-03-01 00:09:49 +01:00
+ // Paper end
2019-04-24 03:00:24 +02:00
protected final MaterialMapColor t;
2018-08-26 20:11:49 +02:00
private final float frictionFactor;
protected final BlockStateList<Block, IBlockData> blockStateList;
2018-09-29 01:31:59 +02:00
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
2019-05-20 03:32:41 +02:00
index 937fcd7fa..d62c84516 100644
2018-09-29 01:31:59 +02:00
--- a/src/main/java/net/minecraft/server/Chunk.java
+++ b/src/main/java/net/minecraft/server/Chunk.java
2019-05-14 04:20:58 +02:00
@@ -547,6 +547,7 @@ public class Chunk implements IChunkAccess {
2018-09-29 01:31:59 +02:00
server.getPluginManager().callEvent(new org.bukkit.event.world.ChunkLoadEvent(this.bukkitChunk, this.needsDecoration));
if (this.needsDecoration) {
2019-05-20 03:32:41 +02:00
+ try (co.aikar.timings.Timing ignored = this.world.timings.syncChunkLoadPopulateTimer.startTiming()) { // Paper
2018-09-29 01:31:59 +02:00
java.util.Random random = new java.util.Random();
random.setSeed(world.getSeed());
2019-04-24 03:00:24 +02:00
long xRand = random.nextLong() / 2L * 2L + 1L;
2019-05-14 04:20:58 +02:00
@@ -565,6 +566,7 @@ public class Chunk implements IChunkAccess {
2019-04-24 03:00:24 +02:00
}
2018-09-29 01:31:59 +02:00
}
server.getPluginManager().callEvent(new org.bukkit.event.world.ChunkPopulateEvent(bukkitChunk));
2019-05-20 03:32:41 +02:00
+ } // Paper
2018-09-29 01:31:59 +02:00
}
}
2018-07-15 03:53:17 +02:00
}
2016-10-21 22:42:49 +02:00
diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java
2019-05-14 04:20:58 +02:00
index 4cc3e1217..cbe1353ac 100644
2016-10-21 22:42:49 +02:00
--- a/src/main/java/net/minecraft/server/ChunkProviderServer.java
+++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java
2019-05-14 04:20:58 +02:00
@@ -234,7 +234,9 @@ public class ChunkProviderServer extends IChunkProvider {
2019-04-24 03:00:24 +02:00
}
2018-08-26 20:11:49 +02:00
2019-04-24 03:00:24 +02:00
public void save(boolean flag) {
+ try (co.aikar.timings.Timing timed = world.timings.chunkSaveData.startTiming()) { // Paper - Timings
this.playerChunkMap.save(flag);
+ } // Paper - Timings
}
@Override
2019-05-14 04:20:58 +02:00
@@ -352,9 +354,9 @@ public class ChunkProviderServer extends IChunkProvider {
2019-04-24 03:00:24 +02:00
this.world.getMethodProfiler().exit();
}
2019-05-14 04:20:58 +02:00
2019-04-24 03:00:24 +02:00
- this.world.timings.doTickTiles.startTiming(); // Spigot
+ this.world.timings.chunkTicks.startTiming(); // Spigot // Paper
2019-05-14 04:20:58 +02:00
this.world.a(chunk, k);
2019-04-24 03:00:24 +02:00
- this.world.timings.doTickTiles.stopTiming(); // Spigot
+ this.world.timings.chunkTicks.stopTiming(); // Spigot // Paper
}
}
}
2019-05-14 04:20:58 +02:00
@@ -368,9 +370,7 @@ public class ChunkProviderServer extends IChunkProvider {
this.world.getMethodProfiler().exit();
2018-07-22 07:27:46 +02:00
}
2019-04-24 03:00:24 +02:00
- this.world.timings.tracker.startTiming(); // Spigot
this.playerChunkMap.g();
- this.world.timings.tracker.stopTiming(); // Spigot
2016-10-21 22:42:49 +02:00
}
2019-04-24 03:00:24 +02:00
@Override
2016-08-28 02:36:26 +02:00
diff --git a/src/main/java/net/minecraft/server/ChunkRegionLoader.java b/src/main/java/net/minecraft/server/ChunkRegionLoader.java
2019-05-14 04:20:58 +02:00
index e4c021a45..2b8148fbd 100644
2016-08-28 02:36:26 +02:00
--- a/src/main/java/net/minecraft/server/ChunkRegionLoader.java
+++ b/src/main/java/net/minecraft/server/ChunkRegionLoader.java
2018-07-15 03:53:17 +02:00
@@ -1,5 +1,6 @@
package net.minecraft.server;
2016-08-28 02:36:26 +02:00
2018-07-15 03:53:17 +02:00
+import co.aikar.timings.Timings;
import com.google.common.collect.Maps;
2019-04-24 03:00:24 +02:00
import it.unimi.dsi.fastutil.longs.LongOpenHashSet;
import it.unimi.dsi.fastutil.longs.LongSet;
2019-05-14 04:20:58 +02:00
@@ -435,7 +436,7 @@ public class ChunkRegionLoader {
2019-04-24 03:00:24 +02:00
private static void loadEntities(NBTTagCompound nbttagcompound, Chunk chunk) {
2018-07-15 03:53:17 +02:00
NBTTagList nbttaglist = nbttagcompound.getList("Entities", 10);
World world = chunk.getWorld();
2016-08-28 02:36:26 +02:00
- world.timings.syncChunkLoadEntitiesTimer.startTiming(); // Spigot
2018-07-15 03:53:17 +02:00
+ world.timings.chunkLoadLevelTimer.startTiming(); // Spigot
2016-08-28 02:36:26 +02:00
2018-07-15 03:53:17 +02:00
for (int i = 0; i < nbttaglist.size(); ++i) {
NBTTagCompound nbttagcompound1 = nbttaglist.getCompound(i);
2019-05-14 04:20:58 +02:00
@@ -447,8 +448,6 @@ public class ChunkRegionLoader {
2019-04-24 03:00:24 +02:00
chunk.d(true);
2016-08-28 02:36:26 +02:00
}
2018-07-15 03:53:17 +02:00
2016-08-28 02:36:26 +02:00
- world.timings.syncChunkLoadEntitiesTimer.stopTiming(); // Spigot
- world.timings.syncChunkLoadTileEntitiesTimer.startTiming(); // Spigot
2018-07-15 03:53:17 +02:00
NBTTagList nbttaglist1 = nbttagcompound.getList("TileEntities", 10);
2016-08-28 02:36:26 +02:00
2018-07-15 03:53:17 +02:00
for (int j = 0; j < nbttaglist1.size(); ++j) {
2019-05-14 04:20:58 +02:00
@@ -465,7 +464,7 @@ public class ChunkRegionLoader {
2018-07-15 03:53:17 +02:00
}
2016-08-28 02:36:26 +02:00
}
}
- world.timings.syncChunkLoadTileEntitiesTimer.stopTiming(); // Spigot
2019-05-14 04:20:58 +02:00
+ world.timings.chunkLoadLevelTimer.stopTiming(); // Paper
2016-08-28 02:36:26 +02:00
}
2018-07-15 03:53:17 +02:00
2018-08-28 00:30:58 +02:00
diff --git a/src/main/java/net/minecraft/server/CustomFunction.java b/src/main/java/net/minecraft/server/CustomFunction.java
2019-05-14 04:20:58 +02:00
index 46e7737ca..a3ef94306 100644
2018-08-28 00:30:58 +02:00
--- a/src/main/java/net/minecraft/server/CustomFunction.java
+++ b/src/main/java/net/minecraft/server/CustomFunction.java
2019-04-24 03:00:24 +02:00
@@ -13,12 +13,22 @@ public class CustomFunction {
2018-08-28 00:30:58 +02:00
private final CustomFunction.c[] a;
private final MinecraftKey b;
+ // Paper start
+ public co.aikar.timings.Timing timing;
+ public co.aikar.timings.Timing getTiming() {
+ if (timing == null) {
+ timing = co.aikar.timings.MinecraftTimings.getCommandFunctionTiming(this);
+ }
+ return timing;
+ }
+ // Paper end
public CustomFunction(MinecraftKey minecraftkey, CustomFunction.c[] acustomfunction_c) {
this.b = minecraftkey;
this.a = acustomfunction_c;
}
+ public MinecraftKey getMinecraftKey() { return this.a(); } // Paper - OBFHELPER
public MinecraftKey a() {
return this.b;
}
diff --git a/src/main/java/net/minecraft/server/CustomFunctionData.java b/src/main/java/net/minecraft/server/CustomFunctionData.java
2019-05-14 04:20:58 +02:00
index 9c9eef0ad..b42fbf2c6 100644
2018-08-28 00:30:58 +02:00
--- a/src/main/java/net/minecraft/server/CustomFunctionData.java
+++ b/src/main/java/net/minecraft/server/CustomFunctionData.java
2019-05-14 04:20:58 +02:00
@@ -101,7 +101,7 @@ public class CustomFunctionData implements IResourcePackListener {
2018-08-28 00:30:58 +02:00
return 0;
} else {
- try {
+ try (co.aikar.timings.Timing timing = customfunction.getTiming().startTiming()) { // Paper
2019-05-14 04:20:58 +02:00
this.h = true;
2018-08-28 00:30:58 +02:00
int j = 0;
CustomFunction.c[] acustomfunction_c = customfunction.b();
2016-01-09 07:32:38 +01:00
diff --git a/src/main/java/net/minecraft/server/DedicatedServer.java b/src/main/java/net/minecraft/server/DedicatedServer.java
2019-05-14 04:20:58 +02:00
index b60956218..19e2df309 100644
2016-01-09 07:32:38 +01:00
--- a/src/main/java/net/minecraft/server/DedicatedServer.java
+++ b/src/main/java/net/minecraft/server/DedicatedServer.java
2019-04-24 03:00:24 +02:00
@@ -31,7 +31,7 @@ import org.apache.logging.log4j.Level;
2016-01-09 07:32:38 +01:00
2018-07-15 03:53:17 +02:00
import org.bukkit.command.CommandSender;
2016-01-09 07:32:38 +01:00
import org.bukkit.craftbukkit.LoggerOutputStream;
-import org.bukkit.craftbukkit.SpigotTimings; // Spigot
2016-04-30 03:23:40 +02:00
+import co.aikar.timings.MinecraftTimings; // Paper
2016-01-09 07:32:38 +01:00
import org.bukkit.event.server.ServerCommandEvent;
import org.bukkit.craftbukkit.util.Waitable;
import org.bukkit.event.server.RemoteServerCommandEvent;
2019-04-24 03:00:24 +02:00
@@ -428,7 +428,7 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer
2016-04-30 03:23:40 +02:00
}
2018-12-17 06:18:06 +01:00
public void handleCommandQueue() {
2016-04-30 03:23:40 +02:00
- SpigotTimings.serverCommandTimer.startTiming(); // Spigot
+ MinecraftTimings.serverCommandTimer.startTiming(); // Spigot
while (!this.serverCommandQueue.isEmpty()) {
ServerCommand servercommand = (ServerCommand) this.serverCommandQueue.remove(0);
2019-04-24 03:00:24 +02:00
@@ -443,7 +443,7 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer
2016-04-30 03:23:40 +02:00
// CraftBukkit end
}
- SpigotTimings.serverCommandTimer.stopTiming(); // Spigot
+ MinecraftTimings.serverCommandTimer.stopTiming(); // Spigot
}
2019-04-24 03:00:24 +02:00
@Override
@@ -681,7 +681,20 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer
2017-02-05 04:47:39 +01:00
return remoteControlCommandListener.getMessages();
}
};
- processQueue.add(waitable);
+ // Paper start
+ if (s.toLowerCase().startsWith("timings") && s.toLowerCase().matches("timings (report|paste|get|merged|seperate)")) {
+ org.bukkit.command.BufferedCommandSender sender = new org.bukkit.command.BufferedCommandSender();
+ waitable = new Waitable<String>() {
+ @Override
+ protected String evaluate() {
+ return sender.getBuffer();
+ }
+ };
+ co.aikar.timings.Timings.generateReport(new co.aikar.timings.TimingsReportListener(sender, waitable));
+ } else {
+ processQueue.add(waitable);
+ }
+ // Paper end
try {
return waitable.get();
} catch (java.util.concurrent.ExecutionException e) {
2016-01-09 07:32:38 +01:00
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
2019-05-14 04:20:58 +02:00
index 7fc4af565..e52f0610f 100644
2016-01-09 07:32:38 +01:00
--- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java
2019-04-25 08:53:51 +02:00
@@ -29,7 +29,8 @@ import org.bukkit.command.CommandSender;
2016-03-01 00:09:49 +01:00
import org.bukkit.entity.Hanging;
2016-01-09 07:32:38 +01:00
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Vehicle;
-import org.spigotmc.CustomTimingsHandler; // Spigot
2016-04-30 03:23:40 +02:00
+import co.aikar.timings.MinecraftTimings; // Paper
2016-03-01 00:09:49 +01:00
+import co.aikar.timings.Timing; // Paper
2016-01-09 07:32:38 +01:00
import org.bukkit.event.entity.EntityCombustByEntityEvent;
import org.bukkit.event.hanging.HangingBreakByEntityEvent;
2016-03-01 00:09:49 +01:00
import org.bukkit.event.vehicle.VehicleBlockCollisionEvent;
2019-05-06 04:58:04 +02:00
@@ -161,7 +162,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
2017-11-08 17:13:57 +01:00
public boolean valid;
public org.bukkit.projectiles.ProjectileSource projectileSource; // For projectiles only
public boolean forceExplosionKnockback; // SPIGOT-949
2016-01-09 07:32:38 +01:00
- public CustomTimingsHandler tickTimer = org.bukkit.craftbukkit.SpigotTimings.getEntityTimings(this); // Spigot
2016-04-30 03:23:40 +02:00
+ public Timing tickTimer = MinecraftTimings.getEntityTimings(this); // Paper
2016-03-01 00:09:49 +01:00
// Spigot start
2016-01-09 07:32:38 +01:00
public final byte activationType = org.spigotmc.ActivationRange.initializeEntityActivationType(this);
public final boolean defaultActivationState;
2019-05-06 04:58:04 +02:00
@@ -483,7 +484,6 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
2016-03-01 00:09:49 +01:00
}
2016-01-09 07:32:38 +01:00
2019-04-24 03:00:24 +02:00
public void move(EnumMoveType enummovetype, Vec3D vec3d) {
2016-01-09 07:32:38 +01:00
- org.bukkit.craftbukkit.SpigotTimings.entityMoveTimer.startTiming(); // Spigot
if (this.noclip) {
2019-04-24 03:00:24 +02:00
this.a(this.getBoundingBox().b(vec3d));
2016-03-01 00:09:49 +01:00
this.recalcPosition();
2019-05-06 04:58:04 +02:00
@@ -648,7 +648,6 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
2016-01-09 07:32:38 +01:00
2019-04-24 03:00:24 +02:00
this.world.getMethodProfiler().exit();
2016-01-09 07:32:38 +01:00
}
- org.bukkit.craftbukkit.SpigotTimings.entityMoveTimer.stopTiming(); // Spigot
}
2019-04-24 03:00:24 +02:00
protected Vec3D a(Vec3D vec3d, EnumMoveType enummovetype) {
2016-01-09 07:32:38 +01:00
diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java
2019-05-14 04:20:58 +02:00
index 1a33b7048..7c72fb918 100644
2016-01-09 07:32:38 +01:00
--- a/src/main/java/net/minecraft/server/EntityLiving.java
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
2019-04-24 03:00:24 +02:00
@@ -35,7 +35,7 @@ import org.bukkit.event.entity.EntityTeleportEvent;
2016-03-01 00:09:49 +01:00
import org.bukkit.event.player.PlayerItemConsumeEvent;
2016-01-09 07:32:38 +01:00
// CraftBukkit end
-import org.bukkit.craftbukkit.SpigotTimings; // Spigot
2016-04-30 03:23:40 +02:00
+import co.aikar.timings.MinecraftTimings; // Paper
2016-01-09 07:32:38 +01:00
public abstract class EntityLiving extends Entity {
2019-04-24 03:00:24 +02:00
@@ -2208,7 +2208,6 @@ public abstract class EntityLiving extends Entity {
2016-01-09 07:32:38 +01:00
2019-04-24 03:00:24 +02:00
@Override
2018-07-15 03:53:17 +02:00
public void tick() {
2016-01-09 07:32:38 +01:00
- SpigotTimings.timerEntityBaseTick.startTiming(); // Spigot
2018-07-15 03:53:17 +02:00
super.tick();
2019-04-24 03:00:24 +02:00
this.dk();
2018-07-15 03:53:17 +02:00
this.o();
2019-04-24 03:00:24 +02:00
@@ -2283,9 +2282,7 @@ public abstract class EntityLiving extends Entity {
2016-01-09 07:32:38 +01:00
}
}
- SpigotTimings.timerEntityBaseTick.stopTiming(); // Spigot
2018-12-17 06:18:06 +01:00
this.movementTick();
2016-01-09 07:32:38 +01:00
- SpigotTimings.timerEntityTickRest.startTiming(); // Spigot
double d0 = this.locX - this.lastX;
double d1 = this.locZ - this.lastZ;
float f = (float) (d0 * d0 + d1 * d1);
2019-04-24 03:00:24 +02:00
@@ -2365,8 +2362,6 @@ public abstract class EntityLiving extends Entity {
if (this.isSleeping()) {
this.pitch = 0.0F;
2016-03-01 00:09:49 +01:00
}
-
2016-01-09 07:32:38 +01:00
- SpigotTimings.timerEntityTickRest.stopTiming(); // Spigot
}
2018-07-15 03:53:17 +02:00
protected float e(float f, float f1) {
2019-04-24 03:00:24 +02:00
@@ -2440,7 +2435,6 @@ public abstract class EntityLiving extends Entity {
2016-01-09 07:32:38 +01:00
2019-04-24 03:00:24 +02:00
this.setMot(d4, d5, d6);
this.world.getMethodProfiler().enter("ai");
2016-01-09 07:32:38 +01:00
- SpigotTimings.timerEntityAI.startTiming(); // Spigot
2016-11-17 03:23:38 +01:00
if (this.isFrozen()) {
2019-04-24 03:00:24 +02:00
this.jumping = false;
this.bb = 0.0F;
@@ -2451,7 +2445,6 @@ public abstract class EntityLiving extends Entity {
2016-01-09 07:32:38 +01:00
this.doTick();
2019-04-24 03:00:24 +02:00
this.world.getMethodProfiler().exit();
2016-01-09 07:32:38 +01:00
}
- SpigotTimings.timerEntityAI.stopTiming(); // Spigot
2019-04-24 03:00:24 +02:00
this.world.getMethodProfiler().exit();
this.world.getMethodProfiler().enter("jump");
@@ -2476,9 +2469,7 @@ public abstract class EntityLiving extends Entity {
2018-07-15 03:53:17 +02:00
this.n();
AxisAlignedBB axisalignedbb = this.getBoundingBox();
2016-01-09 07:32:38 +01:00
- SpigotTimings.timerEntityAIMove.startTiming(); // Spigot
2019-04-24 03:00:24 +02:00
this.e(new Vec3D((double) this.bb, (double) this.bc, (double) this.bd));
2016-01-09 07:32:38 +01:00
- SpigotTimings.timerEntityAIMove.stopTiming(); // Spigot
2019-04-24 03:00:24 +02:00
this.world.getMethodProfiler().exit();
this.world.getMethodProfiler().enter("push");
if (this.bq > 0) {
@@ -2486,9 +2477,7 @@ public abstract class EntityLiving extends Entity {
2018-07-15 03:53:17 +02:00
this.a(axisalignedbb, this.getBoundingBox());
}
2016-03-01 00:09:49 +01:00
- SpigotTimings.timerEntityAICollision.startTiming(); // Spigot
2019-04-24 03:00:24 +02:00
this.collideNearby();
2016-03-01 00:09:49 +01:00
- SpigotTimings.timerEntityAICollision.stopTiming(); // Spigot
2019-04-24 03:00:24 +02:00
this.world.getMethodProfiler().exit();
2016-04-30 03:23:40 +02:00
}
2016-01-09 07:32:38 +01:00
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
2019-05-20 03:32:41 +02:00
index 64318e6e7..c76620f2b 100644
2016-01-09 07:32:38 +01:00
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
2019-04-24 03:00:24 +02:00
@@ -1,5 +1,7 @@
2018-07-15 03:53:17 +02:00
package net.minecraft.server;
+import co.aikar.timings.Timings;
2019-04-24 03:00:24 +02:00
+import com.google.common.base.Stopwatch;
2018-07-15 03:53:17 +02:00
import com.google.common.collect.Lists;
2018-08-26 20:11:49 +02:00
import com.google.common.collect.Maps;
2019-04-24 03:00:24 +02:00
import com.google.gson.JsonElement;
@@ -54,8 +56,8 @@ import org.bukkit.craftbukkit.CraftServer;
2016-07-16 00:36:53 +02:00
import org.bukkit.craftbukkit.Main;
2018-09-08 05:49:37 +02:00
import org.bukkit.event.server.ServerLoadEvent;
2016-01-09 07:32:38 +01:00
// CraftBukkit end
2016-03-01 00:09:49 +01:00
-import org.bukkit.craftbukkit.SpigotTimings; // Spigot
2017-01-31 05:33:54 +01:00
import org.spigotmc.SlackActivityAccountant; // Spigot
2016-04-30 03:23:40 +02:00
+import co.aikar.timings.MinecraftTimings; // Paper
2016-01-09 07:32:38 +01:00
2019-04-24 03:00:24 +02:00
public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTask> implements IMojangStatistics, ICommandListener, AutoCloseable, Runnable {
2016-03-01 00:09:49 +01:00
2019-05-07 02:33:26 +02:00
@@ -671,6 +673,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
2016-03-01 00:09:49 +01:00
}
2016-01-09 07:32:38 +01:00
// CraftBukkit end
2016-03-01 00:09:49 +01:00
MinecraftServer.LOGGER.info("Stopping server");
2016-04-30 03:23:40 +02:00
+ MinecraftTimings.stopServer(); // Paper
2016-03-03 10:46:26 +01:00
// CraftBukkit start
if (this.server != null) {
this.server.disablePlugins();
2019-05-07 02:33:26 +02:00
@@ -948,7 +951,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
2019-04-24 03:00:24 +02:00
protected void exit() {}
2016-01-09 07:32:38 +01:00
2018-08-26 20:11:49 +02:00
protected void a(BooleanSupplier booleansupplier) {
2016-01-09 07:32:38 +01:00
- SpigotTimings.serverTickTimer.startTiming(); // Spigot
2016-03-01 00:09:49 +01:00
+ co.aikar.timings.TimingsManager.FULL_SERVER_TICK.startTiming(); // Paper
2017-01-31 05:33:54 +01:00
this.slackActivityAccountant.tickStarted(); // Spigot
2018-12-17 06:18:06 +01:00
long i = SystemUtils.getMonotonicNanos();
2016-01-09 07:32:38 +01:00
2019-05-07 02:33:26 +02:00
@@ -969,14 +972,12 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
2016-04-30 03:23:40 +02:00
}
if (autosavePeriod > 0 && this.ticks % autosavePeriod == 0) { // CraftBukkit
- SpigotTimings.worldSaveTimer.startTiming(); // Spigot
2019-04-24 03:00:24 +02:00
MinecraftServer.LOGGER.debug("Autosave started");
2018-12-17 06:18:06 +01:00
this.methodProfiler.enter("save");
this.playerList.savePlayers();
2019-04-24 03:00:24 +02:00
this.saveChunks(true, false, false);
2018-12-17 06:18:06 +01:00
this.methodProfiler.exit();
2019-04-24 03:00:24 +02:00
MinecraftServer.LOGGER.debug("Autosave finished");
2016-04-30 03:23:40 +02:00
- SpigotTimings.worldSaveTimer.stopTiming(); // Spigot
}
2018-12-17 06:18:06 +01:00
this.methodProfiler.enter("snooper");
2019-05-07 02:33:26 +02:00
@@ -999,29 +1000,28 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
2018-12-17 06:18:06 +01:00
this.methodProfiler.exit();
2016-01-09 07:32:38 +01:00
org.spigotmc.WatchdogThread.tick(); // Spigot
2018-07-15 03:53:17 +02:00
this.slackActivityAccountant.tickEnded(l); // Spigot
2016-01-09 07:32:38 +01:00
- SpigotTimings.serverTickTimer.stopTiming(); // Spigot
- org.spigotmc.CustomTimingsHandler.tick(); // Spigot
2016-03-01 00:09:49 +01:00
+ co.aikar.timings.TimingsManager.FULL_SERVER_TICK.stopTiming(); // Paper
2016-01-09 07:32:38 +01:00
}
2019-04-24 03:00:24 +02:00
protected void b(BooleanSupplier booleansupplier) {
2016-06-30 07:38:53 +02:00
- SpigotTimings.schedulerTimer.startTiming(); // Spigot
2019-04-24 03:00:24 +02:00
+ MinecraftTimings.bukkitSchedulerTimer.startTiming(); // Spigot // Paper
2016-06-30 07:38:53 +02:00
this.server.getScheduler().mainThreadHeartbeat(this.ticks); // CraftBukkit
- SpigotTimings.schedulerTimer.stopTiming(); // Spigot
2019-04-24 03:00:24 +02:00
+ MinecraftTimings.bukkitSchedulerTimer.stopTiming(); // Spigot // Paper
this.methodProfiler.enter("commandFunctions");
2018-07-15 03:53:17 +02:00
- SpigotTimings.commandFunctionsTimer.startTiming(); // Spigot
2019-04-24 03:00:24 +02:00
+ MinecraftTimings.commandFunctionsTimer.startTiming(); // Spigot // Paper
2018-12-17 06:18:06 +01:00
this.getFunctionData().tick();
2018-07-15 03:53:17 +02:00
- SpigotTimings.commandFunctionsTimer.stopTiming(); // Spigot
2019-04-24 03:00:24 +02:00
+ MinecraftTimings.commandFunctionsTimer.stopTiming(); // Spigot // Paper
2018-12-17 06:18:06 +01:00
this.methodProfiler.exitEnter("levels");
2016-02-24 05:35:34 +01:00
// CraftBukkit start
// Run tasks that are waiting on processing
2016-04-30 03:23:40 +02:00
- SpigotTimings.processQueueTimer.startTiming(); // Spigot
+ MinecraftTimings.processQueueTimer.startTiming(); // Spigot
while (!processQueue.isEmpty()) {
processQueue.remove().run();
}
- SpigotTimings.processQueueTimer.stopTiming(); // Spigot
+ MinecraftTimings.processQueueTimer.stopTiming(); // Spigot
- SpigotTimings.timeUpdateTimer.startTiming(); // Spigot
2019-04-24 03:00:24 +02:00
+ MinecraftTimings.timeUpdateTimer.startTiming(); // Spigot // Paper
2016-04-30 03:23:40 +02:00
// 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) {
2019-05-07 02:33:26 +02:00
@@ -1029,7 +1029,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
2016-04-30 03:23:40 +02:00
entityplayer.playerConnection.sendPacket(new PacketPlayOutUpdateTime(entityplayer.world.getTime(), entityplayer.getPlayerTime(), entityplayer.world.getGameRules().getBoolean("doDaylightCycle"))); // Add support for per player time
}
}
- SpigotTimings.timeUpdateTimer.stopTiming(); // Spigot
2019-04-24 03:00:24 +02:00
+ MinecraftTimings.timeUpdateTimer.stopTiming(); // Spigot // Paper
2016-04-30 03:23:40 +02:00
2018-08-26 20:11:49 +02:00
// WorldServer worldserver; // CraftBukkit - dropped down
long i;
2019-05-07 02:33:26 +02:00
@@ -1076,20 +1076,20 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
2016-04-30 03:23:40 +02:00
}
2018-12-17 06:18:06 +01:00
this.methodProfiler.exitEnter("connection");
2016-04-30 03:23:40 +02:00
- SpigotTimings.connectionTimer.startTiming(); // Spigot
+ MinecraftTimings.connectionTimer.startTiming(); // Spigot
2018-07-15 03:53:17 +02:00
this.getServerConnection().c();
2016-04-30 03:23:40 +02:00
- SpigotTimings.connectionTimer.stopTiming(); // Spigot
+ MinecraftTimings.connectionTimer.stopTiming(); // Spigot
2018-12-17 06:18:06 +01:00
this.methodProfiler.exitEnter("players");
2016-04-30 03:23:40 +02:00
- SpigotTimings.playerListTimer.startTiming(); // Spigot
+ MinecraftTimings.playerListTimer.startTiming(); // Spigot
2018-12-17 06:18:06 +01:00
this.playerList.tick();
2016-04-30 03:23:40 +02:00
- SpigotTimings.playerListTimer.stopTiming(); // Spigot
+ MinecraftTimings.playerListTimer.stopTiming(); // Spigot
2019-04-24 03:00:24 +02:00
this.methodProfiler.exitEnter("server gui refresh");
2018-08-26 20:11:49 +02:00
2016-04-30 03:23:40 +02:00
- SpigotTimings.tickablesTimer.startTiming(); // Spigot
+ MinecraftTimings.tickablesTimer.startTiming(); // Spigot
2019-04-24 03:00:24 +02:00
for (int j = 0; j < this.tickables.size(); ++j) {
((Runnable) this.tickables.get(j)).run();
2016-04-30 03:23:40 +02:00
}
- SpigotTimings.tickablesTimer.stopTiming(); // Spigot
+ MinecraftTimings.tickablesTimer.stopTiming(); // Spigot
2018-12-17 06:18:06 +01:00
this.methodProfiler.exit();
2016-04-30 03:23:40 +02:00
}
2016-06-05 06:10:50 +02:00
diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java
2019-05-14 04:20:58 +02:00
index 2e17358ed..e7019d8ae 100644
2016-06-05 06:10:50 +02:00
--- a/src/main/java/net/minecraft/server/PlayerChunkMap.java
+++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java
2019-04-24 03:00:24 +02:00
@@ -1,6 +1,8 @@
2016-06-05 06:10:50 +02:00
package net.minecraft.server;
2019-04-24 03:00:24 +02:00
import com.google.common.collect.ImmutableList;
2016-06-05 06:10:50 +02:00
+import co.aikar.timings.Timing;
2019-04-24 03:00:24 +02:00
+import com.google.common.collect.ComparisonChain;
2018-07-15 03:53:17 +02:00
import com.google.common.collect.Lists;
2019-04-24 03:00:24 +02:00
import com.google.common.collect.Sets;
import com.mojang.datafixers.DataFixer;
2019-05-14 04:20:58 +02:00
@@ -423,7 +425,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
2016-06-05 06:10:50 +02:00
});
2017-01-31 05:33:54 +01:00
2019-04-24 03:00:24 +02:00
return completablefuture.thenComposeAsync((either) -> {
- return (CompletableFuture) either.map((list) -> {
+ return either.map((list) -> { // Paper - Shut up.
try {
CompletableFuture<Either<IChunkAccess, PlayerChunk.Failure>> completablefuture1 = chunkstatus.a(this.world, this.chunkGenerator, this.definedStructureManager, this.lightEngine, (ichunkaccess) -> {
2019-05-14 04:20:58 +02:00
return this.c(playerchunk);
@@ -916,6 +918,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
2016-06-05 06:10:50 +02:00
2019-04-24 03:00:24 +02:00
PlayerChunkMap.EntityTracker playerchunkmap_entitytracker;
ObjectIterator objectiterator;
+ world.timings.tracker1.startTiming(); // Paper
2016-06-05 06:10:50 +02:00
2019-04-24 03:00:24 +02:00
for (objectiterator = this.trackedEntities.values().iterator(); objectiterator.hasNext(); playerchunkmap_entitytracker.trackerEntry.a()) {
playerchunkmap_entitytracker = (PlayerChunkMap.EntityTracker) objectiterator.next();
2019-05-14 04:20:58 +02:00
@@ -933,13 +936,16 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
2019-04-24 03:00:24 +02:00
playerchunkmap_entitytracker.e = sectionposition1;
2016-06-05 06:10:50 +02:00
}
}
2019-04-24 03:00:24 +02:00
+ world.timings.tracker1.stopTiming(); // Paper
2016-06-05 06:10:50 +02:00
2019-04-24 03:00:24 +02:00
objectiterator = this.trackedEntities.values().iterator();
2016-06-05 06:10:50 +02:00
2019-04-24 03:00:24 +02:00
+ world.timings.tracker2.startTiming(); // Paper
while (objectiterator.hasNext()) {
playerchunkmap_entitytracker = (PlayerChunkMap.EntityTracker) objectiterator.next();
playerchunkmap_entitytracker.track(list);
2019-05-06 22:45:02 +02:00
}
+ world.timings.tracker2.stopTiming(); // Paper
}
2016-01-09 07:32:38 +01:00
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
2019-05-14 04:20:58 +02:00
index 5757dd6fb..a7104e966 100644
2016-01-09 07:32:38 +01:00
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
2019-05-06 04:58:04 +02:00
@@ -58,6 +58,7 @@ import org.bukkit.inventory.CraftingInventory;
2016-03-04 22:20:13 +01:00
import org.bukkit.inventory.EquipmentSlot;
2016-01-09 07:32:38 +01:00
import org.bukkit.inventory.InventoryView;
import org.bukkit.util.NumberConversions;
2016-04-30 03:23:40 +02:00
+import co.aikar.timings.MinecraftTimings; // Paper
2016-01-09 07:32:38 +01:00
// CraftBukkit end
2019-04-24 03:00:24 +02:00
public class PlayerConnection implements PacketListenerPlayIn {
2019-05-06 04:58:04 +02:00
@@ -135,7 +136,6 @@ public class PlayerConnection implements PacketListenerPlayIn {
2018-10-28 23:08:08 +01:00
// CraftBukkit end
2018-12-17 06:18:06 +01:00
public void tick() {
2018-10-28 23:08:08 +01:00
- org.bukkit.craftbukkit.SpigotTimings.playerConnectionTimer.startTiming(); // Spigot
this.syncPosition();
this.player.playerTick();
this.player.setLocation(this.l, this.m, this.n, this.player.yaw, this.player.pitch);
2019-05-06 04:58:04 +02:00
@@ -208,7 +208,6 @@ public class PlayerConnection implements PacketListenerPlayIn {
2018-10-28 23:08:08 +01:00
this.player.resetIdleTimer(); // CraftBukkit - SPIGOT-854
this.disconnect(new ChatMessage("multiplayer.disconnect.idling", new Object[0]));
}
- org.bukkit.craftbukkit.SpigotTimings.playerConnectionTimer.stopTiming(); // Spigot
}
2019-05-06 04:58:04 +02:00
@@ -1647,7 +1646,7 @@ public class PlayerConnection implements PacketListenerPlayIn {
2016-01-09 07:32:38 +01:00
// CraftBukkit end
2017-05-14 20:05:01 +02:00
private void handleCommand(String s) {
2016-01-09 07:32:38 +01:00
- org.bukkit.craftbukkit.SpigotTimings.playerCommandTimer.startTiming(); // Spigot
2017-05-14 20:05:01 +02:00
+ MinecraftTimings.playerCommandTimer.startTiming(); // Paper
2018-07-15 03:53:17 +02:00
// CraftBukkit start - whole method
2016-01-09 07:32:38 +01:00
if ( org.spigotmc.SpigotConfig.logCommands ) // Spigot
2016-03-01 00:09:49 +01:00
this.LOGGER.info(this.player.getName() + " issued server command: " + s);
2019-05-06 04:58:04 +02:00
@@ -1658,7 +1657,7 @@ public class PlayerConnection implements PacketListenerPlayIn {
2016-01-09 07:32:38 +01:00
this.server.getPluginManager().callEvent(event);
if (event.isCancelled()) {
- org.bukkit.craftbukkit.SpigotTimings.playerCommandTimer.stopTiming(); // Spigot
2016-04-30 03:23:40 +02:00
+ MinecraftTimings.playerCommandTimer.stopTiming(); // Paper
2016-01-09 07:32:38 +01:00
return;
}
2019-05-06 04:58:04 +02:00
@@ -1671,7 +1670,7 @@ public class PlayerConnection implements PacketListenerPlayIn {
2016-01-09 07:32:38 +01:00
java.util.logging.Logger.getLogger(PlayerConnection.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
2018-07-15 03:53:17 +02:00
return;
} finally {
2016-01-09 07:32:38 +01:00
- org.bukkit.craftbukkit.SpigotTimings.playerCommandTimer.stopTiming(); // Spigot
2016-04-30 03:23:40 +02:00
+ MinecraftTimings.playerCommandTimer.stopTiming(); // Paper
2016-01-09 07:32:38 +01:00
}
2018-07-15 03:53:17 +02:00
// this.minecraftServer.getCommandDispatcher().a(this.player.getCommandListener(), s);
2016-01-09 07:32:38 +01:00
// CraftBukkit end
2017-02-05 06:13:16 +01:00
diff --git a/src/main/java/net/minecraft/server/PlayerConnectionUtils.java b/src/main/java/net/minecraft/server/PlayerConnectionUtils.java
2019-05-14 04:20:58 +02:00
index cb6d50ea7..9ba03f8ed 100644
2017-02-05 06:13:16 +01:00
--- a/src/main/java/net/minecraft/server/PlayerConnectionUtils.java
+++ b/src/main/java/net/minecraft/server/PlayerConnectionUtils.java
2019-04-24 03:00:24 +02:00
@@ -1,5 +1,8 @@
2017-02-05 06:13:16 +01:00
package net.minecraft.server;
+import co.aikar.timings.MinecraftTimings; // Paper
+import co.aikar.timings.Timing; // Paper
+
public class PlayerConnectionUtils {
2019-01-01 04:15:55 +01:00
2019-04-24 03:00:24 +02:00
public static <T extends PacketListener> void ensureMainThread(Packet<T> packet, T t0, WorldServer worldserver) throws CancelledPacketHandleException {
@@ -8,9 +11,12 @@ public class PlayerConnectionUtils {
public static <T extends PacketListener> void ensureMainThread(Packet<T> packet, T t0, IAsyncTaskHandler<?> iasynctaskhandler) throws CancelledPacketHandleException {
2017-02-05 06:13:16 +01:00
if (!iasynctaskhandler.isMainThread()) {
2018-07-15 03:53:17 +02:00
+ Timing timing = MinecraftTimings.getPacketTiming(packet); // Paper
2019-04-24 03:00:24 +02:00
iasynctaskhandler.execute(() -> {
2019-05-06 04:58:04 +02:00
if (MinecraftServer.getServer().hasStopped() || (t0 instanceof PlayerConnection && ((PlayerConnection) t0).processedDisconnect)) return; // CraftBukkit, MC-142590
2019-02-03 16:34:04 +01:00
+ try (Timing ignored = timing.startTiming()) { // Paper
2019-01-01 04:15:55 +01:00
packet.a(t0);
2019-05-06 04:58:04 +02:00
+ } // Paper - timings
2017-02-05 06:13:16 +01:00
});
throw CancelledPacketHandleException.INSTANCE;
}
2016-10-21 22:42:49 +02:00
diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java
2019-05-14 04:20:58 +02:00
index 6171b369c..bab32af46 100644
2016-10-21 22:42:49 +02:00
--- a/src/main/java/net/minecraft/server/PlayerList.java
+++ b/src/main/java/net/minecraft/server/PlayerList.java
@@ -1,5 +1,6 @@
package net.minecraft.server;
+import co.aikar.timings.MinecraftTimings;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
2019-05-14 04:20:58 +02:00
@@ -895,10 +896,11 @@ public abstract class PlayerList {
2016-10-21 22:42:49 +02:00
}
public void savePlayers() {
+ MinecraftTimings.savePlayers.startTiming(); // Paper
for (int i = 0; i < this.players.size(); ++i) {
this.savePlayerFile((EntityPlayer) this.players.get(i));
}
-
+ MinecraftTimings.savePlayers.stopTiming(); // Paper
}
2018-07-15 03:53:17 +02:00
public WhiteList getWhitelist() {
diff --git a/src/main/java/net/minecraft/server/TickListServer.java b/src/main/java/net/minecraft/server/TickListServer.java
2019-05-14 04:20:58 +02:00
index a99618099..972b1c0d2 100644
2018-07-15 03:53:17 +02:00
--- a/src/main/java/net/minecraft/server/TickListServer.java
+++ b/src/main/java/net/minecraft/server/TickListServer.java
2019-05-14 04:20:58 +02:00
@@ -25,13 +25,18 @@ public class TickListServer<T> implements TickList<T> {
private final List<NextTickListEntry<T>> i = Lists.newArrayList();
private final Consumer<NextTickListEntry<T>> j;
2018-07-15 03:53:17 +02:00
- public TickListServer(WorldServer worldserver, Predicate<T> predicate, Function<T, MinecraftKey> function, Function<MinecraftKey, T> function1, Consumer<NextTickListEntry<T>> consumer) {
+ public TickListServer(WorldServer worldserver, Predicate<T> predicate, Function<T, MinecraftKey> function, Function<MinecraftKey, T> function1, Consumer<NextTickListEntry<T>> consumer, String timingsType) { // Paper
this.a = predicate;
this.b = function;
this.c = function1;
2019-05-14 04:20:58 +02:00
this.h = worldserver;
this.j = consumer;
2018-07-15 03:53:17 +02:00
+ timingCleanup = co.aikar.timings.WorldTimingsHandler.getTickList(worldserver, timingsType + " - Cleanup");
+ timingTicking = co.aikar.timings.WorldTimingsHandler.getTickList(worldserver, timingsType + " - Ticking");
}
+ private final co.aikar.timings.Timing timingCleanup; // Paper
+ private final co.aikar.timings.Timing timingTicking; // Paper
+ // Paper end
2016-08-28 02:36:26 +02:00
2018-07-15 03:53:17 +02:00
public void a() {
2019-05-14 04:20:58 +02:00
this.b();
@@ -53,6 +58,7 @@ public class TickListServer<T> implements TickList<T> {
this.h.getMethodProfiler().enter("selecting");
Iterator iterator = this.nextTickList.iterator();
2016-08-28 02:36:26 +02:00
2018-07-15 03:53:17 +02:00
+ timingCleanup.startTiming(); // Paper
2019-05-14 04:20:58 +02:00
NextTickListEntry nextticklistentry;
2016-08-28 02:36:26 +02:00
2019-05-14 04:20:58 +02:00
while (iterator.hasNext()) {
@@ -66,7 +72,9 @@ public class TickListServer<T> implements TickList<T> {
--i;
}
2018-07-15 03:53:17 +02:00
}
+ timingCleanup.stopTiming(); // Paper
2016-08-28 02:36:26 +02:00
2018-07-15 03:53:17 +02:00
+ timingTicking.startTiming(); // Paper
2019-05-14 04:20:58 +02:00
this.h.getMethodProfiler().exitEnter("ticking");
iterator = this.i.iterator();
2016-08-28 02:36:26 +02:00
2019-05-14 04:20:58 +02:00
@@ -94,6 +102,7 @@ public class TickListServer<T> implements TickList<T> {
this.i.clear();
2018-07-15 03:53:17 +02:00
this.g.clear();
2019-05-14 04:20:58 +02:00
this.h.getMethodProfiler().exit();
2018-07-15 03:53:17 +02:00
+ timingTicking.stopTiming(); // Paper
2016-08-28 02:36:26 +02:00
}
}
2018-07-15 03:53:17 +02:00
2016-01-09 07:32:38 +01:00
diff --git a/src/main/java/net/minecraft/server/TileEntity.java b/src/main/java/net/minecraft/server/TileEntity.java
2019-05-14 04:20:58 +02:00
index 7546f6690..095ef9ba5 100644
2016-01-09 07:32:38 +01:00
--- a/src/main/java/net/minecraft/server/TileEntity.java
+++ b/src/main/java/net/minecraft/server/TileEntity.java
2019-05-14 04:20:58 +02:00
@@ -9,11 +9,12 @@ import org.bukkit.craftbukkit.persistence.CraftPersistentDataContainer;
2019-05-06 04:58:04 +02:00
import org.bukkit.craftbukkit.persistence.CraftPersistentDataTypeRegistry;
import org.bukkit.inventory.InventoryHolder;
// CraftBukkit end
2016-01-09 07:32:38 +01:00
-import org.spigotmc.CustomTimingsHandler; // Spigot
2016-04-30 03:23:40 +02:00
+import co.aikar.timings.MinecraftTimings; // Paper
2016-03-01 00:09:49 +01:00
+import co.aikar.timings.Timing; // Paper
2016-01-09 07:32:38 +01:00
2018-07-27 06:44:53 +02:00
public abstract class TileEntity implements KeyedObject { // Paper
2016-01-09 07:32:38 +01:00
- public CustomTimingsHandler tickTimer = org.bukkit.craftbukkit.SpigotTimings.getTileEntityTimings(this); // Spigot
2016-04-30 03:23:40 +02:00
+ public Timing tickTimer = MinecraftTimings.getTileEntityTimings(this); // Paper
2019-05-06 04:58:04 +02:00
// CraftBukkit start - data containers
private static final CraftPersistentDataTypeRegistry DATA_TYPE_REGISTRY = new CraftPersistentDataTypeRegistry();
public final CraftPersistentDataContainer persistentDataContainer = new CraftPersistentDataContainer(DATA_TYPE_REGISTRY);
2016-01-09 07:32:38 +01:00
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
2019-05-14 04:20:58 +02:00
index 404d3d8c8..93fa09121 100644
2016-01-09 07:32:38 +01:00
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
2019-04-24 03:00:24 +02:00
@@ -1,5 +1,7 @@
package net.minecraft.server;
2018-07-15 03:53:17 +02:00
2019-04-24 03:00:24 +02:00
+import co.aikar.timings.Timing;
2018-07-15 03:53:17 +02:00
+import co.aikar.timings.Timings;
import com.google.common.collect.Lists;
2019-04-24 03:00:24 +02:00
import java.io.IOException;
import java.util.Collection;
@@ -20,7 +22,6 @@ import java.util.ArrayList;
2016-03-01 00:09:49 +01:00
import java.util.Map;
import org.bukkit.Bukkit;
2016-01-09 07:32:38 +01:00
import org.bukkit.block.BlockState;
2016-03-01 00:09:49 +01:00
-import org.bukkit.craftbukkit.SpigotTimings; // Spigot
2016-01-09 07:32:38 +01:00
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.CraftWorld;
2018-07-15 03:53:17 +02:00
import org.bukkit.craftbukkit.block.CraftBlockState;
2019-04-24 03:00:24 +02:00
@@ -88,7 +89,7 @@ public abstract class World implements IIBlockAccess, GeneratorAccess, AutoClose
2016-01-09 07:32:38 +01:00
2016-03-01 00:09:49 +01:00
public final com.destroystokyo.paper.PaperWorldConfig paperConfig; // Paper
2016-01-09 07:32:38 +01:00
- public final SpigotTimings.WorldTimingsHandler timings; // Spigot
2016-03-01 00:09:49 +01:00
+ public final co.aikar.timings.WorldTimingsHandler timings; // Paper
2019-02-03 16:34:04 +01:00
public static BlockPosition lastPhysicsProblem; // Spigot
private org.spigotmc.TickLimiter entityLimiter;
2019-04-24 03:00:24 +02:00
private org.spigotmc.TickLimiter tileLimiter;
@@ -150,7 +151,7 @@ public abstract class World implements IIBlockAccess, GeneratorAccess, AutoClose
public void c(WorldBorder worldborder, double d0) {}
2016-03-25 05:59:37 +01:00
});
2016-03-03 10:46:26 +01:00
// CraftBukkit end
2016-03-01 00:09:49 +01:00
- timings = new SpigotTimings.WorldTimingsHandler(this); // Spigot - code below can generate new world and access timings
+ timings = new co.aikar.timings.WorldTimingsHandler(this); // Paper - code below can generate new world and access timings
2019-04-24 03:00:24 +02:00
this.entityLimiter = new org.spigotmc.TickLimiter(spigotConfig.entityMaxTickTime);
2016-01-09 07:32:38 +01:00
this.tileLimiter = new org.spigotmc.TickLimiter(spigotConfig.tileMaxTickTime);
}
2019-05-14 04:20:58 +02:00
@@ -739,21 +740,26 @@ public abstract class World implements IIBlockAccess, GeneratorAccess, AutoClose
2016-01-09 07:32:38 +01:00
}
timings.tileEntityPending.stopTiming(); // Spigot
2016-03-01 00:09:49 +01:00
+ co.aikar.timings.TimingHistory.tileEntityTicks += this.tileEntityListTick.size(); // Paper
2019-04-24 03:00:24 +02:00
gameprofilerfiller.exit();
spigotConfig.currentPrimedTnt = 0; // Spigot
2016-01-09 07:32:38 +01:00
}
2018-04-22 16:40:36 +02:00
2019-04-24 03:00:24 +02:00
public void a(Consumer<Entity> consumer, Entity entity) {
try {
2019-05-14 04:20:58 +02:00
- SpigotTimings.tickEntityTimer.startTiming(); // Spigot
2019-04-24 03:00:24 +02:00
+ timings.tickEntities.startTiming();
2019-05-14 04:20:58 +02:00
+ entity.tickTimer.startTiming();
+ // Spigot end
2019-04-24 03:00:24 +02:00
consumer.accept(entity);
2019-05-14 04:20:58 +02:00
- SpigotTimings.tickEntityTimer.stopTiming(); // Spigot
} catch (Throwable throwable) {
CrashReport crashreport = CrashReport.a(throwable, "Ticking entity");
CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Entity being ticked");
entity.appendEntityCrashDetails(crashreportsystemdetails);
throw new ReportedException(crashreport);
+ } finally {
+ entity.tickTimer.stopTiming();
2019-04-24 03:00:24 +02:00
+ timings.tickEntities.stopTiming();
2016-01-09 07:32:38 +01:00
}
}
2019-05-14 04:20:58 +02:00
2016-01-09 07:32:38 +01:00
diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
2019-05-14 04:20:58 +02:00
index 36c517d8f..5a0d940be 100644
2016-01-09 07:32:38 +01:00
--- a/src/main/java/net/minecraft/server/WorldServer.java
+++ b/src/main/java/net/minecraft/server/WorldServer.java
2019-04-24 03:00:24 +02:00
@@ -1,5 +1,7 @@
2018-07-15 03:53:17 +02:00
package net.minecraft.server;
2019-04-24 03:00:24 +02:00
+import co.aikar.timings.TimingHistory;
2018-07-15 03:53:17 +02:00
+import co.aikar.timings.Timings;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
2019-04-24 03:00:24 +02:00
import com.google.common.collect.Queues;
2019-05-14 04:20:58 +02:00
@@ -33,7 +35,6 @@ import org.apache.logging.log4j.Logger;
// CraftBukkit start
import org.bukkit.Bukkit;
2019-04-24 03:00:24 +02:00
import org.bukkit.WeatherType;
-import org.bukkit.craftbukkit.SpigotTimings; // Spigot
import org.bukkit.craftbukkit.event.CraftEventFactory;
2019-05-14 04:20:58 +02:00
import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.event.server.MapInitializeEvent;
@@ -90,10 +91,10 @@ public class WorldServer extends World {
2019-01-01 04:15:55 +01:00
// CraftBukkit end
this.nextTickListBlock = new TickListServer<>(this, (block) -> {
return block == null || block.getBlockData().isAir();
2019-04-24 03:00:24 +02:00
- }, IRegistry.BLOCK::getKey, IRegistry.BLOCK::get, this::b);
+ }, IRegistry.BLOCK::getKey, IRegistry.BLOCK::get, this::b, "Blocks"); // Paper - Timings
2019-01-01 04:15:55 +01:00
this.nextTickListFluid = new TickListServer<>(this, (fluidtype) -> {
return fluidtype == null || fluidtype == FluidTypes.EMPTY;
2019-04-24 03:00:24 +02:00
- }, IRegistry.FLUID::getKey, IRegistry.FLUID::get, this::a);
+ }, IRegistry.FLUID::getKey, IRegistry.FLUID::get, this::a, "Fluids"); // Paper - Timings
this.I = Sets.newHashSet();
2018-07-15 03:53:17 +02:00
this.siegeManager = new VillageSiege(this);
2019-04-24 03:00:24 +02:00
this.J = new ObjectLinkedOpenHashSet();
2019-05-14 04:20:58 +02:00
@@ -256,12 +257,12 @@ public class WorldServer extends World {
2019-05-06 09:20:16 +02:00
gameprofilerfiller.exitEnter("chunkSource");
this.getChunkProvider().tick(booleansupplier);
gameprofilerfiller.exitEnter("tickPending");
- timings.doTickPending.startTiming(); // Spigot
+ timings.scheduledBlocks.startTiming(); // Spigot
if (this.worldData.getType() != WorldType.DEBUG_ALL_BLOCK_STATES) {
this.nextTickListBlock.a();
this.nextTickListFluid.a();
}
- timings.doTickPending.stopTiming(); // Spigot
+ timings.scheduledBlocks.stopTiming(); // Spigot
gameprofilerfiller.exitEnter("village");
timings.doVillages.startTiming(); // Spigot
2019-05-14 04:20:58 +02:00
@@ -318,6 +319,7 @@ public class WorldServer extends World {
2019-04-24 03:00:24 +02:00
org.spigotmc.ActivationRange.activateEntities(this); // Spigot
timings.entityTick.startTiming(); // Spigot
+ TimingHistory.entityTicks += this.globalEntityList.size(); // Paper
while (objectiterator.hasNext()) {
Entry<Entity> entry = (Entry) objectiterator.next();
Entity entity1 = (Entity) entry.getValue();
2019-05-14 04:20:58 +02:00
@@ -421,6 +423,7 @@ public class WorldServer extends World {
2019-04-24 03:00:24 +02:00
}
2016-01-09 07:32:38 +01:00
2019-04-24 03:00:24 +02:00
gameprofilerfiller.exitEnter("tickBlocks");
+ timings.chunkTicksBlocks.startTiming(); // Paper
if (i > 0) {
ChunkSection[] achunksection = chunk.getSections();
int l = achunksection.length;
2019-05-14 04:20:58 +02:00
@@ -452,7 +455,7 @@ public class WorldServer extends World {
2016-01-09 07:32:38 +01:00
}
}
2019-04-24 03:00:24 +02:00
}
-
+ timings.chunkTicksBlocks.stopTiming(); // Paper
gameprofilerfiller.exit();
}
2016-01-09 07:32:38 +01:00
2019-05-14 04:20:58 +02:00
@@ -747,6 +750,7 @@ public class WorldServer extends World {
2016-10-21 22:42:49 +02:00
2019-04-24 03:00:24 +02:00
if (!flag1) {
2016-10-21 22:42:49 +02:00
org.bukkit.Bukkit.getPluginManager().callEvent(new org.bukkit.event.world.WorldSaveEvent(getWorld())); // CraftBukkit
2019-05-06 09:20:16 +02:00
+ try (co.aikar.timings.Timing ignored = timings.worldSave.startTiming()) { // Paper
2016-10-21 22:42:49 +02:00
if (iprogressupdate != null) {
2018-07-15 03:53:17 +02:00
iprogressupdate.a(new ChatMessage("menu.savingLevel", new Object[0]));
2016-10-21 22:42:49 +02:00
}
2019-05-14 04:20:58 +02:00
@@ -756,7 +760,10 @@ public class WorldServer extends World {
2018-07-15 03:53:17 +02:00
iprogressupdate.c(new ChatMessage("menu.savingChunks", new Object[0]));
2016-10-21 22:42:49 +02:00
}
+ timings.worldSaveChunks.startTiming(); // Paper
2019-04-24 03:00:24 +02:00
chunkproviderserver.save(flag);
2016-10-21 22:42:49 +02:00
+ timings.worldSaveChunks.stopTiming(); // Paper
2019-04-24 03:00:24 +02:00
+ } // Paper
2016-10-21 22:42:49 +02:00
}
}
2016-01-09 07:32:38 +01:00
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
2019-05-14 04:20:58 +02:00
index 7fe76b8d5..b43888592 100644
2016-01-09 07:32:38 +01:00
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
2019-05-06 04:58:04 +02:00
@@ -1926,12 +1926,31 @@ public final class CraftServer implements Server {
2016-03-01 00:09:49 +01:00
private final Spigot spigot = new Spigot()
{
2016-01-09 07:32:38 +01:00
+ @Deprecated
@Override
public YamlConfiguration getConfig()
{
2018-03-10 14:07:40 +01:00
return org.spigotmc.SpigotConfig.config;
2016-03-01 00:09:49 +01:00
}
2018-03-10 14:07:40 +01:00
+ @Override
2016-01-09 07:32:38 +01:00
+ public YamlConfiguration getBukkitConfig()
+ {
+ return configuration;
+ }
+
+ @Override
+ public YamlConfiguration getSpigotConfig()
+ {
2016-03-01 00:09:49 +01:00
+ return org.spigotmc.SpigotConfig.config;
+ }
+
+ @Override
+ public YamlConfiguration getPaperConfig()
2016-01-09 07:32:38 +01:00
+ {
2016-03-01 00:09:49 +01:00
+ return com.destroystokyo.paper.PaperConfig.config;
2016-01-09 07:32:38 +01:00
+ }
+
2018-03-10 14:07:40 +01:00
@Override
2016-01-09 07:32:38 +01:00
public void restart() {
org.spigotmc.RestartCommand.restart();
diff --git a/src/main/java/org/bukkit/craftbukkit/SpigotTimings.java b/src/main/java/org/bukkit/craftbukkit/SpigotTimings.java
deleted file mode 100644
2019-05-14 04:20:58 +02:00
index 38f211526..000000000
2016-01-09 07:32:38 +01:00
--- a/src/main/java/org/bukkit/craftbukkit/SpigotTimings.java
+++ /dev/null
2019-04-24 03:00:24 +02:00
@@ -1,166 +0,0 @@
2016-01-09 07:32:38 +01:00
-package org.bukkit.craftbukkit;
-
-import java.util.HashMap;
2019-04-24 03:00:24 +02:00
-import net.minecraft.server.Entity;
-import net.minecraft.server.TileEntity;
-import net.minecraft.server.World;
2016-01-09 07:32:38 +01:00
-import org.bukkit.craftbukkit.scheduler.CraftTask;
2019-04-24 03:00:24 +02:00
-import org.bukkit.plugin.java.JavaPluginLoader;
-import org.bukkit.scheduler.BukkitTask;
-import org.spigotmc.CustomTimingsHandler;
2016-01-09 07:32:38 +01:00
-
-public class SpigotTimings {
-
- public static final CustomTimingsHandler serverTickTimer = new CustomTimingsHandler("** Full Server Tick");
- public static final CustomTimingsHandler playerListTimer = new CustomTimingsHandler("Player List");
2017-05-14 20:05:01 +02:00
- public static final CustomTimingsHandler commandFunctionsTimer = new CustomTimingsHandler("Command Functions");
2016-01-09 07:32:38 +01:00
- public static final CustomTimingsHandler connectionTimer = new CustomTimingsHandler("Connection Handler");
2018-10-28 23:08:08 +01:00
- public static final CustomTimingsHandler playerConnectionTimer = new CustomTimingsHandler("** PlayerConnection");
2016-01-09 07:32:38 +01:00
- public static final CustomTimingsHandler tickablesTimer = new CustomTimingsHandler("Tickables");
- public static final CustomTimingsHandler schedulerTimer = new CustomTimingsHandler("Scheduler");
- 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 CustomTimingsHandler entityActivationCheckTimer = new CustomTimingsHandler("entityActivationCheck");
- public static final CustomTimingsHandler checkIfActiveTimer = new CustomTimingsHandler("** checkIfActive");
-
- 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 {
- 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) {
2017-10-29 16:19:21 +01:00
- String entityType = entity.getClass().getName();
2016-01-09 07:32:38 +01:00
- CustomTimingsHandler result = entityTypeTimingMap.get(entityType);
- if (result == null) {
2017-10-29 16:19:21 +01:00
- result = new CustomTimingsHandler("** tickEntity - " + entity.getClass().getSimpleName(), activatedEntityTimer);
2016-01-09 07:32:38 +01:00
- entityTypeTimingMap.put(entityType, result);
- }
- return result;
- }
-
- /**
- * Get a named timer for the specified tile entity type to track type specific timings.
- * @param entity
- * @return
- */
- public static CustomTimingsHandler getTileEntityTimings(TileEntity entity) {
2017-10-29 16:19:21 +01:00
- String entityType = entity.getClass().getName();
2016-01-09 07:32:38 +01:00
- CustomTimingsHandler result = tileEntityTypeTimingMap.get(entityType);
- if (result == null) {
2017-10-29 16:19:21 +01:00
- result = new CustomTimingsHandler("** tickTileEntity - " + entity.getClass().getSimpleName(), tickTileEntityTimer);
2016-01-09 07:32:38 +01:00
- tileEntityTypeTimingMap.put(entityType, result);
- }
- return result;
- }
-
- /**
- * Set of timers per world, to track world specific timings.
- */
- public static class WorldTimingsHandler {
- public final CustomTimingsHandler mobSpawn;
- public final CustomTimingsHandler doChunkUnload;
- public final CustomTimingsHandler doPortalForcer;
- public final CustomTimingsHandler doTickPending;
- public final CustomTimingsHandler doTickTiles;
- public final CustomTimingsHandler doVillages;
- public final CustomTimingsHandler doChunkMap;
- public final CustomTimingsHandler doSounds;
- 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 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");
- doPortalForcer = new CustomTimingsHandler("** " + name + "doPortalForcer");
- entityTick = new CustomTimingsHandler("** " + name + "entityTick");
- tileEntityTick = new CustomTimingsHandler("** " + name + "tileEntityTick");
- tileEntityPending = new CustomTimingsHandler("** " + name + "tileEntityPending");
-
- syncChunkLoadTimer = new CustomTimingsHandler("** " + name + "syncChunkLoad");
- syncChunkLoadStructuresTimer = new CustomTimingsHandler("** " + name + "chunkLoad - Structures");
- syncChunkLoadEntitiesTimer = new CustomTimingsHandler("** " + name + "chunkLoad - Entities");
- syncChunkLoadTileEntitiesTimer = new CustomTimingsHandler("** " + name + "chunkLoad - TileEntities");
- syncChunkLoadTileTicksTimer = new CustomTimingsHandler("** " + name + "chunkLoad - TileTicks");
- syncChunkLoadPostTimer = new CustomTimingsHandler("** " + name + "chunkLoad - Post");
-
-
- tracker = new CustomTimingsHandler(name + "tracker");
- doTick = new CustomTimingsHandler(name + "doTick");
- tickEntities = new CustomTimingsHandler(name + "tickEntities");
- }
- }
-}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
2019-05-14 04:20:58 +02:00
index 5b58b1a96..8980de820 100644
2016-01-09 07:32:38 +01:00
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
2019-05-06 04:58:04 +02:00
@@ -1728,6 +1728,14 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
2016-03-01 00:09:49 +01:00
packet.components = components;
getHandle().playerConnection.sendPacket(packet);
2016-01-09 07:32:38 +01:00
}
+
2018-09-29 01:31:59 +02:00
+ // Paper start
2016-01-09 07:32:38 +01:00
+ @Override
+ public int getPing()
+ {
+ return getHandle().ping;
+ }
2018-09-29 01:31:59 +02:00
+ // Paper end
2016-01-09 07:32:38 +01:00
};
public Player.Spigot spigot()
diff --git a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java
2019-05-14 04:20:58 +02:00
index b90979c7b..8823f94f7 100644
2016-01-09 07:32:38 +01:00
--- a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java
+++ b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java
2019-04-24 03:00:24 +02:00
@@ -1,5 +1,6 @@
package org.bukkit.craftbukkit.scheduler;
2017-02-05 06:13:16 +01:00
+import co.aikar.timings.MinecraftTimings; // Paper
2019-04-24 03:00:24 +02:00
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import java.util.ArrayList;
import java.util.Comparator;
2019-05-06 04:58:04 +02:00
@@ -248,7 +249,7 @@ public class CraftScheduler implements BukkitScheduler {
2016-01-09 07:32:38 +01:00
}
}
return false;
- }});
2016-04-30 03:23:40 +02:00
+ }}){{this.timings=co.aikar.timings.MinecraftTimings.getCancelTasksTimer();}}; // Paper
2018-03-31 11:34:25 +02:00
handle(task, 0L);
2016-01-09 07:32:38 +01:00
for (CraftTask taskPending = head.getNext(); taskPending != null; taskPending = taskPending.getNext()) {
if (taskPending == task) {
2019-05-06 04:58:04 +02:00
@@ -283,7 +284,7 @@ public class CraftScheduler implements BukkitScheduler {
2016-01-09 07:32:38 +01:00
}
}
}
- });
2016-04-30 03:23:40 +02:00
+ }){{this.timings=co.aikar.timings.MinecraftTimings.getCancelTasksTimer(plugin);}}; // Paper
2018-03-31 11:34:25 +02:00
handle(task, 0L);
2016-01-09 07:32:38 +01:00
for (CraftTask taskPending = head.getNext(); taskPending != null; taskPending = taskPending.getNext()) {
if (taskPending == task) {
2019-05-06 04:58:04 +02:00
@@ -390,9 +391,7 @@ public class CraftScheduler implements BukkitScheduler {
2016-01-09 07:32:38 +01:00
if (task.isSync()) {
2018-06-21 05:29:33 +02:00
currentTask = task;
2016-01-09 07:32:38 +01:00
try {
- task.timings.startTiming(); // Spigot
task.run();
- task.timings.stopTiming(); // Spigot
} catch (final Throwable throwable) {
task.getOwner().getLogger().log(
Level.WARNING,
2019-05-06 04:58:04 +02:00
@@ -419,8 +418,10 @@ public class CraftScheduler implements BukkitScheduler {
2017-02-05 06:13:16 +01:00
runners.remove(task.getTaskId());
}
}
+ MinecraftTimings.bukkitSchedulerFinishTimer.startTiming();
pending.addAll(temp);
temp.clear();
+ MinecraftTimings.bukkitSchedulerFinishTimer.stopTiming();
debugHead = debugHead.getNextHead(currentTick);
}
2019-05-06 04:58:04 +02:00
@@ -453,6 +454,7 @@ public class CraftScheduler implements BukkitScheduler {
2017-02-05 06:13:16 +01:00
}
private void parsePending() {
+ MinecraftTimings.bukkitSchedulerPendingTimer.startTiming();
CraftTask head = this.head;
CraftTask task = head.getNext();
CraftTask lastTask = head;
2019-05-06 04:58:04 +02:00
@@ -471,6 +473,7 @@ public class CraftScheduler implements BukkitScheduler {
2017-02-05 06:13:16 +01:00
task.setNext(null);
}
this.head = lastTask;
+ MinecraftTimings.bukkitSchedulerPendingTimer.stopTiming();
}
private boolean isReady(final int currentTick) {
2016-01-09 07:32:38 +01:00
diff --git a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftTask.java b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftTask.java
2019-05-14 04:20:58 +02:00
index 3f55381c1..0d9a46680 100644
2016-01-09 07:32:38 +01:00
--- a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftTask.java
+++ b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftTask.java
2019-03-26 06:31:59 +01:00
@@ -1,9 +1,11 @@
package org.bukkit.craftbukkit.scheduler;
2016-01-09 07:32:38 +01:00
2018-11-24 06:28:04 +01:00
import java.util.function.Consumer;
2019-03-26 06:31:59 +01:00
+
+import co.aikar.timings.NullTimingHandler;
2016-01-09 07:32:38 +01:00
import org.bukkit.Bukkit;
-import org.bukkit.craftbukkit.SpigotTimings; // Spigot
-import org.spigotmc.CustomTimingsHandler; // Spigot
2016-04-30 03:23:40 +02:00
+import co.aikar.timings.MinecraftTimings; // Paper
2016-03-01 00:09:49 +01:00
+import co.aikar.timings.Timing; // Paper
2016-01-09 07:32:38 +01:00
import org.bukkit.plugin.Plugin;
import org.bukkit.scheduler.BukkitTask;
2019-03-26 06:31:59 +01:00
@@ -26,12 +28,12 @@ public class CraftTask implements BukkitTask, Runnable { // Spigot
2016-01-09 07:32:38 +01:00
*/
private volatile long period;
private long nextRun;
2018-11-24 06:28:04 +01:00
- private final Runnable rTask;
- private final Consumer<BukkitTask> cTask;
+ public final Runnable rTask; // Paper
+ public final Consumer<BukkitTask> cTask; // Paper
2016-03-01 00:09:49 +01:00
+ public Timing timings; // Paper
2016-01-09 07:32:38 +01:00
private final Plugin plugin;
private final int id;
- final CustomTimingsHandler timings; // Spigot
CraftTask() {
2018-03-31 11:34:25 +02:00
this(null, null, CraftTask.NO_REPEATING, CraftTask.NO_REPEATING);
2016-01-09 07:32:38 +01:00
}
2019-03-26 06:31:59 +01:00
@@ -40,7 +42,7 @@ public class CraftTask implements BukkitTask, Runnable { // Spigot
2018-03-31 11:34:25 +02:00
this(null, task, CraftTask.NO_REPEATING, CraftTask.NO_REPEATING);
2016-01-09 07:32:38 +01:00
}
2018-11-24 06:28:04 +01:00
- CraftTask(final Plugin plugin, final Object task, final int id, final long period) {
+ CraftTask(final Plugin plugin, final Object task, final int id, final long period) { // Paper
2016-01-09 07:32:38 +01:00
this.plugin = plugin;
2018-11-24 06:28:04 +01:00
if (task instanceof Runnable) {
this.rTask = (Runnable) task;
2019-03-26 06:31:59 +01:00
@@ -57,7 +59,7 @@ public class CraftTask implements BukkitTask, Runnable { // Spigot
2018-11-24 06:28:04 +01:00
}
2016-01-09 07:32:38 +01:00
this.id = id;
this.period = period;
2018-11-24 06:28:04 +01:00
- this.timings = this.isSync() ? SpigotTimings.getPluginTaskTimings(this, period) : null; // Spigot
2019-03-26 06:31:59 +01:00
+ timings = task != null ? MinecraftTimings.getPluginTaskTimings(this, period) : NullTimingHandler.NULL; // Paper
2016-01-09 07:32:38 +01:00
}
2018-11-24 06:28:04 +01:00
@Override
2019-03-26 06:31:59 +01:00
@@ -77,11 +79,13 @@ public class CraftTask implements BukkitTask, Runnable { // Spigot
2016-01-09 07:32:38 +01:00
2018-11-24 06:28:04 +01:00
@Override
2016-01-09 07:32:38 +01:00
public void run() {
2019-03-26 05:31:34 +01:00
+ try (Timing ignored = timings.startTiming()) { // Paper
2018-11-24 06:28:04 +01:00
if (rTask != null) {
rTask.run();
} else {
cTask.accept(this);
}
2019-03-26 05:31:34 +01:00
+ } // Paper
2016-01-09 07:32:38 +01:00
}
long getPeriod() {
2019-03-26 06:31:59 +01:00
@@ -108,7 +112,7 @@ public class CraftTask implements BukkitTask, Runnable { // Spigot
2018-11-24 06:28:04 +01:00
this.next = next;
}
- Class<?> getTaskClass() {
+ public Class<?> getTaskClass() {
return (rTask != null) ? rTask.getClass() : ((cTask != null) ? cTask.getClass() : null);
}
2019-03-26 06:31:59 +01:00
@@ -132,9 +136,4 @@ public class CraftTask implements BukkitTask, Runnable { // Spigot
2016-01-09 07:32:38 +01:00
return true;
}
2018-11-24 06:28:04 +01:00
2016-01-09 07:32:38 +01:00
- // Spigot start
- public String getTaskName() {
2018-11-24 06:28:04 +01:00
- return (getTaskClass() == null) ? "Unknown" : getTaskClass().getName();
2016-01-09 07:32:38 +01:00
- }
- // Spigot end
}
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftIconCache.java b/src/main/java/org/bukkit/craftbukkit/util/CraftIconCache.java
2019-05-14 04:20:58 +02:00
index e52ef47b7..3d90b3426 100644
2016-01-09 07:32:38 +01:00
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftIconCache.java
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftIconCache.java
@@ -5,6 +5,7 @@ import org.bukkit.util.CachedServerIcon;
public class CraftIconCache implements CachedServerIcon {
public final String value;
2016-03-01 00:09:49 +01:00
+ public String getData() { return value; } // Paper
2016-01-09 07:32:38 +01:00
public CraftIconCache(final String value) {
this.value = value;
}
2019-05-06 09:20:16 +02:00
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
2019-05-14 04:20:58 +02:00
index bed971921..6775bf043 100644
2019-05-06 09:20:16 +02:00
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
@@ -271,6 +271,13 @@ public final class CraftMagicNumbers implements UnsafeValues {
return clazz;
}
+ // Paper start
+ @Override
+ public String getTimingsServerName() {
+ return com.destroystokyo.paper.PaperConfig.timingsServerName;
+ }
+ // Paper end
+
/**
* This helper class represents the different NBT Tags.
* <p>
2016-01-09 07:32:38 +01:00
diff --git a/src/main/java/org/spigotmc/ActivationRange.java b/src/main/java/org/spigotmc/ActivationRange.java
2019-05-14 04:20:58 +02:00
index 76b060a12..2daecf504 100644
2016-01-09 07:32:38 +01:00
--- a/src/main/java/org/spigotmc/ActivationRange.java
+++ b/src/main/java/org/spigotmc/ActivationRange.java
2018-07-15 03:53:17 +02:00
@@ -30,7 +30,7 @@ import net.minecraft.server.EntityWither;
2016-03-25 05:59:37 +01:00
import net.minecraft.server.MathHelper;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.World;
2016-01-09 07:32:38 +01:00
-import org.bukkit.craftbukkit.SpigotTimings;
2016-04-30 03:23:40 +02:00
+import co.aikar.timings.MinecraftTimings;
2016-01-09 07:32:38 +01:00
public class ActivationRange
{
2018-07-15 03:53:17 +02:00
@@ -64,8 +64,8 @@ public class ActivationRange
2016-04-30 03:23:40 +02:00
/**
* These entities are excluded from Activation range checks.
*
- * @param entity
- * @param world
+ * @param entity Entity to initialize
+ * @param config Spigot config to determine ranges
* @return boolean If it should always tick.
*/
public static boolean initializeEntityActivationState(Entity entity, SpigotWorldConfig config)
2018-07-15 03:53:17 +02:00
@@ -99,7 +99,7 @@ public class ActivationRange
2016-04-30 03:23:40 +02:00
*/
public static void activateEntities(World world)
{
- SpigotTimings.entityActivationCheckTimer.startTiming();
+ MinecraftTimings.entityActivationCheckTimer.startTiming();
final int miscActivationRange = world.spigotConfig.miscActivationRange;
final int animalActivationRange = world.spigotConfig.animalActivationRange;
final int monsterActivationRange = world.spigotConfig.monsterActivationRange;
2018-07-15 03:53:17 +02:00
@@ -133,7 +133,7 @@ public class ActivationRange
2016-04-30 03:23:40 +02:00
}
}
}
- SpigotTimings.entityActivationCheckTimer.stopTiming();
+ MinecraftTimings.entityActivationCheckTimer.stopTiming();
}
/**
2018-07-15 03:53:17 +02:00
@@ -247,10 +247,8 @@ public class ActivationRange
2016-03-18 22:11:53 +01:00
*/
public static boolean checkIfActive(Entity entity)
{
- SpigotTimings.checkIfActiveTimer.startTiming();
// Never safe to skip fireworks or entities not yet added to chunk
2018-07-15 03:53:17 +02:00
if ( !entity.inChunk || entity instanceof EntityFireworks ) {
2016-03-18 22:11:53 +01:00
- SpigotTimings.checkIfActiveTimer.stopTiming();
return true;
}
2019-05-07 02:05:41 +02:00
@@ -274,7 +272,6 @@ public class ActivationRange
2016-03-18 22:11:53 +01:00
{
isActive = false;
}
- SpigotTimings.checkIfActiveTimer.stopTiming();
return isActive;
}
}
2016-01-09 07:32:38 +01:00
--
2019-03-20 02:46:00 +01:00
2.21.0
2016-01-09 07:32:38 +01:00