2018-08-26 18:11:49 +00:00
From b78abc658c7bb0dfd27c6ad4b701005462f2c7d5 Mon Sep 17 00:00:00 2001
2016-01-09 06:32:38 +00:00
From: Aikar <aikar@aikar.co>
2016-03-03 09:46:26 +00:00
Date: Thu, 3 Mar 2016 04:00:11 -0600
2016-01-09 06:32:38 +00:00
Subject: [PATCH] Timings v2
2016-04-30 01:23:40 +00:00
diff --git a/src/main/java/co/aikar/timings/MinecraftTimings.java b/src/main/java/co/aikar/timings/MinecraftTimings.java
2016-01-10 07:33:27 +00:00
new file mode 100644
2018-08-04 21:03:53 +00:00
index 0000000000..4f624e39c7
2016-01-10 07:33:27 +00:00
--- /dev/null
2016-04-30 01:23:40 +00:00
+++ b/src/main/java/co/aikar/timings/MinecraftTimings.java
2017-05-14 18:05:01 +00:00
@@ -0,0 +1,125 @@
2016-01-10 07:33:27 +00:00
+package co.aikar.timings;
+
+import net.minecraft.server.*;
+import org.bukkit.plugin.Plugin;
+import org.bukkit.scheduler.BukkitTask;
+
+import org.bukkit.craftbukkit.scheduler.CraftTask;
+
2016-04-30 01:23:40 +00:00
+public final class MinecraftTimings {
2016-01-10 07:33:27 +00:00
+
+ public static final Timing playerListTimer = Timings.ofSafe("Player List");
2017-05-14 18:05:01 +00:00
+ public static final Timing commandFunctionsTimer = Timings.ofSafe("Command Functions");
2016-01-10 07:33:27 +00:00
+ public static final Timing connectionTimer = Timings.ofSafe("Connection Handler");
+ public static final Timing tickablesTimer = Timings.ofSafe("Tickables");
2016-02-24 04:35:34 +00:00
+ public static final Timing minecraftSchedulerTimer = Timings.ofSafe("Minecraft Scheduler");
+ public static final Timing bukkitSchedulerTimer = Timings.ofSafe("Bukkit Scheduler");
2017-02-05 05:13:16 +00:00
+ public static final Timing bukkitSchedulerPendingTimer = Timings.ofSafe("Bukkit Scheduler - Pending");
+ public static final Timing bukkitSchedulerFinishTimer = Timings.ofSafe("Bukkit Scheduler - Finishing");
2016-01-10 07:33:27 +00: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 20:42:49 +00:00
+ public static final Timing savePlayers = Timings.ofSafe("Save Players");
2016-01-10 07:33:27 +00:00
+
+ public static final Timing tickEntityTimer = Timings.ofSafe("## tickEntity");
+ public static final Timing tickTileEntityTimer = Timings.ofSafe("## tickTileEntity");
2017-02-05 05:13:16 +00: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 07:33:27 +00: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");
+
2016-04-30 01:23:40 +00:00
+ private MinecraftTimings() {}
2016-01-10 07:33:27 +00: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()) {
+ return null;
+ }
+ Plugin plugin;
+
+ Runnable task = ((CraftTask) bukkitTask).task;
+
+ final Class<? extends Runnable> taskClass = task.getClass();
+ if (bukkitTask.getOwner() != null) {
+ plugin = bukkitTask.getOwner();
+ } else {
+ plugin = TimingsManager.getPluginByClassloader(taskClass);
+ }
+
+ final String taskname;
+ if (taskClass.isAnonymousClass()) {
+ taskname = taskClass.getName();
+ } else {
+ taskname = taskClass.getCanonicalName();
+ }
+
2017-02-05 05:13:16 +00:00
+ StringBuilder name = new StringBuilder(64);
+ name.append("Task: ").append(taskname);
2016-01-10 07:33:27 +00:00
+ if (period > 0) {
2017-02-05 05:13:16 +00:00
+ name.append(" (interval:").append(period).append(")");
2016-01-10 07:33:27 +00:00
+ } else {
2017-02-05 05:13:16 +00:00
+ name.append(" (Single)");
2016-01-10 07:33:27 +00:00
+ }
+
+ if (plugin == null) {
2017-02-05 05:13:16 +00:00
+ return Timings.ofSafe(null, name.toString());
2016-01-10 07:33:27 +00:00
+ }
+
2017-02-05 05:13:16 +00:00
+ return Timings.ofSafe(plugin, name.toString());
2016-01-10 07:33:27 +00: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 01:53:17 +00:00
+ return Timings.ofSafe("## Scheduled Block: " + block.toString(), scheduledBlocksTimer);
2016-01-10 07:33:27 +00:00
+ }
2018-07-15 01:53:17 +00:00
+/*
2016-08-28 00:36:26 +00:00
+ public static Timing getStructureTiming(StructureGenerator structureGenerator) {
2017-02-05 05:13:16 +00:00
+ return Timings.ofSafe("Structure Generator - " + structureGenerator.getName(), structureGenerationTimer);
2018-07-15 01:53:17 +00:00
+ }*/
2017-02-05 05:13:16 +00:00
+
+ public static Timing getPacketTiming(Packet packet) {
+ return Timings.ofSafe("## Packet - " + packet.getClass().getSimpleName(), packetProcessTimer);
2016-08-28 00:36:26 +00:00
+ }
+}
2016-01-10 07:33:27 +00: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
2018-08-04 21:03:53 +00:00
index 0000000000..145cb274b0
2016-01-10 07:33:27 +00:00
--- /dev/null
+++ b/src/main/java/co/aikar/timings/WorldTimingsHandler.java
2018-07-15 01:53:17 +00:00
@@ -0,0 +1,104 @@
2016-01-10 07:33:27 +00:00
+package co.aikar.timings;
+
+import net.minecraft.server.World;
2018-07-15 01:53:17 +00:00
+import net.minecraft.server.WorldServer;
2016-01-10 07:33:27 +00:00
+
+/**
+ * Set of timers per world, to track world specific timings.
+ */
+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 00:36:26 +00:00
+ public final Timing lightChunk;
2016-01-10 07:33:27 +00:00
+ public final Timing chunkTicksBlocks;
+ public final Timing doVillages;
+ public final Timing doChunkMap;
2016-06-05 04:10:50 +00: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 07:33:27 +00: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 01:23:40 +00:00
+ public final Timing tracker1;
+ public final Timing tracker2;
2016-01-10 07:33:27 +00: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 01:53:17 +00:00
+ public final Timing syncChunkLoadPopulateTimer;
+ public final Timing chunkLoadLevelTimer;
2016-08-28 00:36:26 +00:00
+ public final Timing chunkGeneration;
+ public final Timing chunkIOStage1;
+ public final Timing chunkIOStage2;
2016-10-21 20:42:49 +00:00
+ public final Timing worldSave;
+ public final Timing worldSaveChunks;
+ public final Timing worldSaveLevel;
+ public final Timing chunkSaveData;
2016-01-10 07:33:27 +00: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 00:36:26 +00:00
+ lightChunk = Timings.ofSafe(name + "Light Chunk");
2016-01-10 07:33:27 +00:00
+ chunkTicksBlocks = Timings.ofSafe(name + "Chunk Ticks - Blocks");
+ doVillages = Timings.ofSafe(name + "doVillages");
+ doChunkMap = Timings.ofSafe(name + "doChunkMap");
2016-06-05 04:10:50 +00: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 07:33:27 +00: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 00:36:26 +00:00
+ syncChunkLoadStructuresTimer = Timings.ofSafe(name + "chunkLoad - recreateStructures");
2016-01-10 07:33:27 +00:00
+ syncChunkLoadPostTimer = Timings.ofSafe(name + "chunkLoad - Post");
2018-07-15 01:53:17 +00:00
+ syncChunkLoadPopulateTimer = Timings.ofSafe(name + "chunkLoad - Populate");
+ chunkLoadLevelTimer = Timings.ofSafe(name + "chunkLoad - Load Level");
2016-08-28 00:36:26 +00: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 20:42:49 +00: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 07:33:27 +00:00
+
2016-04-30 01:23:40 +00:00
+ tracker1 = Timings.ofSafe(name + "tracker stage 1");
+ tracker2 = Timings.ofSafe(name + "tracker stage 2");
2016-01-10 07:33:27 +00:00
+ doTick = Timings.ofSafe(name + "doTick");
+ tickEntities = Timings.ofSafe(name + "tickEntities");
+ }
2018-07-15 01:53:17 +00:00
+
+ public static Timing getTickList(WorldServer worldserver, String timingsType) {
+ return Timings.ofSafe(worldserver.getWorldData().getName() + " - Scheduled " + timingsType);
+ }
2016-01-10 07:33:27 +00:00
+}
2016-02-29 23:09:49 +00:00
diff --git a/src/main/java/com/destroystokyo/paper/PaperConfig.java b/src/main/java/com/destroystokyo/paper/PaperConfig.java
2018-08-04 21:03:53 +00:00
index d2efcca80a..4812da0dac 100644
2016-02-29 23:09:49 +00:00
--- a/src/main/java/com/destroystokyo/paper/PaperConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java
2016-05-02 03:54:08 +00:00
@@ -14,11 +14,14 @@ import java.util.concurrent.TimeUnit;
2016-02-29 23:09:49 +00:00
import java.util.logging.Level;
2016-05-02 03:54:08 +00:00
import java.util.regex.Pattern;
2016-02-29 23:09:49 +00: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 {
2018-07-24 00:24:44 +00:00
@@ -180,4 +183,24 @@ public class PaperConfig {
2016-03-25 04:59:37 +00:00
config.addDefault(path, def);
return config.getString(path, config.getString(path));
2016-02-29 23:09:49 +00: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);
+
+
+ Timings.setVerboseTimingsEnabled(verboseTimings);
+ Timings.setTimingsEnabled(timings);
+ Timings.setHistoryInterval(timingHistoryInterval * 20);
+ Timings.setHistoryLength(timingHistoryLength * 20);
+
2017-03-25 03:18:58 +00:00
+ log("Timings: " + timings +
2016-02-29 23:09:49 +00:00
+ " - Verbose: " + verboseTimings +
+ " - Interval: " + timeSummary(Timings.getHistoryInterval() / 20) +
+ " - Length: " + timeSummary(Timings.getHistoryLength() / 20));
+ }
}
2016-01-09 06:32:38 +00:00
diff --git a/src/main/java/net/minecraft/server/Block.java b/src/main/java/net/minecraft/server/Block.java
2018-08-26 18:11:49 +00:00
index 8811dbc9b3..7818a3b6a7 100644
2016-01-09 06:32:38 +00:00
--- a/src/main/java/net/minecraft/server/Block.java
+++ b/src/main/java/net/minecraft/server/Block.java
2018-08-26 18:11:49 +00:00
@@ -23,6 +23,15 @@ public class Block implements IMaterial {
protected final boolean i;
protected final SoundEffectType stepSound;
protected final Material material;
+ // Paper start
2016-01-10 07:33:27 +00:00
+ public co.aikar.timings.Timing timing;
+ public co.aikar.timings.Timing getTiming() {
2016-01-09 06:32:38 +00:00
+ if (timing == null) {
2016-04-30 01:23:40 +00:00
+ timing = co.aikar.timings.MinecraftTimings.getBlockTiming(this);
2016-01-09 06:32:38 +00:00
+ }
+ return timing;
+ }
2016-02-29 23:09:49 +00:00
+ // Paper end
2018-08-26 18:11:49 +00:00
protected final MaterialMapColor l;
private final float frictionFactor;
protected final BlockStateList<Block, IBlockData> blockStateList;
2018-07-15 01:53:17 +00:00
diff --git a/src/main/java/net/minecraft/server/ChunkMap.java b/src/main/java/net/minecraft/server/ChunkMap.java
2018-08-26 18:11:49 +00:00
index e3d1761b49..fbebd4591c 100644
2018-07-15 01:53:17 +00:00
--- a/src/main/java/net/minecraft/server/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/ChunkMap.java
@@ -14,6 +14,7 @@ public class ChunkMap extends Long2ObjectOpenHashMap<Chunk> {
}
2016-02-29 23:09:49 +00:00
2018-07-15 01:53:17 +00:00
public Chunk a(long i, Chunk chunk) {
+ chunk.world.timings.syncChunkLoadPostTimer.startTiming(); // Paper
Chunk chunk1 = (Chunk) super.put(i, chunk);
ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(i);
2016-08-28 00:36:26 +00:00
2018-07-30 05:08:59 +00:00
@@ -46,8 +47,10 @@ public class ChunkMap extends Long2ObjectOpenHashMap<Chunk> {
2018-07-15 01:53:17 +00:00
}
2016-08-28 00:36:26 +00:00
}
}
2018-07-15 01:53:17 +00:00
+ chunk.world.timings.syncChunkLoadPostTimer.stopTiming(); // Paper
if (chunk.newChunk) {
+ chunk.world.timings.syncChunkLoadPopulateTimer.startTiming(); // Paper
BlockSand.instaFall = true;
java.util.Random random = new java.util.Random();
random.setSeed(chunk.world.getSeed());
2018-07-30 05:08:59 +00:00
@@ -68,6 +71,7 @@ public class ChunkMap extends Long2ObjectOpenHashMap<Chunk> {
2016-08-28 00:36:26 +00:00
}
2018-07-15 01:53:17 +00:00
BlockSand.instaFall = false;
chunk.world.getServer().getPluginManager().callEvent(new org.bukkit.event.world.ChunkPopulateEvent(chunk.bukkitChunk));
+ chunk.world.timings.syncChunkLoadPopulateTimer.stopTiming(); // Paper
2016-08-28 00:36:26 +00:00
}
2018-07-30 05:08:59 +00:00
// CraftBukkit end
2016-08-28 00:36:26 +00:00
2016-10-21 20:42:49 +00:00
diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java
2018-08-26 18:11:49 +00:00
index 9e805c5d22..0034956af9 100644
2016-10-21 20:42:49 +00:00
--- a/src/main/java/net/minecraft/server/ChunkProviderServer.java
+++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java
2018-08-26 18:11:49 +00:00
@@ -90,7 +90,7 @@ public class ChunkProviderServer implements IChunkProvider {
}
if (flag) {
- try {
+ try (co.aikar.timings.Timing timing = world.timings.syncChunkLoadTimer.startTiming()) { // Paper
// CraftBukkit - decompile error
chunk = this.chunkLoader.a(this.world, i, j, (chunk1) -> {
chunk1.setLastSaved(this.world.getTime());
@@ -106,8 +106,7 @@ public class ChunkProviderServer implements IChunkProvider {
this.asyncTaskHandler.postToMainThread(chunk::addEntities);
2018-07-22 05:27:46 +00:00
return chunk;
2018-08-26 18:11:49 +00:00
} else if (flag1) {
2018-07-22 05:27:46 +00:00
- try {
- world.timings.syncChunkLoadTimer.startTiming(); // Spigot
2018-08-26 18:11:49 +00:00
+ try (co.aikar.timings.Timing timing = world.timings.chunkGeneration.startTiming()) { // Paper
this.batchScheduler.b();
this.batchScheduler.a(new ChunkCoordIntPair(i, j));
CompletableFuture<ProtoChunk> completablefuture = this.batchScheduler.c(); // CraftBukkit - decompile error
@@ -116,7 +115,7 @@ public class ChunkProviderServer implements IChunkProvider {
} catch (RuntimeException runtimeexception) {
throw this.a(i, j, (Throwable) runtimeexception);
2018-07-22 05:27:46 +00:00
}
- finally { world.timings.syncChunkLoadTimer.stopTiming(); } // Spigot
2018-08-26 18:11:49 +00:00
+ // finally { world.timings.syncChunkLoadTimer.stopTiming(); } // Spigot // Paper
} else {
return null;
2018-07-22 05:27:46 +00:00
}
2018-08-26 18:11:49 +00:00
@@ -206,7 +205,7 @@ public class ChunkProviderServer implements IChunkProvider {
2016-10-21 20:42:49 +00:00
}
2018-07-15 01:53:17 +00:00
public void saveChunk(IChunkAccess ichunkaccess, boolean unloaded) { // Spigot
2016-10-21 20:42:49 +00:00
- try {
2018-07-15 01:53:17 +00:00
+ try (co.aikar.timings.Timing timed = world.timings.chunkSaveData.startTiming()) { // Paper - Timings
ichunkaccess.setLastSaved(this.world.getTime());
this.chunkLoader.saveChunk(this.world, ichunkaccess, unloaded); // Spigot
2016-10-21 20:42:49 +00:00
} catch (IOException ioexception) {
2016-08-28 00:36:26 +00:00
diff --git a/src/main/java/net/minecraft/server/ChunkRegionLoader.java b/src/main/java/net/minecraft/server/ChunkRegionLoader.java
2018-08-26 18:11:49 +00:00
index df07b2b889..f969c036f3 100644
2016-08-28 00:36:26 +00:00
--- a/src/main/java/net/minecraft/server/ChunkRegionLoader.java
+++ b/src/main/java/net/minecraft/server/ChunkRegionLoader.java
2018-07-15 01:53:17 +00:00
@@ -1,5 +1,6 @@
package net.minecraft.server;
2016-08-28 00:36:26 +00:00
2018-07-15 01:53:17 +00:00
+import co.aikar.timings.Timings;
import com.google.common.collect.Maps;
import com.mojang.datafixers.DataFixTypes;
import com.mojang.datafixers.DataFixer;
2018-08-26 18:11:49 +00:00
@@ -678,7 +679,7 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver {
2018-07-15 01:53:17 +00:00
public void loadEntities(NBTTagCompound nbttagcompound, Chunk chunk) {
NBTTagList nbttaglist = nbttagcompound.getList("Entities", 10);
World world = chunk.getWorld();
2016-08-28 00:36:26 +00:00
- world.timings.syncChunkLoadEntitiesTimer.startTiming(); // Spigot
2018-07-15 01:53:17 +00:00
+ world.timings.chunkLoadLevelTimer.startTiming(); // Spigot
2016-08-28 00:36:26 +00:00
2018-07-15 01:53:17 +00:00
for (int i = 0; i < nbttaglist.size(); ++i) {
NBTTagCompound nbttagcompound1 = nbttaglist.getCompound(i);
2018-08-26 18:11:49 +00:00
@@ -687,8 +688,6 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver {
2018-07-15 01:53:17 +00:00
chunk.f(true);
2016-08-28 00:36:26 +00:00
}
2018-07-15 01:53:17 +00:00
2016-08-28 00:36:26 +00:00
- world.timings.syncChunkLoadEntitiesTimer.stopTiming(); // Spigot
- world.timings.syncChunkLoadTileEntitiesTimer.startTiming(); // Spigot
2018-07-15 01:53:17 +00:00
NBTTagList nbttaglist1 = nbttagcompound.getList("TileEntities", 10);
2016-08-28 00:36:26 +00:00
2018-07-15 01:53:17 +00:00
for (int j = 0; j < nbttaglist1.size(); ++j) {
2018-08-26 18:11:49 +00:00
@@ -705,8 +704,6 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver {
2018-07-15 01:53:17 +00:00
}
2016-08-28 00:36:26 +00:00
}
}
- world.timings.syncChunkLoadTileEntitiesTimer.stopTiming(); // Spigot
- world.timings.syncChunkLoadTileTicksTimer.startTiming(); // Spigot
2018-08-26 18:11:49 +00:00
if (nbttagcompound.hasKeyOfType("TileTicks", 9) && world.J() instanceof TickListServer) {
((TickListServer) world.J()).a(nbttagcompound.getList("TileTicks", 10));
@@ -715,7 +712,7 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver {
if (nbttagcompound.hasKeyOfType("LiquidTicks", 9) && world.I() instanceof TickListServer) {
((TickListServer) world.I()).a(nbttagcompound.getList("LiquidTicks", 10));
2016-08-28 00:36:26 +00:00
}
- world.timings.syncChunkLoadTileTicksTimer.stopTiming(); // Spigot
2018-07-15 01:53:17 +00:00
+ world.timings.chunkLoadLevelTimer.stopTiming(); // Spigot
2016-08-28 00:36:26 +00:00
}
2018-07-15 01:53:17 +00:00
2016-01-09 06:32:38 +00:00
diff --git a/src/main/java/net/minecraft/server/DedicatedServer.java b/src/main/java/net/minecraft/server/DedicatedServer.java
2018-08-26 18:11:49 +00:00
index efa738d4ec..dabad6b055 100644
2016-01-09 06:32:38 +00:00
--- a/src/main/java/net/minecraft/server/DedicatedServer.java
+++ b/src/main/java/net/minecraft/server/DedicatedServer.java
2018-07-15 01:53:17 +00:00
@@ -29,7 +29,7 @@ import org.apache.logging.log4j.Level;
2016-01-09 06:32:38 +00:00
2018-07-15 01:53:17 +00:00
import org.bukkit.command.CommandSender;
2016-01-09 06:32:38 +00:00
import org.bukkit.craftbukkit.LoggerOutputStream;
-import org.bukkit.craftbukkit.SpigotTimings; // Spigot
2016-04-30 01:23:40 +00:00
+import co.aikar.timings.MinecraftTimings; // Paper
2016-01-09 06:32:38 +00:00
import org.bukkit.event.server.ServerCommandEvent;
import org.bukkit.craftbukkit.util.Waitable;
import org.bukkit.event.server.RemoteServerCommandEvent;
2018-07-15 01:53:17 +00:00
@@ -443,7 +443,7 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer
2016-04-30 01:23:40 +00:00
}
2018-08-26 18:11:49 +00:00
public void aU() {
2016-04-30 01:23:40 +00:00
- SpigotTimings.serverCommandTimer.startTiming(); // Spigot
+ MinecraftTimings.serverCommandTimer.startTiming(); // Spigot
while (!this.serverCommandQueue.isEmpty()) {
ServerCommand servercommand = (ServerCommand) this.serverCommandQueue.remove(0);
2018-07-15 01:53:17 +00:00
@@ -458,7 +458,7 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer
2016-04-30 01:23:40 +00:00
// CraftBukkit end
}
- SpigotTimings.serverCommandTimer.stopTiming(); // Spigot
+ MinecraftTimings.serverCommandTimer.stopTiming(); // Spigot
}
2018-08-26 18:11:49 +00:00
public boolean Q() {
2018-07-15 01:53:17 +00:00
@@ -708,7 +708,20 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer
2017-02-05 03:47:39 +00: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 06:32:38 +00:00
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
2018-08-26 18:11:49 +00:00
index 591ae114cf..ec5c9fd735 100644
2016-01-09 06:32:38 +00:00
--- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java
2018-07-15 01:53:17 +00:00
@@ -29,7 +29,8 @@ import org.bukkit.command.CommandSender;
2016-02-29 23:09:49 +00:00
import org.bukkit.entity.Hanging;
2016-01-09 06:32:38 +00:00
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Vehicle;
-import org.spigotmc.CustomTimingsHandler; // Spigot
2016-04-30 01:23:40 +00:00
+import co.aikar.timings.MinecraftTimings; // Paper
2016-02-29 23:09:49 +00:00
+import co.aikar.timings.Timing; // Paper
2016-01-09 06:32:38 +00:00
import org.bukkit.event.entity.EntityCombustByEntityEvent;
import org.bukkit.event.hanging.HangingBreakByEntityEvent;
2016-02-29 23:09:49 +00:00
import org.bukkit.event.vehicle.VehicleBlockCollisionEvent;
2018-07-31 01:19:41 +00:00
@@ -160,7 +161,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
2017-11-08 16:13:57 +00:00
public boolean valid;
public org.bukkit.projectiles.ProjectileSource projectileSource; // For projectiles only
public boolean forceExplosionKnockback; // SPIGOT-949
2016-01-09 06:32:38 +00:00
- public CustomTimingsHandler tickTimer = org.bukkit.craftbukkit.SpigotTimings.getEntityTimings(this); // Spigot
2016-04-30 01:23:40 +00:00
+ public Timing tickTimer = MinecraftTimings.getEntityTimings(this); // Paper
2016-02-29 23:09:49 +00:00
// Spigot start
2016-01-09 06:32:38 +00:00
public final byte activationType = org.spigotmc.ActivationRange.initializeEntityActivationType(this);
public final boolean defaultActivationState;
2018-08-26 18:11:49 +00:00
@@ -536,7 +537,6 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
2016-02-29 23:09:49 +00:00
}
2016-01-09 06:32:38 +00:00
2016-11-17 02:23:38 +00:00
public void move(EnumMoveType enummovetype, double d0, double d1, double d2) {
2016-01-09 06:32:38 +00:00
- org.bukkit.craftbukkit.SpigotTimings.entityMoveTimer.startTiming(); // Spigot
if (this.noclip) {
2016-11-17 02:23:38 +00:00
this.a(this.getBoundingBox().d(d0, d1, d2));
2016-02-29 23:09:49 +00:00
this.recalcPosition();
2018-08-26 18:11:49 +00:00
@@ -886,7 +886,6 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
2016-01-09 06:32:38 +00:00
2018-07-15 01:53:17 +00:00
this.world.methodProfiler.e();
2016-01-09 06:32:38 +00:00
}
- org.bukkit.craftbukkit.SpigotTimings.entityMoveTimer.stopTiming(); // Spigot
}
2018-07-15 01:53:17 +00:00
protected float ab() {
2016-01-09 06:32:38 +00:00
diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java
2018-08-26 18:11:49 +00:00
index 91c4785889..8a41a1dca8 100644
2016-01-09 06:32:38 +00:00
--- a/src/main/java/net/minecraft/server/EntityLiving.java
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
2018-07-20 19:57:43 +00:00
@@ -32,7 +32,7 @@ import org.bukkit.event.entity.EntityTeleportEvent;
2016-02-29 23:09:49 +00:00
import org.bukkit.event.player.PlayerItemConsumeEvent;
2016-01-09 06:32:38 +00:00
// CraftBukkit end
-import org.bukkit.craftbukkit.SpigotTimings; // Spigot
2016-04-30 01:23:40 +00:00
+import co.aikar.timings.MinecraftTimings; // Paper
2016-01-09 06:32:38 +00:00
public abstract class EntityLiving extends Entity {
2018-08-26 18:11:49 +00:00
@@ -2020,7 +2020,6 @@ public abstract class EntityLiving extends Entity {
2016-01-09 06:32:38 +00:00
}
2018-07-15 01:53:17 +00:00
public void tick() {
2016-01-09 06:32:38 +00:00
- SpigotTimings.timerEntityBaseTick.startTiming(); // Spigot
2018-07-15 01:53:17 +00:00
super.tick();
2018-07-22 05:27:46 +00:00
this.cV();
2018-07-15 01:53:17 +00:00
this.o();
2018-08-26 18:11:49 +00:00
@@ -2094,9 +2093,7 @@ public abstract class EntityLiving extends Entity {
2016-01-09 06:32:38 +00:00
}
}
- SpigotTimings.timerEntityBaseTick.stopTiming(); // Spigot
2018-07-15 01:53:17 +00:00
this.k();
2016-01-09 06:32:38 +00:00
- SpigotTimings.timerEntityTickRest.startTiming(); // Spigot
double d0 = this.locX - this.lastX;
double d1 = this.locZ - this.lastZ;
float f = (float) (d0 * d0 + d1 * d1);
2018-08-26 18:11:49 +00:00
@@ -2172,8 +2169,6 @@ public abstract class EntityLiving extends Entity {
2016-02-29 23:09:49 +00:00
} else {
2018-07-15 01:53:17 +00:00
this.bv = 0;
2016-02-29 23:09:49 +00:00
}
-
2016-01-09 06:32:38 +00:00
- SpigotTimings.timerEntityTickRest.stopTiming(); // Spigot
}
2018-07-15 01:53:17 +00:00
protected float e(float f, float f1) {
2018-08-26 18:11:49 +00:00
@@ -2243,7 +2238,6 @@ public abstract class EntityLiving extends Entity {
2016-01-09 06:32:38 +00:00
}
this.world.methodProfiler.a("ai");
- SpigotTimings.timerEntityAI.startTiming(); // Spigot
2016-11-17 02:23:38 +00:00
if (this.isFrozen()) {
2018-07-15 01:53:17 +00:00
this.bg = false;
this.bh = 0.0F;
2018-08-26 18:11:49 +00:00
@@ -2254,7 +2248,6 @@ public abstract class EntityLiving extends Entity {
2016-01-09 06:32:38 +00:00
this.doTick();
2018-07-15 01:53:17 +00:00
this.world.methodProfiler.e();
2016-01-09 06:32:38 +00:00
}
- SpigotTimings.timerEntityAI.stopTiming(); // Spigot
2018-07-15 01:53:17 +00:00
this.world.methodProfiler.e();
2016-01-09 06:32:38 +00:00
this.world.methodProfiler.a("jump");
2018-08-26 18:11:49 +00:00
@@ -2279,9 +2272,7 @@ public abstract class EntityLiving extends Entity {
2018-07-15 01:53:17 +00:00
this.n();
AxisAlignedBB axisalignedbb = this.getBoundingBox();
2016-01-09 06:32:38 +00:00
- SpigotTimings.timerEntityAIMove.startTiming(); // Spigot
2018-07-15 01:53:17 +00:00
this.a(this.bh, this.bi, this.bj);
2016-01-09 06:32:38 +00:00
- SpigotTimings.timerEntityAIMove.stopTiming(); // Spigot
2018-07-15 01:53:17 +00:00
this.world.methodProfiler.e();
2016-01-09 06:32:38 +00:00
this.world.methodProfiler.a("push");
2018-07-15 01:53:17 +00:00
if (this.bw > 0) {
2018-08-26 18:11:49 +00:00
@@ -2289,9 +2280,7 @@ public abstract class EntityLiving extends Entity {
2018-07-15 01:53:17 +00:00
this.a(axisalignedbb, this.getBoundingBox());
}
2016-02-29 23:09:49 +00:00
- SpigotTimings.timerEntityAICollision.startTiming(); // Spigot
2018-07-22 05:27:46 +00:00
this.cN();
2016-02-29 23:09:49 +00:00
- SpigotTimings.timerEntityAICollision.stopTiming(); // Spigot
2018-07-15 01:53:17 +00:00
this.world.methodProfiler.e();
2016-02-29 23:09:49 +00:00
}
2016-04-30 01:23:40 +00:00
diff --git a/src/main/java/net/minecraft/server/EntityTracker.java b/src/main/java/net/minecraft/server/EntityTracker.java
2018-08-04 21:03:53 +00:00
index ae31935c48..70c9b1f50c 100644
2016-04-30 01:23:40 +00:00
--- a/src/main/java/net/minecraft/server/EntityTracker.java
+++ b/src/main/java/net/minecraft/server/EntityTracker.java
2018-07-15 01:53:17 +00:00
@@ -168,7 +168,7 @@ public class EntityTracker {
2016-04-30 01:23:40 +00:00
public void updatePlayers() {
ArrayList arraylist = Lists.newArrayList();
Iterator iterator = this.c.iterator();
-
+ world.timings.tracker1.startTiming(); // Spigot
while (iterator.hasNext()) {
EntityTrackerEntry entitytrackerentry = (EntityTrackerEntry) iterator.next();
2018-07-15 01:53:17 +00:00
@@ -181,7 +181,9 @@ public class EntityTracker {
2016-04-30 01:23:40 +00:00
}
}
}
+ world.timings.tracker1.stopTiming(); // Spigot
+ world.timings.tracker2.startTiming(); // Spigot
for (int i = 0; i < arraylist.size(); ++i) {
EntityPlayer entityplayer = (EntityPlayer) arraylist.get(i);
Iterator iterator1 = this.c.iterator();
2018-07-15 01:53:17 +00:00
@@ -194,6 +196,7 @@ public class EntityTracker {
2016-04-30 01:23:40 +00:00
}
}
}
+ world.timings.tracker2.stopTiming(); // Spigot
}
2016-01-09 06:32:38 +00:00
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
2018-08-26 18:11:49 +00:00
index 2c69e68276..0ebe754619 100644
2016-01-09 06:32:38 +00:00
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
2018-07-15 01:53:17 +00:00
@@ -1,5 +1,6 @@
package net.minecraft.server;
+import co.aikar.timings.Timings;
import com.google.common.base.Stopwatch;
import com.google.common.collect.Lists;
2018-08-26 18:11:49 +00:00
import com.google.common.collect.Maps;
@@ -66,8 +67,8 @@ import org.bukkit.Bukkit;
2016-05-12 02:07:46 +00:00
import org.bukkit.craftbukkit.CraftServer;
2016-07-15 22:36:53 +00:00
import org.bukkit.craftbukkit.Main;
2016-01-09 06:32:38 +00:00
// CraftBukkit end
2016-02-29 23:09:49 +00:00
-import org.bukkit.craftbukkit.SpigotTimings; // Spigot
2017-01-31 04:33:54 +00:00
import org.spigotmc.SlackActivityAccountant; // Spigot
2016-04-30 01:23:40 +00:00
+import co.aikar.timings.MinecraftTimings; // Paper
2016-01-09 06:32:38 +00:00
2018-07-15 01:53:17 +00:00
public abstract class MinecraftServer implements IAsyncTaskHandler, IMojangStatistics, ICommandListener, Runnable {
2016-02-29 23:09:49 +00:00
2018-08-26 18:11:49 +00:00
@@ -616,6 +617,7 @@ public abstract class MinecraftServer implements IAsyncTaskHandler, IMojangStati
2016-02-29 23:09:49 +00:00
}
2016-01-09 06:32:38 +00:00
// CraftBukkit end
2016-02-29 23:09:49 +00:00
MinecraftServer.LOGGER.info("Stopping server");
2016-04-30 01:23:40 +00:00
+ MinecraftTimings.stopServer(); // Paper
2016-03-03 09:46:26 +00:00
// CraftBukkit start
if (this.server != null) {
this.server.disablePlugins();
2018-08-26 18:11:49 +00:00
@@ -817,7 +819,7 @@ public abstract class MinecraftServer implements IAsyncTaskHandler, IMojangStati
public void t() {}
2016-01-09 06:32:38 +00:00
2018-08-26 18:11:49 +00:00
protected void a(BooleanSupplier booleansupplier) {
2016-01-09 06:32:38 +00:00
- SpigotTimings.serverTickTimer.startTiming(); // Spigot
2016-02-29 23:09:49 +00:00
+ co.aikar.timings.TimingsManager.FULL_SERVER_TICK.startTiming(); // Paper
2017-01-31 04:33:54 +00:00
this.slackActivityAccountant.tickStarted(); // Spigot
2018-07-15 01:53:17 +00:00
long i = SystemUtils.c();
2016-01-09 06:32:38 +00:00
2018-08-26 18:11:49 +00:00
@@ -844,7 +846,6 @@ public abstract class MinecraftServer implements IAsyncTaskHandler, IMojangStati
2016-04-30 01:23:40 +00:00
}
if (autosavePeriod > 0 && this.ticks % autosavePeriod == 0) { // CraftBukkit
- SpigotTimings.worldSaveTimer.startTiming(); // Spigot
this.methodProfiler.a("save");
2018-07-15 01:53:17 +00:00
this.s.savePlayers();
2016-04-30 01:23:40 +00:00
// Spigot Start
2018-08-26 18:11:49 +00:00
@@ -859,7 +860,6 @@ public abstract class MinecraftServer implements IAsyncTaskHandler, IMojangStati
2016-04-30 01:23:40 +00:00
// this.saveChunks(true);
// Spigot End
2018-07-15 01:53:17 +00:00
this.methodProfiler.e();
2016-04-30 01:23:40 +00:00
- SpigotTimings.worldSaveTimer.stopTiming(); // Spigot
}
2018-07-15 01:53:17 +00:00
this.methodProfiler.a("snooper");
2018-08-26 18:11:49 +00:00
@@ -880,14 +880,14 @@ public abstract class MinecraftServer implements IAsyncTaskHandler, IMojangStati
2018-07-15 01:53:17 +00:00
this.methodProfiler.e();
2016-01-09 06:32:38 +00:00
org.spigotmc.WatchdogThread.tick(); // Spigot
2018-07-15 01:53:17 +00:00
this.slackActivityAccountant.tickEnded(l); // Spigot
2016-01-09 06:32:38 +00:00
- SpigotTimings.serverTickTimer.stopTiming(); // Spigot
- org.spigotmc.CustomTimingsHandler.tick(); // Spigot
2016-02-29 23:09:49 +00:00
+ co.aikar.timings.TimingsManager.FULL_SERVER_TICK.stopTiming(); // Paper
2016-01-09 06:32:38 +00:00
}
2018-08-26 18:11:49 +00:00
public void b(BooleanSupplier booleansupplier) {
2016-06-30 05:38:53 +00:00
- SpigotTimings.schedulerTimer.startTiming(); // Spigot
+ MinecraftTimings.bukkitSchedulerTimer.startTiming(); // Paper
this.server.getScheduler().mainThreadHeartbeat(this.ticks); // CraftBukkit
- SpigotTimings.schedulerTimer.stopTiming(); // Spigot
+ MinecraftTimings.bukkitSchedulerTimer.stopTiming(); // Paper
2016-04-30 01:23:40 +00:00
+ MinecraftTimings.minecraftSchedulerTimer.startTiming(); // Paper
2016-02-24 04:35:34 +00:00
this.methodProfiler.a("jobs");
2018-07-15 01:53:17 +00:00
FutureTask futuretask;
2018-08-26 18:11:49 +00:00
@@ -895,26 +895,27 @@ public abstract class MinecraftServer implements IAsyncTaskHandler, IMojangStati
while ((futuretask = (FutureTask) this.f.poll()) != null) {
2018-07-15 01:53:17 +00:00
SystemUtils.a(futuretask, MinecraftServer.LOGGER);
}
2016-04-30 01:23:40 +00:00
+ MinecraftTimings.minecraftSchedulerTimer.stopTiming(); // Paper
2016-02-24 04:35:34 +00:00
2018-07-15 01:53:17 +00:00
this.methodProfiler.c("commandFunctions");
- SpigotTimings.commandFunctionsTimer.startTiming(); // Spigot
+ MinecraftTimings.commandFunctionsTimer.startTiming(); // Spigot
2018-07-22 05:27:46 +00:00
this.getFunctionData().Y_();
2018-07-15 01:53:17 +00:00
- SpigotTimings.commandFunctionsTimer.stopTiming(); // Spigot
+ MinecraftTimings.commandFunctionsTimer.stopTiming(); // Spigot
2016-02-24 04:35:34 +00:00
this.methodProfiler.c("levels");
// CraftBukkit start
// Run tasks that are waiting on processing
2016-04-30 01:23:40 +00:00
- SpigotTimings.processQueueTimer.startTiming(); // Spigot
+ MinecraftTimings.processQueueTimer.startTiming(); // Spigot
while (!processQueue.isEmpty()) {
processQueue.remove().run();
}
- SpigotTimings.processQueueTimer.stopTiming(); // Spigot
+ MinecraftTimings.processQueueTimer.stopTiming(); // Spigot
- SpigotTimings.chunkIOTickTimer.startTiming(); // Spigot
+ MinecraftTimings.chunkIOTickTimer.startTiming(); // Spigot
org.bukkit.craftbukkit.chunkio.ChunkIOExecutor.tick();
- SpigotTimings.chunkIOTickTimer.stopTiming(); // Spigot
+ MinecraftTimings.chunkIOTickTimer.stopTiming(); // Spigot
- SpigotTimings.timeUpdateTimer.startTiming(); // Spigot
+ MinecraftTimings.timeUpdateTimer.startTiming(); // Spigot
// Send time updates to everyone, it will get the right time from the world the player is in.
if (this.ticks % 20 == 0) {
for (int i = 0; i < this.getPlayerList().players.size(); ++i) {
2018-08-26 18:11:49 +00:00
@@ -922,7 +923,7 @@ public abstract class MinecraftServer implements IAsyncTaskHandler, IMojangStati
2016-04-30 01:23:40 +00: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
+ MinecraftTimings.timeUpdateTimer.stopTiming(); // Spigot
2018-08-26 18:11:49 +00:00
// WorldServer worldserver; // CraftBukkit - dropped down
long i;
@@ -981,29 +982,27 @@ public abstract class MinecraftServer implements IAsyncTaskHandler, IMojangStati
2016-04-30 01:23:40 +00:00
2018-07-15 01:53:17 +00:00
this.methodProfiler.e();
2016-04-30 01:23:40 +00:00
this.methodProfiler.a("tracker");
- worldserver.timings.tracker.startTiming(); // Spigot
worldserver.getTracker().updatePlayers();
- worldserver.timings.tracker.stopTiming(); // Spigot
2018-07-15 01:53:17 +00:00
this.methodProfiler.e();
this.methodProfiler.e();
}
2016-04-30 01:23:40 +00:00
}
this.methodProfiler.c("connection");
- SpigotTimings.connectionTimer.startTiming(); // Spigot
+ MinecraftTimings.connectionTimer.startTiming(); // Spigot
2018-07-15 01:53:17 +00:00
this.getServerConnection().c();
2016-04-30 01:23:40 +00:00
- SpigotTimings.connectionTimer.stopTiming(); // Spigot
+ MinecraftTimings.connectionTimer.stopTiming(); // Spigot
this.methodProfiler.c("players");
- SpigotTimings.playerListTimer.startTiming(); // Spigot
+ MinecraftTimings.playerListTimer.startTiming(); // Spigot
2018-07-15 01:53:17 +00:00
this.s.tick();
2016-04-30 01:23:40 +00:00
- SpigotTimings.playerListTimer.stopTiming(); // Spigot
+ MinecraftTimings.playerListTimer.stopTiming(); // Spigot
this.methodProfiler.c("tickables");
2018-08-26 18:11:49 +00:00
2016-04-30 01:23:40 +00:00
- SpigotTimings.tickablesTimer.startTiming(); // Spigot
+ MinecraftTimings.tickablesTimer.startTiming(); // Spigot
2018-08-26 18:11:49 +00:00
for (int j = 0; j < this.k.size(); ++j) {
((ITickable) this.k.get(j)).Y_();
2016-04-30 01:23:40 +00:00
}
- SpigotTimings.tickablesTimer.stopTiming(); // Spigot
+ MinecraftTimings.tickablesTimer.stopTiming(); // Spigot
2018-07-15 01:53:17 +00:00
this.methodProfiler.e();
2016-04-30 01:23:40 +00:00
}
2016-06-05 04:10:50 +00:00
diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java
2018-08-04 21:03:53 +00:00
index ac6d8cc6e6..d975c2ccf1 100644
2016-06-05 04:10:50 +00:00
--- a/src/main/java/net/minecraft/server/PlayerChunkMap.java
+++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java
@@ -1,5 +1,6 @@
package net.minecraft.server;
+import co.aikar.timings.Timing;
import com.google.common.collect.AbstractIterator;
import com.google.common.collect.ComparisonChain;
2018-07-15 01:53:17 +00:00
import com.google.common.collect.Lists;
@@ -90,6 +91,7 @@ public class PlayerChunkMap {
2016-06-05 04:10:50 +00:00
PlayerChunk playerchunk;
if (i - this.k > 8000L) {
+ try (Timing ignored = world.timings.doChunkMapUpdate.startTiming()) { // Paper
this.k = i;
for (j = 0; j < this.i.size(); ++j) {
2018-07-15 01:53:17 +00:00
@@ -97,9 +99,11 @@ public class PlayerChunkMap {
2016-06-05 04:10:50 +00:00
playerchunk.d();
playerchunk.c();
}
+ } // Paper timing
}
if (!this.f.isEmpty()) {
+ try (Timing ignored = world.timings.doChunkMapToUpdate.startTiming()) { // Paper
Iterator iterator = this.f.iterator();
while (iterator.hasNext()) {
2018-07-15 01:53:17 +00:00
@@ -108,25 +112,31 @@ public class PlayerChunkMap {
2016-06-05 04:10:50 +00:00
}
this.f.clear();
+ } // Paper timing
}
if (this.l && i % 4L == 0L) {
this.l = false;
+ try (Timing ignored = world.timings.doChunkMapSortMissing.startTiming()) { // Paper
2018-07-15 01:53:17 +00:00
// CraftBukkit start
Collections.sort(this.h, (playerchunkx, playerchunk1x) -> {
return ComparisonChain.start().compare(playerchunkx.g(), playerchunk1x.g()).result();
2016-06-05 04:10:50 +00:00
});
+ } // Paper timing
}
if (this.m && i % 4L == 2L) {
this.m = false;
+ try (Timing ignored = world.timings.doChunkMapSortSendToPlayers.startTiming()) { // Paper
2018-07-15 01:53:17 +00:00
Collections.sort(this.g, (playerchunkx, playerchunk1x) -> {
return ComparisonChain.start().compare(playerchunkx.g(), playerchunk1x.g()).result();
2016-06-05 04:10:50 +00:00
});
+ } // Paper timing
2018-07-15 01:53:17 +00:00
// CraftBukkit end
2016-06-05 04:10:50 +00:00
}
if (!this.h.isEmpty()) {
+ try (Timing ignored = world.timings.doChunkMapPlayersNeedingChunks.startTiming()) { // Paper
2017-01-31 04:33:54 +00:00
// Spigot start
org.spigotmc.SlackActivityAccountant activityAccountant = this.world.getMinecraftServer().slackActivityAccountant;
activityAccountant.startActivity(0.5);
2018-07-15 01:53:17 +00:00
@@ -158,10 +168,12 @@ public class PlayerChunkMap {
2016-06-05 04:10:50 +00:00
}
2017-01-31 04:33:54 +00:00
activityAccountant.endActivity(); // Spigot
2016-06-05 04:10:50 +00:00
+ } // Paper timing
}
if (!this.g.isEmpty()) {
j = 81;
+ try (Timing ignored = world.timings.doChunkMapPendingSendToPlayers.startTiming()) { // Paper
Iterator iterator2 = this.g.iterator();
while (iterator2.hasNext()) {
2018-07-15 01:53:17 +00:00
@@ -175,14 +187,17 @@ public class PlayerChunkMap {
2016-06-05 04:10:50 +00:00
}
}
}
+ } // Paper timing
}
if (this.managedPlayers.isEmpty()) {
+ try (Timing ignored = world.timings.doChunkMapUnloadChunks.startTiming()) { // Paper
WorldProvider worldprovider = this.world.worldProvider;
2018-07-15 01:53:17 +00:00
if (!worldprovider.p()) {
2016-06-05 04:10:50 +00:00
this.world.getChunkProviderServer().b();
}
+ } // Paper timing
}
}
2016-01-09 06:32:38 +00:00
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
2018-08-26 18:11:49 +00:00
index 7dee734a70..37284fae4d 100644
2016-01-09 06:32:38 +00:00
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
2018-08-26 18:11:49 +00:00
@@ -59,6 +59,7 @@ import org.bukkit.inventory.CraftingInventory;
2016-03-04 21:20:13 +00:00
import org.bukkit.inventory.EquipmentSlot;
2016-01-09 06:32:38 +00:00
import org.bukkit.inventory.InventoryView;
import org.bukkit.util.NumberConversions;
2016-04-30 01:23:40 +00:00
+import co.aikar.timings.MinecraftTimings; // Paper
2016-01-09 06:32:38 +00:00
// CraftBukkit end
2016-02-29 23:09:49 +00:00
public class PlayerConnection implements PacketListenerPlayIn, ITickable {
2018-08-26 18:11:49 +00:00
@@ -1625,7 +1626,7 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
2016-01-09 06:32:38 +00:00
// CraftBukkit end
2017-05-14 18:05:01 +00:00
private void handleCommand(String s) {
2016-01-09 06:32:38 +00:00
- org.bukkit.craftbukkit.SpigotTimings.playerCommandTimer.startTiming(); // Spigot
2017-05-14 18:05:01 +00:00
+ MinecraftTimings.playerCommandTimer.startTiming(); // Paper
2018-07-15 01:53:17 +00:00
// CraftBukkit start - whole method
2016-01-09 06:32:38 +00:00
if ( org.spigotmc.SpigotConfig.logCommands ) // Spigot
2016-02-29 23:09:49 +00:00
this.LOGGER.info(this.player.getName() + " issued server command: " + s);
2018-08-26 18:11:49 +00:00
@@ -1636,7 +1637,7 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
2016-01-09 06:32:38 +00:00
this.server.getPluginManager().callEvent(event);
if (event.isCancelled()) {
- org.bukkit.craftbukkit.SpigotTimings.playerCommandTimer.stopTiming(); // Spigot
2016-04-30 01:23:40 +00:00
+ MinecraftTimings.playerCommandTimer.stopTiming(); // Paper
2016-01-09 06:32:38 +00:00
return;
}
2018-08-26 18:11:49 +00:00
@@ -1649,7 +1650,7 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
2016-01-09 06:32:38 +00:00
java.util.logging.Logger.getLogger(PlayerConnection.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
2018-07-15 01:53:17 +00:00
return;
} finally {
2016-01-09 06:32:38 +00:00
- org.bukkit.craftbukkit.SpigotTimings.playerCommandTimer.stopTiming(); // Spigot
2016-04-30 01:23:40 +00:00
+ MinecraftTimings.playerCommandTimer.stopTiming(); // Paper
2016-01-09 06:32:38 +00:00
}
2018-07-15 01:53:17 +00:00
// this.minecraftServer.getCommandDispatcher().a(this.player.getCommandListener(), s);
2016-01-09 06:32:38 +00:00
// CraftBukkit end
2017-02-05 05:13:16 +00:00
diff --git a/src/main/java/net/minecraft/server/PlayerConnectionUtils.java b/src/main/java/net/minecraft/server/PlayerConnectionUtils.java
2018-08-04 21:03:53 +00:00
index 889b32287e..69da194f52 100644
2017-02-05 05:13:16 +00:00
--- a/src/main/java/net/minecraft/server/PlayerConnectionUtils.java
+++ b/src/main/java/net/minecraft/server/PlayerConnectionUtils.java
2018-07-15 01:53:17 +00:00
@@ -1,11 +1,17 @@
2017-02-05 05:13:16 +00:00
package net.minecraft.server;
+import co.aikar.timings.MinecraftTimings; // Paper
+import co.aikar.timings.Timing; // Paper
+
public class PlayerConnectionUtils {
2018-07-15 01:53:17 +00:00
- public static <T extends PacketListener> void ensureMainThread(Packet<T> packet, T t0, IAsyncTaskHandler iasynctaskhandler) throws CancelledPacketHandleException {
+ public static <T extends PacketListener> void ensureMainThread(Packet<T> packet, T packetlistener, IAsyncTaskHandler iasynctaskhandler) throws CancelledPacketHandleException { // Paper fix name of param
2017-02-05 05:13:16 +00:00
if (!iasynctaskhandler.isMainThread()) {
2018-07-15 01:53:17 +00:00
+ Timing timing = MinecraftTimings.getPacketTiming(packet); // Paper
iasynctaskhandler.postToMainThread(() -> {
+ try (Timing ignored = timing.startTiming()) { // Paper
packet.a(packetlistener);
+ }
2017-02-05 05:13:16 +00:00
});
throw CancelledPacketHandleException.INSTANCE;
}
2016-10-21 20:42:49 +00:00
diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java
2018-08-26 18:11:49 +00:00
index ead9697e65..26df2ff32f 100644
2016-10-21 20:42:49 +00: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;
2018-08-26 18:11:49 +00:00
@@ -1173,10 +1174,11 @@ public abstract class PlayerList {
2016-10-21 20:42:49 +00: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 01:53:17 +00:00
public WhiteList getWhitelist() {
diff --git a/src/main/java/net/minecraft/server/TickListServer.java b/src/main/java/net/minecraft/server/TickListServer.java
2018-08-04 21:03:53 +00:00
index a07895935e..ee5c2421bb 100644
2018-07-15 01:53:17 +00:00
--- a/src/main/java/net/minecraft/server/TickListServer.java
+++ b/src/main/java/net/minecraft/server/TickListServer.java
@@ -24,13 +24,19 @@ public class TickListServer<T> implements TickList<T> {
private final List<NextTickListEntry<T>> g = Lists.newArrayList();
private final Consumer<NextTickListEntry<T>> h;
- 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;
this.f = worldserver;
this.h = consumer;
+ // Paper start
+ 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 00:36:26 +00:00
2018-07-15 01:53:17 +00:00
public void a() {
int i = this.nextTickList.size();
@@ -49,7 +55,7 @@ public class TickListServer<T> implements TickList<T> {
}
2016-08-28 00:36:26 +00:00
2018-07-15 01:53:17 +00:00
this.f.methodProfiler.a("cleaning");
-
+ timingCleanup.startTiming(); // Paper
NextTickListEntry<T> nextticklistentry; // CraftBukkit - decompile error
2016-08-28 00:36:26 +00:00
2018-07-15 01:53:17 +00:00
for (int j = 0; j < i; ++j) {
@@ -62,9 +68,11 @@ public class TickListServer<T> implements TickList<T> {
// this.nextTickListHash.remove(nextticklistentry); // CraftBukkit - use nextTickList
this.g.add(nextticklistentry);
}
+ timingCleanup.stopTiming(); // Paper
2016-08-28 00:36:26 +00:00
2018-07-15 01:53:17 +00:00
this.f.methodProfiler.e();
this.f.methodProfiler.a("ticking");
+ timingTicking.startTiming(); // Paper
Iterator iterator = this.g.iterator();
2016-08-28 00:36:26 +00:00
2018-07-15 01:53:17 +00:00
while (iterator.hasNext()) {
@@ -89,6 +97,7 @@ public class TickListServer<T> implements TickList<T> {
2016-08-28 00:36:26 +00:00
2018-07-15 01:53:17 +00:00
this.f.methodProfiler.e();
this.g.clear();
+ timingTicking.stopTiming(); // Paper
2016-08-28 00:36:26 +00:00
}
}
2018-07-15 01:53:17 +00:00
2016-01-09 06:32:38 +00:00
diff --git a/src/main/java/net/minecraft/server/TileEntity.java b/src/main/java/net/minecraft/server/TileEntity.java
2018-08-26 18:11:49 +00:00
index c69209497b..68ac014aab 100644
2016-01-09 06:32:38 +00:00
--- a/src/main/java/net/minecraft/server/TileEntity.java
+++ b/src/main/java/net/minecraft/server/TileEntity.java
2016-11-17 02:23:38 +00:00
@@ -4,12 +4,13 @@ import javax.annotation.Nullable;
2016-01-09 06:32:38 +00:00
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
-import org.spigotmc.CustomTimingsHandler; // Spigot
2016-04-30 01:23:40 +00:00
+import co.aikar.timings.MinecraftTimings; // Paper
2016-02-29 23:09:49 +00:00
+import co.aikar.timings.Timing; // Paper
2016-01-09 06:32:38 +00:00
import org.bukkit.inventory.InventoryHolder; // CraftBukkit
2018-07-27 04:44:53 +00:00
public abstract class TileEntity implements KeyedObject { // Paper
2016-01-09 06:32:38 +00:00
- public CustomTimingsHandler tickTimer = org.bukkit.craftbukkit.SpigotTimings.getTileEntityTimings(this); // Spigot
2016-04-30 01:23:40 +00:00
+ public Timing tickTimer = MinecraftTimings.getTileEntityTimings(this); // Paper
2016-01-09 06:32:38 +00:00
private static final Logger a = LogManager.getLogger();
2018-07-15 01:53:17 +00:00
private final TileEntityTypes<?> e; public TileEntityTypes getTileEntityType() { return e; } // Paper - OBFHELPER
2016-11-17 02:23:38 +00:00
protected World world;
2016-01-09 06:32:38 +00:00
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
2018-08-26 18:11:49 +00:00
index 028678379a..c3c435cab9 100644
2016-01-09 06:32:38 +00:00
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
2018-07-15 01:53:17 +00:00
@@ -1,5 +1,6 @@
package net.minecraft.server;
+import co.aikar.timings.Timings;
import com.google.common.base.MoreObjects;
import com.google.common.collect.Lists;
2018-08-26 18:11:49 +00:00
import it.unimi.dsi.fastutil.longs.LongSet;
@@ -26,13 +27,13 @@ import com.google.common.collect.Maps;
2016-02-29 23:09:49 +00:00
import java.util.Map;
import org.bukkit.Bukkit;
2016-01-09 06:32:38 +00:00
import org.bukkit.block.BlockState;
2016-02-29 23:09:49 +00:00
-import org.bukkit.craftbukkit.SpigotTimings; // Spigot
2016-01-09 06:32:38 +00:00
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.CraftWorld;
2018-07-15 01:53:17 +00:00
import org.bukkit.craftbukkit.block.CraftBlockState;
import org.bukkit.craftbukkit.block.data.CraftBlockData;
2016-01-09 06:32:38 +00:00
import org.bukkit.craftbukkit.event.CraftEventFactory;
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
2016-02-29 23:09:49 +00:00
+import org.bukkit.craftbukkit.util.LongHashSet; // Paper
2016-01-09 06:32:38 +00:00
import org.bukkit.event.block.BlockCanBuildEvent;
import org.bukkit.event.block.BlockPhysicsEvent;
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
2018-08-26 18:11:49 +00:00
@@ -136,7 +137,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
2016-01-09 06:32:38 +00:00
2016-02-29 23:09:49 +00:00
public final com.destroystokyo.paper.PaperWorldConfig paperConfig; // Paper
2016-01-09 06:32:38 +00:00
- public final SpigotTimings.WorldTimingsHandler timings; // Spigot
2016-02-29 23:09:49 +00:00
+ public final co.aikar.timings.WorldTimingsHandler timings; // Paper
private boolean guardEntityList; // Spigot
public static boolean haveWeSilencedAPhysicsCrash;
public static String blockLocation;
2018-08-26 18:11:49 +00:00
@@ -205,7 +206,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
2016-03-25 04:59:37 +00:00
});
2016-03-03 09:46:26 +00:00
this.getServer().addWorld(this.world);
// CraftBukkit end
2016-02-29 23:09:49 +00: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
this.entityLimiter = new org.spigotmc.TickLimiter(spigotConfig.entityMaxTickTime);
2016-01-09 06:32:38 +00:00
this.tileLimiter = new org.spigotmc.TickLimiter(spigotConfig.tileMaxTickTime);
}
2018-08-26 18:11:49 +00:00
@@ -1123,6 +1124,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
2016-01-09 06:32:38 +00:00
}
this.methodProfiler.c("remove");
2016-02-29 23:09:49 +00:00
+ timings.entityRemoval.startTiming(); // Paper
2018-07-15 01:53:17 +00:00
this.entityList.removeAll(this.g);
2016-01-09 06:32:38 +00:00
int j;
2018-08-26 18:11:49 +00:00
@@ -1143,6 +1145,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
2016-01-09 06:32:38 +00:00
2018-07-15 01:53:17 +00:00
this.g.clear();
this.p_();
2016-02-29 23:09:49 +00:00
+ timings.entityRemoval.stopTiming(); // Paper
2016-01-09 06:32:38 +00:00
this.methodProfiler.c("regular");
2016-02-29 23:09:49 +00:00
CrashReportSystemDetails crashreportsystemdetails1;
2018-08-26 18:11:49 +00:00
@@ -1152,6 +1155,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
2016-01-09 06:32:38 +00:00
timings.entityTick.startTiming(); // Spigot
guardEntityList = true; // Spigot
// CraftBukkit start - Use field for loop variable
2016-02-29 23:09:49 +00:00
+ co.aikar.timings.TimingHistory.entityTicks += this.entityList.size(); // Paper
2016-01-09 06:32:38 +00:00
int entitiesThisCycle = 0;
2016-03-25 04:59:37 +00:00
if (tickPosition < 0) tickPosition = 0;
for (entityLimiter.initTick();
2018-08-26 18:11:49 +00:00
@@ -1173,10 +1177,11 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
2016-01-09 06:32:38 +00:00
this.methodProfiler.a("tick");
2016-02-29 23:09:49 +00:00
if (!entity.dead && !(entity instanceof EntityPlayer)) {
2016-01-09 06:32:38 +00:00
try {
- SpigotTimings.tickEntityTimer.startTiming(); // Spigot
2016-02-29 23:09:49 +00:00
+ entity.tickTimer.startTiming(); // Paper
2018-07-15 01:53:17 +00:00
this.g(entity);
2016-01-09 06:32:38 +00:00
- SpigotTimings.tickEntityTimer.stopTiming(); // Spigot
2016-02-29 23:09:49 +00:00
+ entity.tickTimer.stopTiming(); // Paper
2016-01-09 06:32:38 +00:00
} catch (Throwable throwable1) {
+ entity.tickTimer.stopTiming();
2016-03-25 04:59:37 +00:00
crashreport1 = CrashReport.a(throwable1, "Ticking entity");
crashreportsystemdetails1 = crashreport1.a("Entity being ticked");
entity.appendEntityCrashDetails(crashreportsystemdetails1);
2018-08-26 18:11:49 +00:00
@@ -1301,6 +1306,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
2016-01-09 06:32:38 +00:00
}
timings.tileEntityPending.stopTiming(); // Spigot
2016-02-29 23:09:49 +00:00
+ co.aikar.timings.TimingHistory.tileEntityTicks += this.tileEntityListTick.size(); // Paper
2018-07-15 01:53:17 +00:00
this.methodProfiler.e();
this.methodProfiler.e();
2016-01-09 06:32:38 +00:00
}
2018-08-26 18:11:49 +00:00
@@ -1359,7 +1365,6 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
2017-05-21 04:41:39 +00:00
}
2018-04-22 14:40:36 +00:00
// CraftBukkit end
2017-05-21 04:41:39 +00:00
- entity.tickTimer.startTiming(); // Spigot
2018-07-15 01:53:17 +00:00
entity.N = entity.locX;
entity.O = entity.locY;
entity.P = entity.locZ;
2018-08-26 18:11:49 +00:00
@@ -1367,6 +1372,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
2017-05-21 04:41:39 +00:00
entity.lastPitch = entity.pitch;
2018-07-15 01:53:17 +00:00
if (flag && entity.inChunk) {
2017-05-21 04:41:39 +00:00
++entity.ticksLived;
+ ++co.aikar.timings.TimingHistory.activatedEntityTicks; // Paper
if (entity.isPassenger()) {
2018-07-15 01:53:17 +00:00
entity.aH();
2017-05-21 04:41:39 +00:00
} else {
2018-08-26 18:11:49 +00:00
@@ -1430,8 +1436,6 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
2016-01-09 06:32:38 +00:00
}
}
}
2017-05-21 04:41:39 +00:00
- entity.tickTimer.stopTiming(); // Spigot
-
2016-01-09 06:32:38 +00:00
}
2018-07-15 01:53:17 +00:00
public boolean a(@Nullable Entity entity, VoxelShape voxelshape) {
2016-01-09 06:32:38 +00:00
diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
2018-08-26 18:11:49 +00:00
index c276c259ae..badec349b7 100644
2016-01-09 06:32:38 +00:00
--- a/src/main/java/net/minecraft/server/WorldServer.java
+++ b/src/main/java/net/minecraft/server/WorldServer.java
2018-07-15 01:53:17 +00:00
@@ -1,5 +1,6 @@
package net.minecraft.server;
+import co.aikar.timings.Timings;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.util.concurrent.ListenableFuture;
2018-08-26 18:11:49 +00:00
@@ -71,7 +72,7 @@ public class WorldServer extends World implements IAsyncTaskHandler {
IRegistry<Block> iregistry1 = IRegistry.BLOCK; // CraftBukkit - decompile error
2018-07-15 01:53:17 +00:00
2018-08-26 18:11:49 +00:00
IRegistry.BLOCK.getClass();
- this.nextTickListBlock = new TickListServer<>(this, predicate, function, iregistry1::getOrDefault, this::b); // CraftBukkit - decompile error
+ this.nextTickListBlock = new TickListServer<>(this, predicate, function, iregistry1::getOrDefault, this::b, "Blocks"); // CraftBukkit - decompile error // Paper - Timings v2
Predicate<FluidType> predicate2 = (fluidtype) -> { // CraftBukkit - decompile error
2018-07-15 01:53:17 +00:00
return fluidtype == null || fluidtype == FluidTypes.a;
};
2018-08-26 18:11:49 +00:00
@@ -80,7 +81,7 @@ public class WorldServer extends World implements IAsyncTaskHandler {
function = iregistry::getKey;
IRegistry<FluidType> iregistry2 = IRegistry.FLUID; // CraftBukkit - decompile error
IRegistry.FLUID.getClass();
- this.nextTickListFluid = new TickListServer<>(this, predicate2, function, iregistry2::getOrDefault, this::a); // CraftBukkit - decompile error
+ this.nextTickListFluid = new TickListServer<>(this, predicate2, function, iregistry2::getOrDefault, this::a, "Fluids"); // CraftBukkit - decompile error // Paper - Timings v2
2018-07-15 01:53:17 +00:00
this.siegeManager = new VillageSiege(this);
this.d = new ObjectLinkedOpenHashSet();
this.server = minecraftserver;
@@ -297,13 +298,13 @@ public class WorldServer extends World implements IAsyncTaskHandler {
2016-01-09 06:32:38 +00:00
timings.doChunkUnload.stopTiming(); // Spigot
this.methodProfiler.c("tickPending");
- timings.doTickPending.startTiming(); // Spigot
2016-02-29 23:09:49 +00:00
+ timings.scheduledBlocks.startTiming(); // Paper
2018-08-26 18:11:49 +00:00
this.q();
2016-01-09 06:32:38 +00:00
- timings.doTickPending.stopTiming(); // Spigot
2016-02-29 23:09:49 +00:00
+ timings.scheduledBlocks.stopTiming(); // Paper
2016-01-09 06:32:38 +00:00
this.methodProfiler.c("tickBlocks");
- timings.doTickTiles.startTiming(); // Spigot
2016-02-29 23:09:49 +00:00
+ timings.chunkTicks.startTiming(); // Paper
2018-08-26 18:11:49 +00:00
this.n_();
2016-01-09 06:32:38 +00:00
- timings.doTickTiles.stopTiming(); // Spigot
2016-02-29 23:09:49 +00:00
+ timings.chunkTicks.stopTiming(); // Paper
2016-01-09 06:32:38 +00:00
this.methodProfiler.c("chunkMap");
timings.doChunkMap.startTiming(); // Spigot
2016-02-29 23:09:49 +00:00
this.manager.flush();
2018-07-15 01:53:17 +00:00
@@ -532,7 +533,7 @@ public class WorldServer extends World implements IAsyncTaskHandler {
2016-02-29 23:09:49 +00:00
}
2016-01-09 06:32:38 +00:00
}
2016-02-29 23:09:49 +00:00
- this.methodProfiler.c("tickBlocks");
+ timings.chunkTicksBlocks.startTiming(); // Paper
if (i > 0) {
2016-01-09 06:32:38 +00:00
ChunkSection[] achunksection = chunk.getSections();
2016-02-29 23:09:49 +00:00
int i1 = achunksection.length;
2018-07-15 01:53:17 +00:00
@@ -564,6 +565,7 @@ public class WorldServer extends World implements IAsyncTaskHandler {
2016-01-09 06:32:38 +00:00
}
}
}
2016-02-29 23:09:49 +00:00
+ timings.chunkTicksBlocks.stopTiming(); // Paper
2016-01-09 06:32:38 +00:00
}
2018-07-15 01:53:17 +00:00
this.methodProfiler.e();
@@ -869,6 +871,7 @@ public class WorldServer extends World implements IAsyncTaskHandler {
2016-10-21 20:42:49 +00:00
2018-08-26 18:11:49 +00:00
if (chunkproviderserver.d()) {
2016-10-21 20:42:49 +00:00
org.bukkit.Bukkit.getPluginManager().callEvent(new org.bukkit.event.world.WorldSaveEvent(getWorld())); // CraftBukkit
+ timings.worldSave.startTiming(); // Paper
if (iprogressupdate != null) {
2018-07-15 01:53:17 +00:00
iprogressupdate.a(new ChatMessage("menu.savingLevel", new Object[0]));
2016-10-21 20:42:49 +00:00
}
2018-07-15 01:53:17 +00:00
@@ -878,7 +881,9 @@ public class WorldServer extends World implements IAsyncTaskHandler {
iprogressupdate.c(new ChatMessage("menu.savingChunks", new Object[0]));
2016-10-21 20:42:49 +00:00
}
+ timings.worldSaveChunks.startTiming(); // Paper
chunkproviderserver.a(flag);
+ timings.worldSaveChunks.stopTiming(); // Paper
// CraftBukkit - ArrayList -> Collection
2018-08-26 18:11:49 +00:00
java.util.Collection arraylist = chunkproviderserver.a();
2016-10-21 20:42:49 +00:00
Iterator iterator = arraylist.iterator();
2018-07-15 01:53:17 +00:00
@@ -890,7 +895,7 @@ public class WorldServer extends World implements IAsyncTaskHandler {
2016-10-21 20:42:49 +00:00
chunkproviderserver.unload(chunk);
}
}
-
+ timings.worldSave.stopTiming(); // Paper
}
}
2018-07-15 01:53:17 +00:00
@@ -903,6 +908,7 @@ public class WorldServer extends World implements IAsyncTaskHandler {
2016-10-21 20:42:49 +00:00
}
protected void a() throws ExceptionWorldConflict {
+ timings.worldSaveLevel.startTiming(); // Paper
this.checkSession();
2018-08-26 18:11:49 +00:00
Iterator iterator = this.server.getWorlds().iterator();
@@ -932,6 +938,7 @@ public class WorldServer extends World implements IAsyncTaskHandler {
this.worldData.c(this.server.aP().c());
2016-10-21 20:42:49 +00:00
this.dataManager.saveWorldData(this.worldData, this.server.getPlayerList().t());
2018-08-26 18:11:49 +00:00
this.h().a();
2016-10-21 20:42:49 +00:00
+ timings.worldSaveLevel.stopTiming(); // Paper
}
// CraftBukkit start
2016-01-09 06:32:38 +00:00
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
2018-08-26 18:11:49 +00:00
index 46a9ff9482..9ba50a2daa 100644
2016-01-09 06:32:38 +00:00
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
2018-08-26 18:11:49 +00:00
@@ -1867,12 +1867,31 @@ public final class CraftServer implements Server {
2016-02-29 23:09:49 +00:00
private final Spigot spigot = new Spigot()
{
2016-01-09 06:32:38 +00:00
+ @Deprecated
@Override
public YamlConfiguration getConfig()
{
2018-03-10 13:07:40 +00:00
return org.spigotmc.SpigotConfig.config;
2016-02-29 23:09:49 +00:00
}
2018-03-10 13:07:40 +00:00
+ @Override
2016-01-09 06:32:38 +00:00
+ public YamlConfiguration getBukkitConfig()
+ {
+ return configuration;
+ }
+
+ @Override
+ public YamlConfiguration getSpigotConfig()
+ {
2016-02-29 23:09:49 +00:00
+ return org.spigotmc.SpigotConfig.config;
+ }
+
+ @Override
+ public YamlConfiguration getPaperConfig()
2016-01-09 06:32:38 +00:00
+ {
2016-02-29 23:09:49 +00:00
+ return com.destroystokyo.paper.PaperConfig.config;
2016-01-09 06:32:38 +00:00
+ }
+
2018-03-10 13:07:40 +00:00
@Override
2016-01-09 06:32:38 +00: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
2018-08-04 21:03:53 +00:00
index 4c8ab2bc97..0000000000
2016-01-09 06:32:38 +00:00
--- a/src/main/java/org/bukkit/craftbukkit/SpigotTimings.java
+++ /dev/null
2017-05-14 18:05:01 +00:00
@@ -1,174 +0,0 @@
2016-01-09 06:32:38 +00:00
-package org.bukkit.craftbukkit;
-
-import com.google.common.collect.Maps;
-import net.minecraft.server.*;
-import org.bukkit.plugin.java.JavaPluginLoader;
-import org.spigotmc.CustomTimingsHandler;
-import org.bukkit.scheduler.BukkitTask;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.bukkit.craftbukkit.scheduler.CraftTask;
-
-public class SpigotTimings {
-
- public static final CustomTimingsHandler serverTickTimer = new CustomTimingsHandler("** Full Server Tick");
- public static final CustomTimingsHandler playerListTimer = new CustomTimingsHandler("Player List");
2017-05-14 18:05:01 +00:00
- public static final CustomTimingsHandler commandFunctionsTimer = new CustomTimingsHandler("Command Functions");
2016-01-09 06:32:38 +00:00
- public static final CustomTimingsHandler connectionTimer = new CustomTimingsHandler("Connection Handler");
- public static final CustomTimingsHandler tickablesTimer = new CustomTimingsHandler("Tickables");
- public static final CustomTimingsHandler schedulerTimer = new CustomTimingsHandler("Scheduler");
- public static final CustomTimingsHandler chunkIOTickTimer = new CustomTimingsHandler("ChunkIOTick");
- public static final CustomTimingsHandler timeUpdateTimer = new CustomTimingsHandler("Time Update");
- public static final CustomTimingsHandler serverCommandTimer = new CustomTimingsHandler("Server Command");
- public static final CustomTimingsHandler worldSaveTimer = new CustomTimingsHandler("World Save");
-
- public static final CustomTimingsHandler entityMoveTimer = new CustomTimingsHandler("** entityMove");
- public static final CustomTimingsHandler tickEntityTimer = new CustomTimingsHandler("** tickEntity");
- public static final CustomTimingsHandler activatedEntityTimer = new CustomTimingsHandler("** activatedTickEntity");
- public static final CustomTimingsHandler tickTileEntityTimer = new CustomTimingsHandler("** tickTileEntity");
-
- public static final CustomTimingsHandler timerEntityBaseTick = new CustomTimingsHandler("** livingEntityBaseTick");
- public static final CustomTimingsHandler timerEntityAI = new CustomTimingsHandler("** livingEntityAI");
- public static final CustomTimingsHandler timerEntityAICollision = new CustomTimingsHandler("** livingEntityAICollision");
- public static final CustomTimingsHandler timerEntityAIMove = new CustomTimingsHandler("** livingEntityAIMove");
- public static final CustomTimingsHandler timerEntityTickRest = new CustomTimingsHandler("** livingEntityTickRest");
-
- public static final CustomTimingsHandler processQueueTimer = new CustomTimingsHandler("processQueue");
- public static final CustomTimingsHandler schedulerSyncTimer = new CustomTimingsHandler("** Scheduler - Sync Tasks", JavaPluginLoader.pluginParentTimer);
-
- public static final CustomTimingsHandler playerCommandTimer = new CustomTimingsHandler("** playerCommand");
-
- public static final 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 if (ctask.timingName != null) {
- plugin = "CraftScheduler";
- } else {
- plugin = "Unknown";
- }
- String taskname = ctask.getTaskName();
-
- String name = "Task: " + plugin + " Runnable: " + taskname;
- if (period > 0) {
- name += "(interval:" + period +")";
- } else {
- name += "(Single)";
- }
- CustomTimingsHandler result = pluginTaskTimingMap.get(name);
- if (result == null) {
- result = new CustomTimingsHandler(name, SpigotTimings.schedulerSyncTimer);
- pluginTaskTimingMap.put(name, result);
- }
- return result;
- }
-
- /**
- * Get a named timer for the specified entity type to track type specific timings.
- * @param entity
- * @return
- */
- public static CustomTimingsHandler getEntityTimings(Entity entity) {
2017-10-29 15:19:21 +00:00
- String entityType = entity.getClass().getName();
2016-01-09 06:32:38 +00:00
- CustomTimingsHandler result = entityTypeTimingMap.get(entityType);
- if (result == null) {
2017-10-29 15:19:21 +00:00
- result = new CustomTimingsHandler("** tickEntity - " + entity.getClass().getSimpleName(), activatedEntityTimer);
2016-01-09 06:32:38 +00: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 15:19:21 +00:00
- String entityType = entity.getClass().getName();
2016-01-09 06:32:38 +00:00
- CustomTimingsHandler result = tileEntityTypeTimingMap.get(entityType);
- if (result == null) {
2017-10-29 15:19:21 +00:00
- result = new CustomTimingsHandler("** tickTileEntity - " + entity.getClass().getSimpleName(), tickTileEntityTimer);
2016-01-09 06:32:38 +00: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 doChunkGC;
- public final CustomTimingsHandler doSounds;
- public final CustomTimingsHandler entityTick;
- public final CustomTimingsHandler tileEntityTick;
- public final CustomTimingsHandler tileEntityPending;
- public final CustomTimingsHandler tracker;
- public final CustomTimingsHandler doTick;
- public final CustomTimingsHandler tickEntities;
-
- public final CustomTimingsHandler syncChunkLoadTimer;
- public final CustomTimingsHandler syncChunkLoadDataTimer;
- public final CustomTimingsHandler syncChunkLoadStructuresTimer;
- public final CustomTimingsHandler syncChunkLoadEntitiesTimer;
- public final CustomTimingsHandler syncChunkLoadTileEntitiesTimer;
- public final CustomTimingsHandler syncChunkLoadTileTicksTimer;
- public final CustomTimingsHandler syncChunkLoadPostTimer;
-
- public WorldTimingsHandler(World server) {
- String name = server.worldData.getName() +" - ";
-
- mobSpawn = new CustomTimingsHandler("** " + name + "mobSpawn");
- doChunkUnload = new CustomTimingsHandler("** " + name + "doChunkUnload");
- doTickPending = new CustomTimingsHandler("** " + name + "doTickPending");
- doTickTiles = new CustomTimingsHandler("** " + name + "doTickTiles");
- doVillages = new CustomTimingsHandler("** " + name + "doVillages");
- doChunkMap = new CustomTimingsHandler("** " + name + "doChunkMap");
- doSounds = new CustomTimingsHandler("** " + name + "doSounds");
- doChunkGC = new CustomTimingsHandler("** " + name + "doChunkGC");
- doPortalForcer = new CustomTimingsHandler("** " + name + "doPortalForcer");
- entityTick = new CustomTimingsHandler("** " + name + "entityTick");
- tileEntityTick = new CustomTimingsHandler("** " + name + "tileEntityTick");
- tileEntityPending = new CustomTimingsHandler("** " + name + "tileEntityPending");
-
- syncChunkLoadTimer = new CustomTimingsHandler("** " + name + "syncChunkLoad");
- syncChunkLoadDataTimer = new CustomTimingsHandler("** " + name + "syncChunkLoad - Data");
- syncChunkLoadStructuresTimer = new CustomTimingsHandler("** " + name + "chunkLoad - Structures");
- syncChunkLoadEntitiesTimer = new CustomTimingsHandler("** " + name + "chunkLoad - Entities");
- syncChunkLoadTileEntitiesTimer = new CustomTimingsHandler("** " + name + "chunkLoad - TileEntities");
- syncChunkLoadTileTicksTimer = new CustomTimingsHandler("** " + name + "chunkLoad - TileTicks");
- syncChunkLoadPostTimer = new CustomTimingsHandler("** " + name + "chunkLoad - Post");
-
-
- tracker = new CustomTimingsHandler(name + "tracker");
- doTick = new CustomTimingsHandler(name + "doTick");
- tickEntities = new CustomTimingsHandler(name + "tickEntities");
- }
- }
-}
2016-08-28 00:36:26 +00:00
diff --git a/src/main/java/org/bukkit/craftbukkit/chunkio/ChunkIOProvider.java b/src/main/java/org/bukkit/craftbukkit/chunkio/ChunkIOProvider.java
2018-08-04 21:03:53 +00:00
index 413dd35f06..52a8c48fa4 100644
2016-08-28 00:36:26 +00:00
--- a/src/main/java/org/bukkit/craftbukkit/chunkio/ChunkIOProvider.java
+++ b/src/main/java/org/bukkit/craftbukkit/chunkio/ChunkIOProvider.java
@@ -1,6 +1,8 @@
package org.bukkit.craftbukkit.chunkio;
import java.io.IOException;
+
+import co.aikar.timings.Timing;
import net.minecraft.server.Chunk;
import net.minecraft.server.ChunkCoordIntPair;
import net.minecraft.server.ChunkRegionLoader;
@@ -16,7 +18,7 @@ class ChunkIOProvider implements AsynchronousExecutor.CallBackProvider<QueuedChu
// async stuff
public Chunk callStage1(QueuedChunk queuedChunk) throws RuntimeException {
- try {
+ try (Timing ignored = queuedChunk.provider.world.timings.chunkIOStage1.startTimingIfSync()) { // Paper
ChunkRegionLoader loader = queuedChunk.loader;
2018-07-15 01:53:17 +00:00
Object[] data = loader.loadChunk(queuedChunk.world, queuedChunk.x, queuedChunk.z, (chunk) -> {});
2016-08-28 00:36:26 +00:00
2018-07-15 01:53:17 +00:00
@@ -38,11 +40,13 @@ class ChunkIOProvider implements AsynchronousExecutor.CallBackProvider<QueuedChu
// queuedChunk.provider.originalGetChunkAt(queuedChunk.x, queuedChunk.z);
2016-08-28 00:36:26 +00:00
return;
}
+ try (Timing ignored = queuedChunk.provider.world.timings.chunkIOStage2.startTimingIfSync()) { // Paper
2018-07-15 01:53:17 +00:00
queuedChunk.loader.loadEntities(queuedChunk.compound.getCompound("Level"), chunk);
2016-08-28 00:36:26 +00:00
chunk.setLastSaved(queuedChunk.provider.world.getTime());
2018-07-15 01:53:17 +00:00
queuedChunk.provider.chunks.put(ChunkCoordIntPair.a(queuedChunk.x, queuedChunk.z), chunk);
2016-08-28 00:36:26 +00:00
chunk.addEntities();
+ } // Paper
}
public void callStage3(QueuedChunk queuedChunk, Chunk chunk, Runnable runnable) throws RuntimeException {
2016-01-09 06:32:38 +00:00
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
2018-08-26 18:11:49 +00:00
index 9f78f2c4ae..b8bdcb6b74 100644
2016-01-09 06:32:38 +00:00
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
2018-08-12 06:08:09 +00:00
@@ -1715,6 +1715,12 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
2016-02-29 23:09:49 +00:00
packet.components = components;
getHandle().playerConnection.sendPacket(packet);
2016-01-09 06:32:38 +00:00
}
+
+ @Override
+ public int getPing()
+ {
+ return getHandle().ping;
+ }
};
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
2018-08-04 21:03:53 +00:00
index f11bd7545f..93b9134d6e 100644
2016-01-09 06:32:38 +00:00
--- a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java
+++ b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java
2017-02-05 05:13:16 +00:00
@@ -14,6 +14,7 @@ import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
import java.util.logging.Level;
+import co.aikar.timings.MinecraftTimings; // Paper
import org.apache.commons.lang.Validate;
import org.bukkit.plugin.IllegalPluginAccessException;
import org.bukkit.plugin.Plugin;
2018-06-21 03:29:33 +00:00
@@ -193,7 +194,7 @@ public class CraftScheduler implements BukkitScheduler {
2016-01-09 06:32:38 +00:00
}
}
return false;
- }});
2016-04-30 01:23:40 +00:00
+ }}){{this.timings=co.aikar.timings.MinecraftTimings.getCancelTasksTimer();}}; // Paper
2018-03-31 09:34:25 +00:00
handle(task, 0L);
2016-01-09 06:32:38 +00:00
for (CraftTask taskPending = head.getNext(); taskPending != null; taskPending = taskPending.getNext()) {
if (taskPending == task) {
2018-06-21 03:29:33 +00:00
@@ -226,7 +227,7 @@ public class CraftScheduler implements BukkitScheduler {
2016-01-09 06:32:38 +00:00
}
}
}
- });
2016-04-30 01:23:40 +00:00
+ }){{this.timings=co.aikar.timings.MinecraftTimings.getCancelTasksTimer(plugin);}}; // Paper
2018-03-31 09:34:25 +00:00
handle(task, 0L);
2016-01-09 06:32:38 +00:00
for (CraftTask taskPending = head.getNext(); taskPending != null; taskPending = taskPending.getNext()) {
if (taskPending == task) {
2018-06-21 03:29:33 +00:00
@@ -258,7 +259,7 @@ public class CraftScheduler implements BukkitScheduler {
2016-01-09 06:32:38 +00:00
CraftScheduler.this.pending.clear();
CraftScheduler.this.temp.clear();
}
- });
2016-04-30 01:23:40 +00:00
+ }){{this.timings=co.aikar.timings.MinecraftTimings.getCancelTasksTimer();}}; // Paper
2018-03-31 09:34:25 +00:00
handle(task, 0L);
2016-01-09 06:32:38 +00:00
for (CraftTask taskPending = head.getNext(); taskPending != null; taskPending = taskPending.getNext()) {
if (taskPending == task) {
2018-06-21 03:29:33 +00:00
@@ -357,9 +358,7 @@ public class CraftScheduler implements BukkitScheduler {
2016-01-09 06:32:38 +00:00
if (task.isSync()) {
2018-06-21 03:29:33 +00:00
currentTask = task;
2016-01-09 06:32:38 +00:00
try {
- task.timings.startTiming(); // Spigot
task.run();
- task.timings.stopTiming(); // Spigot
} catch (final Throwable throwable) {
task.getOwner().getLogger().log(
Level.WARNING,
2018-06-21 03:29:33 +00:00
@@ -386,8 +385,10 @@ public class CraftScheduler implements BukkitScheduler {
2017-02-05 05:13:16 +00:00
runners.remove(task.getTaskId());
}
}
+ MinecraftTimings.bukkitSchedulerFinishTimer.startTiming();
pending.addAll(temp);
temp.clear();
+ MinecraftTimings.bukkitSchedulerFinishTimer.stopTiming();
debugHead = debugHead.getNextHead(currentTick);
}
2018-06-21 03:29:33 +00:00
@@ -419,6 +420,7 @@ public class CraftScheduler implements BukkitScheduler {
2017-02-05 05:13:16 +00:00
}
private void parsePending() {
+ MinecraftTimings.bukkitSchedulerPendingTimer.startTiming();
CraftTask head = this.head;
CraftTask task = head.getNext();
CraftTask lastTask = head;
2018-06-21 03:29:33 +00:00
@@ -437,6 +439,7 @@ public class CraftScheduler implements BukkitScheduler {
2017-02-05 05:13:16 +00:00
task.setNext(null);
}
this.head = lastTask;
+ MinecraftTimings.bukkitSchedulerPendingTimer.stopTiming();
}
private boolean isReady(final int currentTick) {
2016-01-09 06:32:38 +00:00
diff --git a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftTask.java b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftTask.java
2018-08-04 21:03:53 +00:00
index 7e7ce9a81b..46029ce246 100644
2016-01-09 06:32:38 +00:00
--- a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftTask.java
+++ b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftTask.java
@@ -1,8 +1,8 @@
package org.bukkit.craftbukkit.scheduler;
import org.bukkit.Bukkit;
-import org.bukkit.craftbukkit.SpigotTimings; // Spigot
-import org.spigotmc.CustomTimingsHandler; // Spigot
2016-04-30 01:23:40 +00:00
+import co.aikar.timings.MinecraftTimings; // Paper
2016-02-29 23:09:49 +00:00
+import co.aikar.timings.Timing; // Paper
2016-01-09 06:32:38 +00:00
import org.bukkit.plugin.Plugin;
import org.bukkit.scheduler.BukkitTask;
2018-03-31 09:34:25 +00:00
@@ -25,11 +25,11 @@ public class CraftTask implements BukkitTask, Runnable { // Spigot
2016-01-09 06:32:38 +00:00
*/
private volatile long period;
private long nextRun;
- private final Runnable task;
2016-02-29 23:09:49 +00:00
+ public final Runnable task; // Paper
+ public Timing timings; // Paper
2016-01-09 06:32:38 +00:00
private final Plugin plugin;
private final int id;
- final CustomTimingsHandler timings; // Spigot
CraftTask() {
2018-03-31 09:34:25 +00:00
this(null, null, CraftTask.NO_REPEATING, CraftTask.NO_REPEATING);
2016-01-09 06:32:38 +00:00
}
2018-03-31 09:34:25 +00:00
@@ -38,26 +38,12 @@ public class CraftTask implements BukkitTask, Runnable { // Spigot
this(null, task, CraftTask.NO_REPEATING, CraftTask.NO_REPEATING);
2016-01-09 06:32:38 +00:00
}
2016-02-29 23:09:49 +00:00
- // Spigot start
2016-01-09 06:32:38 +00:00
- public String timingName = null;
- CraftTask(String timingName) {
- this(timingName, null, null, -1, -1);
- }
- CraftTask(String timingName, final Runnable task) {
- this(timingName, null, task, -1, -1);
- }
- CraftTask(String timingName, final Plugin plugin, final Runnable task, final int id, final long period) {
2016-02-29 23:09:49 +00:00
+ CraftTask(final Plugin plugin, final Runnable task, final int id, final long period) { // Paper
2016-01-09 06:32:38 +00:00
this.plugin = plugin;
this.task = task;
this.id = id;
this.period = period;
- this.timingName = timingName == null && task == null ? "Unknown" : timingName;
- timings = this.isSync() ? SpigotTimings.getPluginTaskTimings(this, period) : null;
- }
-
- CraftTask(final Plugin plugin, final Runnable task, final int id, final long period) {
- this(null, plugin, task, id, period);
- // Spigot end
2016-04-30 01:23:40 +00:00
+ timings = task != null ? MinecraftTimings.getPluginTaskTimings(this, period) : null; // Paper
2016-01-09 06:32:38 +00:00
}
public final int getTaskId() {
2018-03-31 09:34:25 +00:00
@@ -73,7 +59,9 @@ public class CraftTask implements BukkitTask, Runnable { // Spigot
2016-01-09 06:32:38 +00:00
}
public void run() {
2016-02-29 23:09:49 +00:00
+ if (timings != null && isSync()) timings.startTiming(); // Paper
2016-01-09 06:32:38 +00:00
task.run();
2016-02-29 23:09:49 +00:00
+ if (timings != null && isSync()) timings.stopTiming(); // Paper
2016-01-09 06:32:38 +00:00
}
long getPeriod() {
2018-03-31 09:34:25 +00:00
@@ -122,13 +110,4 @@ public class CraftTask implements BukkitTask, Runnable { // Spigot
setPeriod(CraftTask.CANCEL);
2016-01-09 06:32:38 +00:00
return true;
}
2016-02-29 23:09:49 +00:00
-
2016-01-09 06:32:38 +00:00
- // Spigot start
- public String getTaskName() {
- if (timingName != null) {
- return timingName;
- }
- return task.getClass().getName();
- }
- // Spigot end
}
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftIconCache.java b/src/main/java/org/bukkit/craftbukkit/util/CraftIconCache.java
2018-08-04 21:03:53 +00:00
index e52ef47b78..3d90b34268 100644
2016-01-09 06:32:38 +00: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-02-29 23:09:49 +00:00
+ public String getData() { return value; } // Paper
2016-01-09 06:32:38 +00:00
public CraftIconCache(final String value) {
this.value = value;
}
diff --git a/src/main/java/org/spigotmc/ActivationRange.java b/src/main/java/org/spigotmc/ActivationRange.java
2018-08-04 21:03:53 +00:00
index e60fe5a920..f68e42c4d4 100644
2016-01-09 06:32:38 +00:00
--- a/src/main/java/org/spigotmc/ActivationRange.java
+++ b/src/main/java/org/spigotmc/ActivationRange.java
2018-07-15 01:53:17 +00:00
@@ -30,7 +30,7 @@ import net.minecraft.server.EntityWither;
2016-03-25 04:59:37 +00:00
import net.minecraft.server.MathHelper;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.World;
2016-01-09 06:32:38 +00:00
-import org.bukkit.craftbukkit.SpigotTimings;
2016-04-30 01:23:40 +00:00
+import co.aikar.timings.MinecraftTimings;
2016-01-09 06:32:38 +00:00
public class ActivationRange
{
2018-07-15 01:53:17 +00:00
@@ -64,8 +64,8 @@ public class ActivationRange
2016-04-30 01:23:40 +00: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 01:53:17 +00:00
@@ -99,7 +99,7 @@ public class ActivationRange
2016-04-30 01:23:40 +00: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 01:53:17 +00:00
@@ -133,7 +133,7 @@ public class ActivationRange
2016-04-30 01:23:40 +00:00
}
}
}
- SpigotTimings.entityActivationCheckTimer.stopTiming();
+ MinecraftTimings.entityActivationCheckTimer.stopTiming();
}
/**
2018-07-15 01:53:17 +00:00
@@ -247,10 +247,8 @@ public class ActivationRange
2016-03-18 21:11:53 +00: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 01:53:17 +00:00
if ( !entity.inChunk || entity instanceof EntityFireworks ) {
2016-03-18 21:11:53 +00:00
- SpigotTimings.checkIfActiveTimer.stopTiming();
return true;
}
2018-07-15 01:53:17 +00:00
@@ -282,7 +280,6 @@ public class ActivationRange
2016-03-18 21:11:53 +00:00
{
isActive = false;
}
- SpigotTimings.checkIfActiveTimer.stopTiming();
return isActive;
}
}
2016-01-09 06:32:38 +00:00
--
2018-08-04 21:03:53 +00:00
2.18.0
2016-01-09 06:32:38 +00:00