Paper/Spigot-Server-Patches/0009-Timings-v2.patch

1842 lines
86 KiB
Diff
Raw Normal View History

From 11dc8e1f66a697395be40b58e2249371b50e1e59 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
2016-03-03 09:46:26 +00:00
Date: Thu, 3 Mar 2016 04:00:11 -0600
Subject: [PATCH] Timings v2
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
index 0000000000..c6818bc86a
2016-01-10 07:33:27 +00:00
--- /dev/null
+++ b/src/main/java/co/aikar/timings/MinecraftTimings.java
@@ -0,0 +1,135 @@
2018-09-03 14:38:28 +00:00
+package co.aikar.timings;
2016-01-10 07:33:27 +00:00
+
+import com.google.common.collect.MapMaker;
2016-01-10 07:33:27 +00:00
+import net.minecraft.server.*;
+import org.bukkit.plugin.Plugin;
+import org.bukkit.scheduler.BukkitTask;
+
+import org.bukkit.craftbukkit.scheduler.CraftTask;
+
+import java.util.Map;
+
2019-04-24 01:00:24 +00:00
+// TODO: Re-implement missing timers
+public final class MinecraftTimings {
2016-01-10 07:33:27 +00:00
+
+ public static final Timing serverOversleep = Timings.ofSafe("Server Oversleep");
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");
+ 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");
+ 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");
+ 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 processTasksTimer = Timings.ofSafe("processTasks");
2016-01-10 07:33:27 +00:00
+
+ 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");
+
+ private static final Map<Class<?>, String> taskNameCache = new MapMaker().weakKeys().makeMap();
+
+ 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 NullTimingHandler.NULL;
2016-01-10 07:33:27 +00:00
+ }
+ Plugin plugin;
+
+ CraftTask craftTask = (CraftTask) bukkitTask;
2016-01-10 07:33:27 +00:00
+
+ final Class<?> taskClass = craftTask.getTaskClass();
2016-01-10 07:33:27 +00:00
+ if (bukkitTask.getOwner() != null) {
+ plugin = bukkitTask.getOwner();
+ } else {
+ plugin = TimingsManager.getPluginByClassloader(taskClass);
+ }
+
+ final String taskname = taskNameCache.computeIfAbsent(taskClass, clazz ->
+ clazz.isAnonymousClass() || clazz.isLocalClass()
+ ? clazz.getName()
+ : clazz.getCanonicalName());
2016-01-10 07:33:27 +00:00
+
+ StringBuilder name = new StringBuilder(64);
+ name.append("Task: ").append(taskname);
2016-01-10 07:33:27 +00:00
+ if (period > 0) {
+ name.append(" (interval:").append(period).append(")");
2016-01-10 07:33:27 +00:00
+ } else {
+ name.append(" (Single)");
2016-01-10 07:33:27 +00:00
+ }
+
+ if (plugin == null) {
+ return Timings.ofSafe(null, name.toString());
2016-01-10 07:33:27 +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) {
+ return Timings.ofSafe("## Scheduled Block: " + block.toString(), scheduledBlocksTimer);
2016-01-10 07:33:27 +00:00
+ }
+/*
+ public static Timing getStructureTiming(StructureGenerator structureGenerator) {
+ return Timings.ofSafe("Structure Generator - " + structureGenerator.getName(), structureGenerationTimer);
+ }*/
+
+ public static Timing getPacketTiming(Packet packet) {
+ return Timings.ofSafe("## Packet - " + packet.getClass().getSimpleName(), packetProcessTimer);
+ }
+
+ public static Timing getCommandFunctionTiming(CustomFunction function) {
+ return Timings.ofSafe("Command Function - " + function.getMinecraftKey().toString());
+ }
+}
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
index 0000000000..3a79cde595
2016-01-10 07:33:27 +00:00
--- /dev/null
+++ b/src/main/java/co/aikar/timings/WorldTimingsHandler.java
@@ -0,0 +1,130 @@
2016-01-10 07:33:27 +00:00
+package co.aikar.timings;
+
+import net.minecraft.server.World;
+import net.minecraft.server.WorldServer;
2016-01-10 07:33:27 +00:00
+
+/**
+ * Set of timers per world, to track world specific timings.
+ */
2019-04-24 01:00:24 +00:00
+// TODO: Re-implement missing timers
2016-01-10 07:33:27 +00: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;
+ 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;
+ 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 chunks;
+ public final Timing newEntities;
+ public final Timing raids;
+ public final Timing chunkProviderTick;
+ public final Timing broadcastChunkUpdates;
+ public final Timing countNaturalMobs;
2016-01-10 07:33:27 +00:00
+
+ public final Timing syncChunkLoadTimer;
+ public final Timing syncChunkLoadDataTimer;
+ public final Timing syncChunkLoadStructuresTimer;
+ public final Timing syncChunkLoadPostTimer;
+ public final Timing syncChunkLoadPopulateTimer;
+ public final Timing chunkAwait;
+ public final Timing chunkLoadLevelTimer;
+ public final Timing chunkGeneration;
+ public final Timing chunkIOStage1;
+ public final Timing chunkIOStage2;
+ 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 final Timing miscMobSpawning;
+ public final Timing chunkRangeCheckBig;
+ public final Timing chunkRangeCheckSmall;
+
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");
+ 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");
+ syncChunkLoadStructuresTimer = Timings.ofSafe(name + "chunkLoad - recreateStructures");
2016-01-10 07:33:27 +00:00
+ syncChunkLoadPostTimer = Timings.ofSafe(name + "chunkLoad - Post");
+ syncChunkLoadPopulateTimer = Timings.ofSafe(name + "chunkLoad - Populate");
+ chunkAwait = Timings.ofSafe(name + "chunkAwait");
+ chunkLoadLevelTimer = Timings.ofSafe(name + "chunkLoad - Load Level");
+ chunkGeneration = Timings.ofSafe(name + "chunkGeneration");
+ chunkIOStage1 = Timings.ofSafe(name + "ChunkIO Stage 1 - DiskIO");
+ chunkIOStage2 = Timings.ofSafe(name + "ChunkIO Stage 2 - Post Load");
+ 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
+
+ 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");
+
+ chunks = Timings.ofSafe(name + "Chunks");
+ newEntities = Timings.ofSafe(name + "New entity registration");
+ raids = Timings.ofSafe(name + "Raids");
+ chunkProviderTick = Timings.ofSafe(name + "Chunk provider tick");
+ broadcastChunkUpdates = Timings.ofSafe(name + "Broadcast chunk updates");
+ countNaturalMobs = Timings.ofSafe(name + "Count natural mobs");
+
+
+ miscMobSpawning = Timings.ofSafe(name + "Mob spawning - Misc");
+ chunkRangeCheckBig = Timings.ofSafe(name + "Chunk Tick Range - Big");
+ chunkRangeCheckSmall = Timings.ofSafe(name + "Chunk Tick Range - Small");
2016-01-10 07:33:27 +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
index 5518ec1e54..0c65afccfd 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
@@ -14,11 +14,14 @@ import java.util.concurrent.TimeUnit;
2016-02-29 23:09:49 +00:00
import java.util.logging.Level;
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 {
@@ -187,4 +190,27 @@ 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
}
+
+ public static String timingsServerName;
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);
+ timingsServerName = getString("timings.server-name", "Unknown Server");
2016-02-29 23:09:49 +00:00
+
+
+ Timings.setVerboseTimingsEnabled(verboseTimings);
+ Timings.setTimingsEnabled(timings);
+ Timings.setHistoryInterval(timingHistoryInterval * 20);
+ Timings.setHistoryLength(timingHistoryLength * 20);
+
+ log("Timings: " + timings +
2016-02-29 23:09:49 +00:00
+ " - Verbose: " + verboseTimings +
+ " - Interval: " + timeSummary(Timings.getHistoryInterval() / 20) +
+ " - Length: " + timeSummary(Timings.getHistoryLength() / 20) +
+ " - Server Name: " + timingsServerName);
2016-02-29 23:09:49 +00:00
+ }
}
diff --git a/src/main/java/net/minecraft/server/Block.java b/src/main/java/net/minecraft/server/Block.java
index abba434dac..1426bd01ad 100644
--- a/src/main/java/net/minecraft/server/Block.java
+++ b/src/main/java/net/minecraft/server/Block.java
2019-05-27 23:01:45 +00:00
@@ -31,6 +31,15 @@ public class Block implements IMaterial {
2019-04-24 01:00:24 +00:00
protected final boolean q;
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() {
+ if (timing == null) {
+ timing = co.aikar.timings.MinecraftTimings.getBlockTiming(this);
+ }
+ return timing;
+ }
2016-02-29 23:09:49 +00:00
+ // Paper end
2019-04-24 01:00:24 +00:00
protected final MaterialMapColor t;
private final float frictionFactor;
protected final BlockStateList<Block, IBlockData> blockStateList;
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
index 3ed48be382..c4d989f702 100644
--- a/src/main/java/net/minecraft/server/Chunk.java
+++ b/src/main/java/net/minecraft/server/Chunk.java
2019-05-27 23:01:45 +00:00
@@ -573,6 +573,7 @@ public class Chunk implements IChunkAccess {
server.getPluginManager().callEvent(new org.bukkit.event.world.ChunkLoadEvent(this.bukkitChunk, this.needsDecoration));
if (this.needsDecoration) {
+ try (co.aikar.timings.Timing ignored = this.world.timings.syncChunkLoadPopulateTimer.startTiming()) { // Paper
this.needsDecoration = false;
java.util.Random random = new java.util.Random();
random.setSeed(world.getSeed());
2019-05-27 23:01:45 +00:00
@@ -592,6 +593,7 @@ public class Chunk implements IChunkAccess {
2019-04-24 01:00:24 +00:00
}
}
server.getPluginManager().callEvent(new org.bukkit.event.world.ChunkPopulateEvent(bukkitChunk));
+ } // Paper
}
}
}
diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java
index 3b785a3ade..15480a8dfb 100644
--- a/src/main/java/net/minecraft/server/ChunkProviderServer.java
+++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java
@@ -129,11 +129,13 @@ public class ChunkProviderServer extends IChunkProvider {
}
}
- world.timings.syncChunkLoadTimer.startTiming(); // Spigot
CompletableFuture<Either<IChunkAccess, PlayerChunk.Failure>> completablefuture = this.getChunkFutureMainThread(i, j, chunkstatus, flag);
+ if (!completablefuture.isDone()) { // Paper
+ this.world.timings.chunkAwait.startTiming(); // Paper
this.serverThreadQueue.awaitTasks(completablefuture::isDone);
- world.timings.syncChunkLoadTimer.stopTiming(); // Spigot
+ this.world.timings.chunkAwait.stopTiming(); // Paper
+ } // Paper
ichunkaccess = (IChunkAccess) ((Either) completablefuture.join()).map((ichunkaccess1) -> {
return ichunkaccess1;
}, (playerchunk_failure) -> {
@@ -325,7 +327,9 @@ public class ChunkProviderServer extends IChunkProvider {
2019-04-24 01:00:24 +00:00
public void save(boolean flag) {
2019-05-27 23:01:45 +00:00
this.tickDistanceManager();
2019-04-24 01:00:24 +00:00
+ try (co.aikar.timings.Timing timed = world.timings.chunkSaveData.startTiming()) { // Paper - Timings
this.playerChunkMap.save(flag);
+ } // Paper - Timings
}
@Override
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#2415) * fixup patch and rebuild * Updated Upstream (Bukkit/CraftBukkit/Spigot) Upstream has released updates that appears to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: bde198c9 SPIGOT-5246: PlayerQuitEvent.get/setQuitMessage() is incorrectly marked as NotNull 24ad5a79 SPIGOT-5240: Vector.angle not valid for angles very close to each other a143db9a SPIGOT-5231: ShotAtAngle API for Fireworks 10db5c3d SPIGOT-5226: Update Javadoc of PlayerDeathEvent CraftBukkit Changes: 1ec1b05e SPIGOT-5245: Unneeded cast to WorldNBTStorage in CraftWorld#getWorldFolder e5e8eec2 SPIGOT-5241: setAttributeModifiers does not work on untouched stack 803eaa31 SPIGOT-5231: ShotAtAngle API for Fireworks 7881d2ae SPIGOT-5237: Horses, pigs do not drop their inventory 06efc9ec Don't accept connections until all plugins have enabled da62a66a SPIGOT-5225: World handle isn't closed if world is unloaded without saving 104b3831 SPIGOT-5222: Cannot get Long values from Entity memory f0b3fe43 SPIGOT-5220: Server CPU usage reaches 100% when stdin is null Spigot Changes: e5b1b5db SPIGOT-5235: Destroy expired area effect clouds / fireworks that are inactive cbcc8e87 Make region files more reliable to write to 8887c5f4 Remove redundant late-bind option dac29063 Rebuild patches * Preserve old flush on save flag for reliable regionfiles Originally this patch was in paper * Fix some issues with the death event - Entities potentially entering a glitched state to the client where they appear to be falling over - Donkeys losing their chest if the event was cancelled (only an issue since the upstream merge) - Some wither death logic running for an entity killed by a wither
2019-08-05 16:35:40 +00:00
@@ -362,7 +366,9 @@ public class ChunkProviderServer extends IChunkProvider {
this.tickDistanceManager();
this.world.timings.doChunkMap.stopTiming(); // Spigot
this.world.getMethodProfiler().exitEnter("chunks");
+ this.world.timings.chunks.startTiming(); // Paper - timings
this.tickChunks();
+ this.world.timings.chunks.stopTiming(); // Paper - timings
this.world.timings.doChunkUnload.startTiming(); // Spigot
this.world.getMethodProfiler().exitEnter("unload");
this.playerChunkMap.unloadChunks(booleansupplier);
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#2415) * fixup patch and rebuild * Updated Upstream (Bukkit/CraftBukkit/Spigot) Upstream has released updates that appears to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: bde198c9 SPIGOT-5246: PlayerQuitEvent.get/setQuitMessage() is incorrectly marked as NotNull 24ad5a79 SPIGOT-5240: Vector.angle not valid for angles very close to each other a143db9a SPIGOT-5231: ShotAtAngle API for Fireworks 10db5c3d SPIGOT-5226: Update Javadoc of PlayerDeathEvent CraftBukkit Changes: 1ec1b05e SPIGOT-5245: Unneeded cast to WorldNBTStorage in CraftWorld#getWorldFolder e5e8eec2 SPIGOT-5241: setAttributeModifiers does not work on untouched stack 803eaa31 SPIGOT-5231: ShotAtAngle API for Fireworks 7881d2ae SPIGOT-5237: Horses, pigs do not drop their inventory 06efc9ec Don't accept connections until all plugins have enabled da62a66a SPIGOT-5225: World handle isn't closed if world is unloaded without saving 104b3831 SPIGOT-5222: Cannot get Long values from Entity memory f0b3fe43 SPIGOT-5220: Server CPU usage reaches 100% when stdin is null Spigot Changes: e5b1b5db SPIGOT-5235: Destroy expired area effect clouds / fireworks that are inactive cbcc8e87 Make region files more reliable to write to 8887c5f4 Remove redundant late-bind option dac29063 Rebuild patches * Preserve old flush on save flag for reliable regionfiles Originally this patch was in paper * Fix some issues with the death event - Entities potentially entering a glitched state to the client where they appear to be falling over - Donkeys losing their chest if the event was cancelled (only an issue since the upstream merge) - Some wither death logic running for an entity killed by a wither
2019-08-05 16:35:40 +00:00
@@ -387,10 +393,12 @@ public class ChunkProviderServer extends IChunkProvider {
boolean flag2 = world.ticksPerAnimalSpawns != 0L && worlddata.getTime() % world.ticksPerAnimalSpawns == 0L; // CraftBukkit // PAIL: TODO monster ticks
this.world.getMethodProfiler().enter("naturalSpawnCount");
+ this.world.timings.countNaturalMobs.startTiming(); // Paper - timings
int l = this.chunkMapDistance.b();
EnumCreatureType[] aenumcreaturetype = EnumCreatureType.values();
Object2IntMap<EnumCreatureType> object2intmap = this.world.l();
+ this.world.timings.countNaturalMobs.stopTiming(); // Paper - timings
this.world.getMethodProfiler().exit();
this.playerChunkMap.f().forEach((playerchunk) -> {
Optional<Chunk> optional = ((Either) playerchunk.b().getNow(PlayerChunk.UNLOADED_CHUNK)).left();
@@ -399,13 +407,27 @@ public class ChunkProviderServer extends IChunkProvider {
Chunk chunk = (Chunk) optional.get();
this.world.getMethodProfiler().enter("broadcast");
+ this.world.timings.broadcastChunkUpdates.startTiming(); // Paper - timings
playerchunk.a(chunk);
+ this.world.timings.broadcastChunkUpdates.stopTiming(); // Paper - timings
this.world.getMethodProfiler().exit();
ChunkCoordIntPair chunkcoordintpair = playerchunk.i();
- if (!this.playerChunkMap.isOutsideOfRange(chunkcoordintpair)) {
+ // Paper start - timings
+ this.world.timings.chunkRangeCheckBig.startTiming();
+ // note: this is just a copy of the expression in the if
+ boolean bigRadiusOutsideRange = !this.playerChunkMap.isOutsideOfRange(chunkcoordintpair);
+ this.world.timings.chunkRangeCheckBig.stopTiming();
+ if (bigRadiusOutsideRange) {
+ // Paper end
chunk.b(chunk.q() + j);
- if (flag1 && (this.allowMonsters || this.allowAnimals) && this.world.getWorldBorder().isInBounds(chunk.getPos()) && !this.playerChunkMap.isOutsideOfRange(chunkcoordintpair, true)) { // Spigot
+ // Paper start - timings
+ this.world.timings.chunkRangeCheckSmall.startTiming();
+ // note: this is just a copy of the expression in the if
+ boolean smallRadiusOutsideRange = flag1 && (this.allowMonsters || this.allowAnimals) && this.world.getWorldBorder().isInBounds(chunk.getPos()) && !this.playerChunkMap.isOutsideOfRange(chunkcoordintpair, true);
+ this.world.timings.chunkRangeCheckSmall.stopTiming();
+ if (smallRadiusOutsideRange) { // Spigot
+ // Paper end
this.world.getMethodProfiler().enter("spawner");
this.world.timings.mobSpawn.startTiming(); // Spigot
EnumCreatureType[] aenumcreaturetype1 = aenumcreaturetype;
@@ -449,24 +471,24 @@ public class ChunkProviderServer extends IChunkProvider {
2019-04-24 01:00:24 +00:00
this.world.getMethodProfiler().exit();
}
2019-05-14 02:20:58 +00:00
2019-04-24 01:00:24 +00:00
- this.world.timings.doTickTiles.startTiming(); // Spigot
+ this.world.timings.chunkTicks.startTiming(); // Spigot // Paper
2019-05-14 02:20:58 +00:00
this.world.a(chunk, k);
2019-04-24 01:00:24 +00:00
- this.world.timings.doTickTiles.stopTiming(); // Spigot
+ this.world.timings.chunkTicks.stopTiming(); // Spigot // Paper
}
}
});
this.world.getMethodProfiler().enter("customSpawners");
if (flag1) {
+ try (co.aikar.timings.Timing ignored = this.world.timings.miscMobSpawning.startTiming()) { // Paper - timings
this.chunkGenerator.doMobSpawning(this.world, this.allowMonsters, this.allowAnimals);
+ } // Paper - timings
}
this.world.getMethodProfiler().exit();
2019-05-14 02:20:58 +00:00
this.world.getMethodProfiler().exit();
}
2019-04-24 01:00:24 +00:00
- this.world.timings.tracker.startTiming(); // Spigot
this.playerChunkMap.g();
- this.world.timings.tracker.stopTiming(); // Spigot
}
2019-04-24 01:00:24 +00:00
@Override
diff --git a/src/main/java/net/minecraft/server/ChunkRegionLoader.java b/src/main/java/net/minecraft/server/ChunkRegionLoader.java
index 28bf9e14d6..03be77299b 100644
--- a/src/main/java/net/minecraft/server/ChunkRegionLoader.java
+++ b/src/main/java/net/minecraft/server/ChunkRegionLoader.java
@@ -1,5 +1,6 @@
package net.minecraft.server;
+import co.aikar.timings.Timings;
import com.google.common.collect.Maps;
2019-04-24 01:00:24 +00:00
import it.unimi.dsi.fastutil.longs.LongOpenHashSet;
import it.unimi.dsi.fastutil.longs.LongSet;
@@ -407,7 +408,7 @@ public class ChunkRegionLoader {
2019-04-24 01:00:24 +00:00
private static void loadEntities(NBTTagCompound nbttagcompound, Chunk chunk) {
NBTTagList nbttaglist = nbttagcompound.getList("Entities", 10);
World world = chunk.getWorld();
- world.timings.syncChunkLoadEntitiesTimer.startTiming(); // Spigot
+ world.timings.chunkLoadLevelTimer.startTiming(); // Spigot
for (int i = 0; i < nbttaglist.size(); ++i) {
NBTTagCompound nbttagcompound1 = nbttaglist.getCompound(i);
@@ -419,8 +420,6 @@ public class ChunkRegionLoader {
2019-04-24 01:00:24 +00:00
chunk.d(true);
}
- world.timings.syncChunkLoadEntitiesTimer.stopTiming(); // Spigot
- world.timings.syncChunkLoadTileEntitiesTimer.startTiming(); // Spigot
NBTTagList nbttaglist1 = nbttagcompound.getList("TileEntities", 10);
for (int j = 0; j < nbttaglist1.size(); ++j) {
@@ -437,7 +436,7 @@ public class ChunkRegionLoader {
}
}
}
- world.timings.syncChunkLoadTileEntitiesTimer.stopTiming(); // Spigot
2019-05-14 02:20:58 +00:00
+ world.timings.chunkLoadLevelTimer.stopTiming(); // Paper
}
diff --git a/src/main/java/net/minecraft/server/CustomFunction.java b/src/main/java/net/minecraft/server/CustomFunction.java
index 12885cbd60..49de6e997a 100644
--- a/src/main/java/net/minecraft/server/CustomFunction.java
+++ b/src/main/java/net/minecraft/server/CustomFunction.java
2019-04-24 01:00:24 +00:00
@@ -13,12 +13,22 @@ public class CustomFunction {
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
index 53735b52a3..721839b4c6 100644
--- a/src/main/java/net/minecraft/server/CustomFunctionData.java
+++ b/src/main/java/net/minecraft/server/CustomFunctionData.java
2019-05-14 02:20:58 +00:00
@@ -101,7 +101,7 @@ public class CustomFunctionData implements IResourcePackListener {
return 0;
} else {
- try {
+ try (co.aikar.timings.Timing timing = customfunction.getTiming().startTiming()) { // Paper
2019-05-14 02:20:58 +00:00
this.h = true;
int j = 0;
CustomFunction.c[] acustomfunction_c = customfunction.b();
diff --git a/src/main/java/net/minecraft/server/DedicatedServer.java b/src/main/java/net/minecraft/server/DedicatedServer.java
index e6cf90484c..ce3ca4830e 100644
--- a/src/main/java/net/minecraft/server/DedicatedServer.java
+++ b/src/main/java/net/minecraft/server/DedicatedServer.java
@@ -19,6 +19,8 @@ import java.util.Collections;
import java.util.List;
import java.util.Locale;
import java.util.Random;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.ExecutionException;
import java.util.function.BooleanSupplier;
import java.util.regex.Pattern;
import javax.annotation.Nullable;
@@ -31,7 +33,7 @@ import org.apache.logging.log4j.Level;
import org.bukkit.command.CommandSender;
import org.bukkit.craftbukkit.LoggerOutputStream;
-import org.bukkit.craftbukkit.SpigotTimings; // Spigot
+import co.aikar.timings.MinecraftTimings; // Paper
import org.bukkit.event.server.ServerCommandEvent;
import org.bukkit.craftbukkit.util.Waitable;
import org.bukkit.event.server.RemoteServerCommandEvent;
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#2415) * fixup patch and rebuild * Updated Upstream (Bukkit/CraftBukkit/Spigot) Upstream has released updates that appears to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: bde198c9 SPIGOT-5246: PlayerQuitEvent.get/setQuitMessage() is incorrectly marked as NotNull 24ad5a79 SPIGOT-5240: Vector.angle not valid for angles very close to each other a143db9a SPIGOT-5231: ShotAtAngle API for Fireworks 10db5c3d SPIGOT-5226: Update Javadoc of PlayerDeathEvent CraftBukkit Changes: 1ec1b05e SPIGOT-5245: Unneeded cast to WorldNBTStorage in CraftWorld#getWorldFolder e5e8eec2 SPIGOT-5241: setAttributeModifiers does not work on untouched stack 803eaa31 SPIGOT-5231: ShotAtAngle API for Fireworks 7881d2ae SPIGOT-5237: Horses, pigs do not drop their inventory 06efc9ec Don't accept connections until all plugins have enabled da62a66a SPIGOT-5225: World handle isn't closed if world is unloaded without saving 104b3831 SPIGOT-5222: Cannot get Long values from Entity memory f0b3fe43 SPIGOT-5220: Server CPU usage reaches 100% when stdin is null Spigot Changes: e5b1b5db SPIGOT-5235: Destroy expired area effect clouds / fireworks that are inactive cbcc8e87 Make region files more reliable to write to 8887c5f4 Remove redundant late-bind option dac29063 Rebuild patches * Preserve old flush on save flag for reliable regionfiles Originally this patch was in paper * Fix some issues with the death event - Entities potentially entering a glitched state to the client where they appear to be falling over - Donkeys losing their chest if the event was cancelled (only an issue since the upstream merge) - Some wither death logic running for an entity killed by a wither
2019-08-05 16:35:40 +00:00
@@ -425,7 +427,7 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer
}
public void handleCommandQueue() {
- SpigotTimings.serverCommandTimer.startTiming(); // Spigot
+ MinecraftTimings.serverCommandTimer.startTiming(); // Spigot
while (!this.serverCommandQueue.isEmpty()) {
ServerCommand servercommand = (ServerCommand) this.serverCommandQueue.remove(0);
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#2415) * fixup patch and rebuild * Updated Upstream (Bukkit/CraftBukkit/Spigot) Upstream has released updates that appears to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: bde198c9 SPIGOT-5246: PlayerQuitEvent.get/setQuitMessage() is incorrectly marked as NotNull 24ad5a79 SPIGOT-5240: Vector.angle not valid for angles very close to each other a143db9a SPIGOT-5231: ShotAtAngle API for Fireworks 10db5c3d SPIGOT-5226: Update Javadoc of PlayerDeathEvent CraftBukkit Changes: 1ec1b05e SPIGOT-5245: Unneeded cast to WorldNBTStorage in CraftWorld#getWorldFolder e5e8eec2 SPIGOT-5241: setAttributeModifiers does not work on untouched stack 803eaa31 SPIGOT-5231: ShotAtAngle API for Fireworks 7881d2ae SPIGOT-5237: Horses, pigs do not drop their inventory 06efc9ec Don't accept connections until all plugins have enabled da62a66a SPIGOT-5225: World handle isn't closed if world is unloaded without saving 104b3831 SPIGOT-5222: Cannot get Long values from Entity memory f0b3fe43 SPIGOT-5220: Server CPU usage reaches 100% when stdin is null Spigot Changes: e5b1b5db SPIGOT-5235: Destroy expired area effect clouds / fireworks that are inactive cbcc8e87 Make region files more reliable to write to 8887c5f4 Remove redundant late-bind option dac29063 Rebuild patches * Preserve old flush on save flag for reliable regionfiles Originally this patch was in paper * Fix some issues with the death event - Entities potentially entering a glitched state to the client where they appear to be falling over - Donkeys losing their chest if the event was cancelled (only an issue since the upstream merge) - Some wither death logic running for an entity killed by a wither
2019-08-05 16:35:40 +00:00
@@ -440,7 +442,7 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer
// CraftBukkit end
}
- SpigotTimings.serverCommandTimer.stopTiming(); // Spigot
+ MinecraftTimings.serverCommandTimer.stopTiming(); // Spigot
}
2019-04-24 01:00:24 +00:00
@Override
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#2415) * fixup patch and rebuild * Updated Upstream (Bukkit/CraftBukkit/Spigot) Upstream has released updates that appears to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: bde198c9 SPIGOT-5246: PlayerQuitEvent.get/setQuitMessage() is incorrectly marked as NotNull 24ad5a79 SPIGOT-5240: Vector.angle not valid for angles very close to each other a143db9a SPIGOT-5231: ShotAtAngle API for Fireworks 10db5c3d SPIGOT-5226: Update Javadoc of PlayerDeathEvent CraftBukkit Changes: 1ec1b05e SPIGOT-5245: Unneeded cast to WorldNBTStorage in CraftWorld#getWorldFolder e5e8eec2 SPIGOT-5241: setAttributeModifiers does not work on untouched stack 803eaa31 SPIGOT-5231: ShotAtAngle API for Fireworks 7881d2ae SPIGOT-5237: Horses, pigs do not drop their inventory 06efc9ec Don't accept connections until all plugins have enabled da62a66a SPIGOT-5225: World handle isn't closed if world is unloaded without saving 104b3831 SPIGOT-5222: Cannot get Long values from Entity memory f0b3fe43 SPIGOT-5220: Server CPU usage reaches 100% when stdin is null Spigot Changes: e5b1b5db SPIGOT-5235: Destroy expired area effect clouds / fireworks that are inactive cbcc8e87 Make region files more reliable to write to 8887c5f4 Remove redundant late-bind option dac29063 Rebuild patches * Preserve old flush on save flag for reliable regionfiles Originally this patch was in paper * Fix some issues with the death event - Entities potentially entering a glitched state to the client where they appear to be falling over - Donkeys losing their chest if the event was cancelled (only an issue since the upstream merge) - Some wither death logic running for an entity killed by a wither
2019-08-05 16:35:40 +00:00
@@ -666,6 +668,7 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer
@Override
public String executeRemoteCommand(String s) {
+ Waitable[] waitableArray = new Waitable[1];
this.remoteControlCommandListener.clearMessages();
this.executeSync(() -> {
// CraftBukkit start - fire RemoteServerCommandEvent
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#2415) * fixup patch and rebuild * Updated Upstream (Bukkit/CraftBukkit/Spigot) Upstream has released updates that appears to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: bde198c9 SPIGOT-5246: PlayerQuitEvent.get/setQuitMessage() is incorrectly marked as NotNull 24ad5a79 SPIGOT-5240: Vector.angle not valid for angles very close to each other a143db9a SPIGOT-5231: ShotAtAngle API for Fireworks 10db5c3d SPIGOT-5226: Update Javadoc of PlayerDeathEvent CraftBukkit Changes: 1ec1b05e SPIGOT-5245: Unneeded cast to WorldNBTStorage in CraftWorld#getWorldFolder e5e8eec2 SPIGOT-5241: setAttributeModifiers does not work on untouched stack 803eaa31 SPIGOT-5231: ShotAtAngle API for Fireworks 7881d2ae SPIGOT-5237: Horses, pigs do not drop their inventory 06efc9ec Don't accept connections until all plugins have enabled da62a66a SPIGOT-5225: World handle isn't closed if world is unloaded without saving 104b3831 SPIGOT-5222: Cannot get Long values from Entity memory f0b3fe43 SPIGOT-5220: Server CPU usage reaches 100% when stdin is null Spigot Changes: e5b1b5db SPIGOT-5235: Destroy expired area effect clouds / fireworks that are inactive cbcc8e87 Make region files more reliable to write to 8887c5f4 Remove redundant late-bind option dac29063 Rebuild patches * Preserve old flush on save flag for reliable regionfiles Originally this patch was in paper * Fix some issues with the death event - Entities potentially entering a glitched state to the client where they appear to be falling over - Donkeys losing their chest if the event was cancelled (only an issue since the upstream merge) - Some wither death logic running for an entity killed by a wither
2019-08-05 16:35:40 +00:00
@@ -674,10 +677,39 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer
if (event.isCancelled()) {
return;
}
+ // 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<String> waitable = new Waitable<String>() {
+ @Override
+ protected String evaluate() {
+ return sender.getBuffer();
+ }
+ };
+ waitableArray[0] = waitable;
+ co.aikar.timings.Timings.generateReport(new co.aikar.timings.TimingsReportListener(sender, waitable));
+ } else {
+ // Paper end
2019-07-20 04:01:24 +00:00
ServerCommand serverCommand = new ServerCommand(event.getCommand(), remoteControlCommandListener.getWrapper());
server.dispatchServerCommand(remoteConsole, serverCommand);
+ } // Paper
// CraftBukkit end
});
+ // Paper start
+ if (waitableArray[0] != null) {
+ //noinspection unchecked
+ Waitable<String> waitable = waitableArray[0];
+ try {
+ return waitable.get();
+ } catch (java.util.concurrent.ExecutionException e) {
+ throw new RuntimeException("Exception processing rcon command " + s, e.getCause());
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt(); // Maintain interrupted state
+ throw new RuntimeException("Interrupted processing rcon command " + s, e);
+ }
+
+ }
+ // Paper end
return this.remoteControlCommandListener.getMessages();
}
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
index d4954801cb..fd4712c710 100644
--- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java
2019-04-25 06:53:51 +00:00
@@ -29,7 +29,8 @@ import org.bukkit.command.CommandSender;
2016-02-29 23:09:49 +00:00
import org.bukkit.entity.Hanging;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Vehicle;
-import org.spigotmc.CustomTimingsHandler; // Spigot
+import co.aikar.timings.MinecraftTimings; // Paper
2016-02-29 23:09:49 +00:00
+import co.aikar.timings.Timing; // Paper
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;
2019-05-06 02:58:04 +00:00
@@ -161,7 +162,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
- public CustomTimingsHandler tickTimer = org.bukkit.craftbukkit.SpigotTimings.getEntityTimings(this); // Spigot
+ public Timing tickTimer = MinecraftTimings.getEntityTimings(this); // Paper
2016-02-29 23:09:49 +00:00
// Spigot start
public final org.spigotmc.ActivationRange.ActivationType activationType = org.spigotmc.ActivationRange.initializeEntityActivationType(this);
public final boolean defaultActivationState;
@@ -496,7 +497,6 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
2016-02-29 23:09:49 +00:00
}
2019-04-24 01:00:24 +00:00
public void move(EnumMoveType enummovetype, Vec3D vec3d) {
- org.bukkit.craftbukkit.SpigotTimings.entityMoveTimer.startTiming(); // Spigot
if (this.noclip) {
2019-04-24 01:00:24 +00:00
this.a(this.getBoundingBox().b(vec3d));
2016-02-29 23:09:49 +00:00
this.recalcPosition();
@@ -661,7 +661,6 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
2019-04-24 01:00:24 +00:00
this.world.getMethodProfiler().exit();
}
- org.bukkit.craftbukkit.SpigotTimings.entityMoveTimer.stopTiming(); // Spigot
}
2019-04-24 01:00:24 +00:00
protected Vec3D a(Vec3D vec3d, EnumMoveType enummovetype) {
diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java
index 2b13f4c9f9..47379046dc 100644
--- a/src/main/java/net/minecraft/server/EntityLiving.java
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
2019-04-24 01:00:24 +00:00
@@ -35,7 +35,7 @@ import org.bukkit.event.entity.EntityTeleportEvent;
2016-02-29 23:09:49 +00:00
import org.bukkit.event.player.PlayerItemConsumeEvent;
// CraftBukkit end
-import org.bukkit.craftbukkit.SpigotTimings; // Spigot
+import co.aikar.timings.MinecraftTimings; // Paper
public abstract class EntityLiving extends Entity {
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#2415) * fixup patch and rebuild * Updated Upstream (Bukkit/CraftBukkit/Spigot) Upstream has released updates that appears to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: bde198c9 SPIGOT-5246: PlayerQuitEvent.get/setQuitMessage() is incorrectly marked as NotNull 24ad5a79 SPIGOT-5240: Vector.angle not valid for angles very close to each other a143db9a SPIGOT-5231: ShotAtAngle API for Fireworks 10db5c3d SPIGOT-5226: Update Javadoc of PlayerDeathEvent CraftBukkit Changes: 1ec1b05e SPIGOT-5245: Unneeded cast to WorldNBTStorage in CraftWorld#getWorldFolder e5e8eec2 SPIGOT-5241: setAttributeModifiers does not work on untouched stack 803eaa31 SPIGOT-5231: ShotAtAngle API for Fireworks 7881d2ae SPIGOT-5237: Horses, pigs do not drop their inventory 06efc9ec Don't accept connections until all plugins have enabled da62a66a SPIGOT-5225: World handle isn't closed if world is unloaded without saving 104b3831 SPIGOT-5222: Cannot get Long values from Entity memory f0b3fe43 SPIGOT-5220: Server CPU usage reaches 100% when stdin is null Spigot Changes: e5b1b5db SPIGOT-5235: Destroy expired area effect clouds / fireworks that are inactive cbcc8e87 Make region files more reliable to write to 8887c5f4 Remove redundant late-bind option dac29063 Rebuild patches * Preserve old flush on save flag for reliable regionfiles Originally this patch was in paper * Fix some issues with the death event - Entities potentially entering a glitched state to the client where they appear to be falling over - Donkeys losing their chest if the event was cancelled (only an issue since the upstream merge) - Some wither death logic running for an entity killed by a wither
2019-08-05 16:35:40 +00:00
@@ -2215,7 +2215,6 @@ public abstract class EntityLiving extends Entity {
2019-04-24 01:00:24 +00:00
@Override
public void tick() {
- SpigotTimings.timerEntityBaseTick.startTiming(); // Spigot
super.tick();
this.o();
2019-07-20 04:01:24 +00:00
this.p();
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#2415) * fixup patch and rebuild * Updated Upstream (Bukkit/CraftBukkit/Spigot) Upstream has released updates that appears to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: bde198c9 SPIGOT-5246: PlayerQuitEvent.get/setQuitMessage() is incorrectly marked as NotNull 24ad5a79 SPIGOT-5240: Vector.angle not valid for angles very close to each other a143db9a SPIGOT-5231: ShotAtAngle API for Fireworks 10db5c3d SPIGOT-5226: Update Javadoc of PlayerDeathEvent CraftBukkit Changes: 1ec1b05e SPIGOT-5245: Unneeded cast to WorldNBTStorage in CraftWorld#getWorldFolder e5e8eec2 SPIGOT-5241: setAttributeModifiers does not work on untouched stack 803eaa31 SPIGOT-5231: ShotAtAngle API for Fireworks 7881d2ae SPIGOT-5237: Horses, pigs do not drop their inventory 06efc9ec Don't accept connections until all plugins have enabled da62a66a SPIGOT-5225: World handle isn't closed if world is unloaded without saving 104b3831 SPIGOT-5222: Cannot get Long values from Entity memory f0b3fe43 SPIGOT-5220: Server CPU usage reaches 100% when stdin is null Spigot Changes: e5b1b5db SPIGOT-5235: Destroy expired area effect clouds / fireworks that are inactive cbcc8e87 Make region files more reliable to write to 8887c5f4 Remove redundant late-bind option dac29063 Rebuild patches * Preserve old flush on save flag for reliable regionfiles Originally this patch was in paper * Fix some issues with the death event - Entities potentially entering a glitched state to the client where they appear to be falling over - Donkeys losing their chest if the event was cancelled (only an issue since the upstream merge) - Some wither death logic running for an entity killed by a wither
2019-08-05 16:35:40 +00:00
@@ -2290,9 +2289,7 @@ public abstract class EntityLiving extends Entity {
}
}
- SpigotTimings.timerEntityBaseTick.stopTiming(); // Spigot
this.movementTick();
- SpigotTimings.timerEntityTickRest.startTiming(); // Spigot
double d0 = this.locX - this.lastX;
double d1 = this.locZ - this.lastZ;
float f = (float) (d0 * d0 + d1 * d1);
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#2415) * fixup patch and rebuild * Updated Upstream (Bukkit/CraftBukkit/Spigot) Upstream has released updates that appears to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: bde198c9 SPIGOT-5246: PlayerQuitEvent.get/setQuitMessage() is incorrectly marked as NotNull 24ad5a79 SPIGOT-5240: Vector.angle not valid for angles very close to each other a143db9a SPIGOT-5231: ShotAtAngle API for Fireworks 10db5c3d SPIGOT-5226: Update Javadoc of PlayerDeathEvent CraftBukkit Changes: 1ec1b05e SPIGOT-5245: Unneeded cast to WorldNBTStorage in CraftWorld#getWorldFolder e5e8eec2 SPIGOT-5241: setAttributeModifiers does not work on untouched stack 803eaa31 SPIGOT-5231: ShotAtAngle API for Fireworks 7881d2ae SPIGOT-5237: Horses, pigs do not drop their inventory 06efc9ec Don't accept connections until all plugins have enabled da62a66a SPIGOT-5225: World handle isn't closed if world is unloaded without saving 104b3831 SPIGOT-5222: Cannot get Long values from Entity memory f0b3fe43 SPIGOT-5220: Server CPU usage reaches 100% when stdin is null Spigot Changes: e5b1b5db SPIGOT-5235: Destroy expired area effect clouds / fireworks that are inactive cbcc8e87 Make region files more reliable to write to 8887c5f4 Remove redundant late-bind option dac29063 Rebuild patches * Preserve old flush on save flag for reliable regionfiles Originally this patch was in paper * Fix some issues with the death event - Entities potentially entering a glitched state to the client where they appear to be falling over - Donkeys losing their chest if the event was cancelled (only an issue since the upstream merge) - Some wither death logic running for an entity killed by a wither
2019-08-05 16:35:40 +00:00
@@ -2372,8 +2369,6 @@ public abstract class EntityLiving extends Entity {
2019-04-24 01:00:24 +00:00
if (this.isSleeping()) {
this.pitch = 0.0F;
2016-02-29 23:09:49 +00:00
}
-
- SpigotTimings.timerEntityTickRest.stopTiming(); // Spigot
}
protected float e(float f, float f1) {
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#2415) * fixup patch and rebuild * Updated Upstream (Bukkit/CraftBukkit/Spigot) Upstream has released updates that appears to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: bde198c9 SPIGOT-5246: PlayerQuitEvent.get/setQuitMessage() is incorrectly marked as NotNull 24ad5a79 SPIGOT-5240: Vector.angle not valid for angles very close to each other a143db9a SPIGOT-5231: ShotAtAngle API for Fireworks 10db5c3d SPIGOT-5226: Update Javadoc of PlayerDeathEvent CraftBukkit Changes: 1ec1b05e SPIGOT-5245: Unneeded cast to WorldNBTStorage in CraftWorld#getWorldFolder e5e8eec2 SPIGOT-5241: setAttributeModifiers does not work on untouched stack 803eaa31 SPIGOT-5231: ShotAtAngle API for Fireworks 7881d2ae SPIGOT-5237: Horses, pigs do not drop their inventory 06efc9ec Don't accept connections until all plugins have enabled da62a66a SPIGOT-5225: World handle isn't closed if world is unloaded without saving 104b3831 SPIGOT-5222: Cannot get Long values from Entity memory f0b3fe43 SPIGOT-5220: Server CPU usage reaches 100% when stdin is null Spigot Changes: e5b1b5db SPIGOT-5235: Destroy expired area effect clouds / fireworks that are inactive cbcc8e87 Make region files more reliable to write to 8887c5f4 Remove redundant late-bind option dac29063 Rebuild patches * Preserve old flush on save flag for reliable regionfiles Originally this patch was in paper * Fix some issues with the death event - Entities potentially entering a glitched state to the client where they appear to be falling over - Donkeys losing their chest if the event was cancelled (only an issue since the upstream merge) - Some wither death logic running for an entity killed by a wither
2019-08-05 16:35:40 +00:00
@@ -2447,7 +2442,6 @@ public abstract class EntityLiving extends Entity {
2019-04-24 01:00:24 +00:00
this.setMot(d4, d5, d6);
this.world.getMethodProfiler().enter("ai");
- SpigotTimings.timerEntityAI.startTiming(); // Spigot
2016-11-17 02:23:38 +00:00
if (this.isFrozen()) {
2019-04-24 01:00:24 +00:00
this.jumping = false;
this.bb = 0.0F;
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#2415) * fixup patch and rebuild * Updated Upstream (Bukkit/CraftBukkit/Spigot) Upstream has released updates that appears to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: bde198c9 SPIGOT-5246: PlayerQuitEvent.get/setQuitMessage() is incorrectly marked as NotNull 24ad5a79 SPIGOT-5240: Vector.angle not valid for angles very close to each other a143db9a SPIGOT-5231: ShotAtAngle API for Fireworks 10db5c3d SPIGOT-5226: Update Javadoc of PlayerDeathEvent CraftBukkit Changes: 1ec1b05e SPIGOT-5245: Unneeded cast to WorldNBTStorage in CraftWorld#getWorldFolder e5e8eec2 SPIGOT-5241: setAttributeModifiers does not work on untouched stack 803eaa31 SPIGOT-5231: ShotAtAngle API for Fireworks 7881d2ae SPIGOT-5237: Horses, pigs do not drop their inventory 06efc9ec Don't accept connections until all plugins have enabled da62a66a SPIGOT-5225: World handle isn't closed if world is unloaded without saving 104b3831 SPIGOT-5222: Cannot get Long values from Entity memory f0b3fe43 SPIGOT-5220: Server CPU usage reaches 100% when stdin is null Spigot Changes: e5b1b5db SPIGOT-5235: Destroy expired area effect clouds / fireworks that are inactive cbcc8e87 Make region files more reliable to write to 8887c5f4 Remove redundant late-bind option dac29063 Rebuild patches * Preserve old flush on save flag for reliable regionfiles Originally this patch was in paper * Fix some issues with the death event - Entities potentially entering a glitched state to the client where they appear to be falling over - Donkeys losing their chest if the event was cancelled (only an issue since the upstream merge) - Some wither death logic running for an entity killed by a wither
2019-08-05 16:35:40 +00:00
@@ -2458,7 +2452,6 @@ public abstract class EntityLiving extends Entity {
this.doTick();
2019-04-24 01:00:24 +00:00
this.world.getMethodProfiler().exit();
}
- SpigotTimings.timerEntityAI.stopTiming(); // Spigot
2019-04-24 01:00:24 +00:00
this.world.getMethodProfiler().exit();
this.world.getMethodProfiler().enter("jump");
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#2415) * fixup patch and rebuild * Updated Upstream (Bukkit/CraftBukkit/Spigot) Upstream has released updates that appears to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: bde198c9 SPIGOT-5246: PlayerQuitEvent.get/setQuitMessage() is incorrectly marked as NotNull 24ad5a79 SPIGOT-5240: Vector.angle not valid for angles very close to each other a143db9a SPIGOT-5231: ShotAtAngle API for Fireworks 10db5c3d SPIGOT-5226: Update Javadoc of PlayerDeathEvent CraftBukkit Changes: 1ec1b05e SPIGOT-5245: Unneeded cast to WorldNBTStorage in CraftWorld#getWorldFolder e5e8eec2 SPIGOT-5241: setAttributeModifiers does not work on untouched stack 803eaa31 SPIGOT-5231: ShotAtAngle API for Fireworks 7881d2ae SPIGOT-5237: Horses, pigs do not drop their inventory 06efc9ec Don't accept connections until all plugins have enabled da62a66a SPIGOT-5225: World handle isn't closed if world is unloaded without saving 104b3831 SPIGOT-5222: Cannot get Long values from Entity memory f0b3fe43 SPIGOT-5220: Server CPU usage reaches 100% when stdin is null Spigot Changes: e5b1b5db SPIGOT-5235: Destroy expired area effect clouds / fireworks that are inactive cbcc8e87 Make region files more reliable to write to 8887c5f4 Remove redundant late-bind option dac29063 Rebuild patches * Preserve old flush on save flag for reliable regionfiles Originally this patch was in paper * Fix some issues with the death event - Entities potentially entering a glitched state to the client where they appear to be falling over - Donkeys losing their chest if the event was cancelled (only an issue since the upstream merge) - Some wither death logic running for an entity killed by a wither
2019-08-05 16:35:40 +00:00
@@ -2483,9 +2476,7 @@ public abstract class EntityLiving extends Entity {
this.n();
AxisAlignedBB axisalignedbb = this.getBoundingBox();
- SpigotTimings.timerEntityAIMove.startTiming(); // Spigot
2019-04-24 01:00:24 +00:00
this.e(new Vec3D((double) this.bb, (double) this.bc, (double) this.bd));
- SpigotTimings.timerEntityAIMove.stopTiming(); // Spigot
2019-04-24 01:00:24 +00:00
this.world.getMethodProfiler().exit();
this.world.getMethodProfiler().enter("push");
if (this.bq > 0) {
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#2415) * fixup patch and rebuild * Updated Upstream (Bukkit/CraftBukkit/Spigot) Upstream has released updates that appears to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: bde198c9 SPIGOT-5246: PlayerQuitEvent.get/setQuitMessage() is incorrectly marked as NotNull 24ad5a79 SPIGOT-5240: Vector.angle not valid for angles very close to each other a143db9a SPIGOT-5231: ShotAtAngle API for Fireworks 10db5c3d SPIGOT-5226: Update Javadoc of PlayerDeathEvent CraftBukkit Changes: 1ec1b05e SPIGOT-5245: Unneeded cast to WorldNBTStorage in CraftWorld#getWorldFolder e5e8eec2 SPIGOT-5241: setAttributeModifiers does not work on untouched stack 803eaa31 SPIGOT-5231: ShotAtAngle API for Fireworks 7881d2ae SPIGOT-5237: Horses, pigs do not drop their inventory 06efc9ec Don't accept connections until all plugins have enabled da62a66a SPIGOT-5225: World handle isn't closed if world is unloaded without saving 104b3831 SPIGOT-5222: Cannot get Long values from Entity memory f0b3fe43 SPIGOT-5220: Server CPU usage reaches 100% when stdin is null Spigot Changes: e5b1b5db SPIGOT-5235: Destroy expired area effect clouds / fireworks that are inactive cbcc8e87 Make region files more reliable to write to 8887c5f4 Remove redundant late-bind option dac29063 Rebuild patches * Preserve old flush on save flag for reliable regionfiles Originally this patch was in paper * Fix some issues with the death event - Entities potentially entering a glitched state to the client where they appear to be falling over - Donkeys losing their chest if the event was cancelled (only an issue since the upstream merge) - Some wither death logic running for an entity killed by a wither
2019-08-05 16:35:40 +00:00
@@ -2493,9 +2484,7 @@ public abstract class EntityLiving extends Entity {
this.a(axisalignedbb, this.getBoundingBox());
}
2016-02-29 23:09:49 +00:00
- SpigotTimings.timerEntityAICollision.startTiming(); // Spigot
2019-04-24 01:00:24 +00:00
this.collideNearby();
2016-02-29 23:09:49 +00:00
- SpigotTimings.timerEntityAICollision.stopTiming(); // Spigot
2019-04-24 01:00:24 +00:00
this.world.getMethodProfiler().exit();
}
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index cec3794cd4..c76f262db9 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
2019-07-20 04:01:24 +00:00
@@ -63,7 +63,7 @@ import org.bukkit.craftbukkit.CraftServer;
2016-07-15 22:36:53 +00:00
import org.bukkit.craftbukkit.Main;
import org.bukkit.event.server.ServerLoadEvent;
// CraftBukkit end
2016-02-29 23:09:49 +00:00
-import org.bukkit.craftbukkit.SpigotTimings; // Spigot
+import co.aikar.timings.MinecraftTimings; // Paper
import org.spigotmc.SlackActivityAccountant; // Spigot
2019-04-24 01:00:24 +00:00
public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTask> implements IMojangStatistics, ICommandListener, AutoCloseable, Runnable {
@@ -128,8 +128,8 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
});
});
private long nextTick = SystemUtils.getMonotonicMillis();
- private long ab;
- private boolean ac;
+ private long ab; final long getTickOversleepMaxTime() { return this.ab; } // Paper - OBFHELPER
+ private boolean ac; final boolean hasExecutedTask() { return this.ac; } // Paper - OBFHELPER
private final IReloadableResourceManager ae;
private final ResourcePackRepository<ResourcePackLoader> resourcePackRepository;
@Nullable
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#2415) * fixup patch and rebuild * Updated Upstream (Bukkit/CraftBukkit/Spigot) Upstream has released updates that appears to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: bde198c9 SPIGOT-5246: PlayerQuitEvent.get/setQuitMessage() is incorrectly marked as NotNull 24ad5a79 SPIGOT-5240: Vector.angle not valid for angles very close to each other a143db9a SPIGOT-5231: ShotAtAngle API for Fireworks 10db5c3d SPIGOT-5226: Update Javadoc of PlayerDeathEvent CraftBukkit Changes: 1ec1b05e SPIGOT-5245: Unneeded cast to WorldNBTStorage in CraftWorld#getWorldFolder e5e8eec2 SPIGOT-5241: setAttributeModifiers does not work on untouched stack 803eaa31 SPIGOT-5231: ShotAtAngle API for Fireworks 7881d2ae SPIGOT-5237: Horses, pigs do not drop their inventory 06efc9ec Don't accept connections until all plugins have enabled da62a66a SPIGOT-5225: World handle isn't closed if world is unloaded without saving 104b3831 SPIGOT-5222: Cannot get Long values from Entity memory f0b3fe43 SPIGOT-5220: Server CPU usage reaches 100% when stdin is null Spigot Changes: e5b1b5db SPIGOT-5235: Destroy expired area effect clouds / fireworks that are inactive cbcc8e87 Make region files more reliable to write to 8887c5f4 Remove redundant late-bind option dac29063 Rebuild patches * Preserve old flush on save flag for reliable regionfiles Originally this patch was in paper * Fix some issues with the death event - Entities potentially entering a glitched state to the client where they appear to be falling over - Donkeys losing their chest if the event was cancelled (only an issue since the upstream merge) - Some wither death logic running for an entity killed by a wither
2019-08-05 16:35:40 +00:00
@@ -685,6 +685,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
2016-02-29 23:09:49 +00:00
}
// CraftBukkit end
2016-02-29 23:09:49 +00:00
MinecraftServer.LOGGER.info("Stopping server");
+ MinecraftTimings.stopServer(); // Paper
2016-03-03 09:46:26 +00:00
// CraftBukkit start
if (this.server != null) {
this.server.disablePlugins();
@@ -875,6 +876,16 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
return this.forceTicks || this.isEntered() || SystemUtils.getMonotonicMillis() < (this.ac ? this.ab : this.nextTick);
}
+ // Paper start
+ private boolean canOversleep() {
+ return this.hasExecutedTask() && SystemUtils.getMonotonicMillis() < this.getTickOversleepMaxTime();
+ }
+
+ private boolean canSleepForTickNoOversleep() {
+ return this.forceTicks || this.isEntered() || SystemUtils.getMonotonicMillis() < this.nextTick;
+ }
+ // Paper end
+
private void executeModerately() {
this.executeAll();
java.util.concurrent.locks.LockSupport.parkNanos("executing tasks", 1000L);
@@ -882,9 +893,9 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
// CraftBukkit end
protected void sleepForTick() {
- this.executeAll();
+ //this.executeAll(); // Paper - move this into the tick method for timings
this.awaitTasks(() -> {
- return !this.canSleepForTick();
+ return !this.canSleepForTickNoOversleep(); // Paper - move oversleep into full server tick
});
}
@@ -962,7 +973,14 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
2019-04-24 01:00:24 +00:00
protected void exit() {}
protected void a(BooleanSupplier booleansupplier) {
- SpigotTimings.serverTickTimer.startTiming(); // Spigot
2016-02-29 23:09:49 +00:00
+ co.aikar.timings.TimingsManager.FULL_SERVER_TICK.startTiming(); // Paper
+ // Paper start - move oversleep into full server tick
+ MinecraftTimings.serverOversleep.startTiming();
+ this.awaitTasks(() -> {
+ return !this.canOversleep();
+ });
+ MinecraftTimings.serverOversleep.stopTiming();
+ // Paper end
2017-01-31 04:33:54 +00:00
this.slackActivityAccountant.tickStarted(); // Spigot
long i = SystemUtils.getMonotonicNanos();
@@ -983,14 +1001,12 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
}
if (autosavePeriod > 0 && this.ticks % autosavePeriod == 0) { // CraftBukkit
- SpigotTimings.worldSaveTimer.startTiming(); // Spigot
2019-04-24 01:00:24 +00:00
MinecraftServer.LOGGER.debug("Autosave started");
this.methodProfiler.enter("save");
this.playerList.savePlayers();
2019-04-24 01:00:24 +00:00
this.saveChunks(true, false, false);
this.methodProfiler.exit();
2019-04-24 01:00:24 +00:00
MinecraftServer.LOGGER.debug("Autosave finished");
- SpigotTimings.worldSaveTimer.stopTiming(); // Spigot
}
this.methodProfiler.enter("snooper");
@@ -1013,30 +1029,34 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
this.methodProfiler.exit();
org.spigotmc.WatchdogThread.tick(); // Spigot
this.slackActivityAccountant.tickEnded(l); // Spigot
- SpigotTimings.serverTickTimer.stopTiming(); // Spigot
- org.spigotmc.CustomTimingsHandler.tick(); // Spigot
+ // Paper start - move executeAll() into full server tick timing
+ try (co.aikar.timings.Timing ignored = MinecraftTimings.processTasksTimer.startTiming()) {
+ this.executeAll();
+ }
+ // Paper end
2016-02-29 23:09:49 +00:00
+ co.aikar.timings.TimingsManager.FULL_SERVER_TICK.stopTiming(); // Paper
}
2019-04-24 01:00:24 +00:00
protected void b(BooleanSupplier booleansupplier) {
2016-06-30 05:38:53 +00:00
- SpigotTimings.schedulerTimer.startTiming(); // Spigot
2019-04-24 01:00:24 +00:00
+ MinecraftTimings.bukkitSchedulerTimer.startTiming(); // Spigot // Paper
2016-06-30 05:38:53 +00:00
this.server.getScheduler().mainThreadHeartbeat(this.ticks); // CraftBukkit
- SpigotTimings.schedulerTimer.stopTiming(); // Spigot
2019-04-24 01:00:24 +00:00
+ MinecraftTimings.bukkitSchedulerTimer.stopTiming(); // Spigot // Paper
this.methodProfiler.enter("commandFunctions");
- SpigotTimings.commandFunctionsTimer.startTiming(); // Spigot
2019-04-24 01:00:24 +00:00
+ MinecraftTimings.commandFunctionsTimer.startTiming(); // Spigot // Paper
this.getFunctionData().tick();
- SpigotTimings.commandFunctionsTimer.stopTiming(); // Spigot
2019-04-24 01:00:24 +00:00
+ MinecraftTimings.commandFunctionsTimer.stopTiming(); // Spigot // Paper
this.methodProfiler.exitEnter("levels");
Iterator iterator = this.getWorlds().iterator();
2016-02-24 04:35:34 +00:00
// CraftBukkit start
// Run tasks that are waiting on processing
- 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 01:00:24 +00:00
+ MinecraftTimings.timeUpdateTimer.startTiming(); // Spigot // Paper
// 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) {
@@ -1044,7 +1064,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
entityplayer.playerConnection.sendPacket(new PacketPlayOutUpdateTime(entityplayer.world.getTime(), entityplayer.getPlayerTime(), entityplayer.world.getGameRules().getBoolean(GameRules.DO_DAYLIGHT_CYCLE))); // Add support for per player time
}
}
- SpigotTimings.timeUpdateTimer.stopTiming(); // Spigot
2019-04-24 01:00:24 +00:00
+ MinecraftTimings.timeUpdateTimer.stopTiming(); // Spigot // Paper
while (iterator.hasNext()) {
WorldServer worldserver = (WorldServer) iterator.next();
@@ -1087,20 +1107,20 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
}
this.methodProfiler.exitEnter("connection");
- SpigotTimings.connectionTimer.startTiming(); // Spigot
+ MinecraftTimings.connectionTimer.startTiming(); // Spigot
this.getServerConnection().c();
- SpigotTimings.connectionTimer.stopTiming(); // Spigot
+ MinecraftTimings.connectionTimer.stopTiming(); // Spigot
this.methodProfiler.exitEnter("players");
- SpigotTimings.playerListTimer.startTiming(); // Spigot
+ MinecraftTimings.playerListTimer.startTiming(); // Spigot // Paper
this.playerList.tick();
- SpigotTimings.playerListTimer.stopTiming(); // Spigot
+ MinecraftTimings.playerListTimer.stopTiming(); // Spigot // Paper
2019-04-24 01:00:24 +00:00
this.methodProfiler.exitEnter("server gui refresh");
- SpigotTimings.tickablesTimer.startTiming(); // Spigot
+ MinecraftTimings.tickablesTimer.startTiming(); // Spigot // Paper
for (int i = 0; i < this.tickables.size(); ++i) {
((Runnable) this.tickables.get(i)).run();
}
- SpigotTimings.tickablesTimer.stopTiming(); // Spigot
+ MinecraftTimings.tickablesTimer.stopTiming(); // Spigot // Paper
this.methodProfiler.exit();
}
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
index e41d21f915..cf3d291af8 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,7 +1,9 @@
2016-06-05 04:10:50 +00:00
package net.minecraft.server;
+import co.aikar.timings.Timing; // Paper
2019-04-24 01:00:24 +00:00
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables;
+import com.google.common.collect.ComparisonChain; // Paper
import com.google.common.collect.Lists;
2019-05-27 23:01:45 +00:00
import com.google.common.collect.Queues;
2019-04-24 01:00:24 +00:00
import com.google.common.collect.Sets;
2019-07-20 04:01:24 +00:00
@@ -471,8 +473,11 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
private CompletableFuture<Either<IChunkAccess, PlayerChunk.Failure>> f(ChunkCoordIntPair chunkcoordintpair) {
return CompletableFuture.supplyAsync(() -> {
- try {
- NBTTagCompound nbttagcompound = this.readChunkData(chunkcoordintpair);
+ try (Timing ignored = this.world.timings.syncChunkLoadTimer.startTimingIfSync()) { // Paper
+ NBTTagCompound nbttagcompound; // Paper
+ try (Timing ignored2 = this.world.timings.chunkIOStage1.startTimingIfSync()) { // Paper
+ nbttagcompound = this.readChunkData(chunkcoordintpair);
+ }
if (nbttagcompound != null) {
boolean flag = nbttagcompound.hasKeyOfType("Level", 10) && nbttagcompound.getCompound("Level").hasKeyOfType("Status", 8);
2019-07-20 04:01:24 +00:00
@@ -509,7 +514,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
2019-05-27 23:01:45 +00:00
});
2017-01-31 04:33:54 +00:00
2019-05-27 23:01:45 +00: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) -> {
return this.c(playerchunk);
2019-07-20 04:01:24 +00:00
@@ -562,6 +567,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
ChunkStatus chunkstatus = PlayerChunk.getChunkStatus(playerchunk.getTicketLevel());
return !chunkstatus.b(ChunkStatus.FULL) ? PlayerChunk.UNLOADED_CHUNK_ACCESS : either.mapLeft((ichunkaccess) -> {
+ try (Timing ignored = world.timings.chunkIOStage2.startTimingIfSync()) { // Paper
ChunkCoordIntPair chunkcoordintpair = playerchunk.i();
Chunk chunk;
2019-07-20 04:01:24 +00:00
@@ -606,6 +612,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
}
return chunk;
+ } // Paper
});
}, (runnable) -> {
Mailbox mailbox = this.mailboxMain;
2019-07-20 04:01:24 +00:00
@@ -1042,6 +1049,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
2016-06-05 04:10:50 +00:00
2019-04-24 01:00:24 +00:00
PlayerChunkMap.EntityTracker playerchunkmap_entitytracker;
ObjectIterator objectiterator;
+ world.timings.tracker1.startTiming(); // Paper
2016-06-05 04:10:50 +00:00
2019-04-24 01:00:24 +00:00
for (objectiterator = this.trackedEntities.values().iterator(); objectiterator.hasNext(); playerchunkmap_entitytracker.trackerEntry.a()) {
playerchunkmap_entitytracker = (PlayerChunkMap.EntityTracker) objectiterator.next();
2019-07-20 04:01:24 +00:00
@@ -1059,13 +1067,16 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
2019-04-24 01:00:24 +00:00
playerchunkmap_entitytracker.e = sectionposition1;
2016-06-05 04:10:50 +00:00
}
}
2019-04-24 01:00:24 +00:00
+ world.timings.tracker1.stopTiming(); // Paper
2016-06-05 04:10:50 +00:00
2019-04-24 01:00:24 +00:00
objectiterator = this.trackedEntities.values().iterator();
2016-06-05 04:10:50 +00:00
2019-04-24 01:00:24 +00:00
+ world.timings.tracker2.startTiming(); // Paper
while (objectiterator.hasNext()) {
playerchunkmap_entitytracker = (PlayerChunkMap.EntityTracker) objectiterator.next();
playerchunkmap_entitytracker.track(list);
2019-05-06 20:45:02 +00:00
}
+ world.timings.tracker2.stopTiming(); // Paper
}
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
index 301b1c0829..36c56773f3 100644
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
2019-05-06 02:58:04 +00:00
@@ -58,6 +58,7 @@ import org.bukkit.inventory.CraftingInventory;
2016-03-04 21:20:13 +00:00
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.InventoryView;
import org.bukkit.util.NumberConversions;
+import co.aikar.timings.MinecraftTimings; // Paper
// CraftBukkit end
2019-04-24 01:00:24 +00:00
public class PlayerConnection implements PacketListenerPlayIn {
2019-05-06 02:58:04 +00:00
@@ -135,7 +136,6 @@ public class PlayerConnection implements PacketListenerPlayIn {
2018-10-28 22:08:08 +00:00
// CraftBukkit end
public void tick() {
2018-10-28 22:08:08 +00: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 02:58:04 +00:00
@@ -208,7 +208,6 @@ public class PlayerConnection implements PacketListenerPlayIn {
2018-10-28 22:08:08 +00: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-07-20 04:01:24 +00:00
@@ -1622,7 +1621,7 @@ public class PlayerConnection implements PacketListenerPlayIn {
// CraftBukkit end
2017-05-14 18:05:01 +00:00
private void handleCommand(String s) {
- org.bukkit.craftbukkit.SpigotTimings.playerCommandTimer.startTiming(); // Spigot
2017-05-14 18:05:01 +00:00
+ MinecraftTimings.playerCommandTimer.startTiming(); // Paper
// CraftBukkit start - whole method
if ( org.spigotmc.SpigotConfig.logCommands ) // Spigot
2016-02-29 23:09:49 +00:00
this.LOGGER.info(this.player.getName() + " issued server command: " + s);
2019-07-20 04:01:24 +00:00
@@ -1633,7 +1632,7 @@ public class PlayerConnection implements PacketListenerPlayIn {
this.server.getPluginManager().callEvent(event);
if (event.isCancelled()) {
- org.bukkit.craftbukkit.SpigotTimings.playerCommandTimer.stopTiming(); // Spigot
+ MinecraftTimings.playerCommandTimer.stopTiming(); // Paper
return;
}
2019-07-20 04:01:24 +00:00
@@ -1646,7 +1645,7 @@ public class PlayerConnection implements PacketListenerPlayIn {
java.util.logging.Logger.getLogger(PlayerConnection.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
return;
} finally {
- org.bukkit.craftbukkit.SpigotTimings.playerCommandTimer.stopTiming(); // Spigot
+ MinecraftTimings.playerCommandTimer.stopTiming(); // Paper
}
// this.minecraftServer.getCommandDispatcher().a(this.player.getCommandListener(), s);
// CraftBukkit end
diff --git a/src/main/java/net/minecraft/server/PlayerConnectionUtils.java b/src/main/java/net/minecraft/server/PlayerConnectionUtils.java
index a677ec74d4..e928525b8f 100644
--- a/src/main/java/net/minecraft/server/PlayerConnectionUtils.java
+++ b/src/main/java/net/minecraft/server/PlayerConnectionUtils.java
2019-07-20 04:01:24 +00:00
@@ -2,6 +2,8 @@ package net.minecraft.server;
2019-07-20 04:01:24 +00:00
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
+import co.aikar.timings.MinecraftTimings; // Paper
+import co.aikar.timings.Timing; // Paper
2019-07-20 04:01:24 +00:00
public class PlayerConnectionUtils {
Updated Upstream (Bukkit/CraftBukkit/Spigot) Upstream has released updates that appears to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Warning: this commit contains more mapping changes from upstream, As always, ensure that you have working backups and test this build before deployment; Developers working on paper will, yet again, need to delete their work/Minecraft/1.13.2 folder Bukkit Changes: 7fca5fd4 SPIGOT-4558: Preserve user order in the face of copied defaults in configurations 15c9b1eb Ignore spurious slot IDs sent by client, e.g. in enchanting tables 5d2a10c5 SPIGOT-3747: Add API for force loaded chunks d6dd2bb3 SPIGOT-3538: Add getHitBlockFace for ProjectileHitEvent 771db4aa SPIGOT-794: Call EntityPlaceEvent for Minecart placement 55462509 Add InventoryView#getSlotType 2f3ce5b6 Remove EntityTransformEvent and CustomItemTagContainer from draft API f04ad7b6 Make ProjectileLaunchEvent extend EntitySpawnEvent ccb85808 Define EntitySpawnEvent b8cc3ebe Add PlayerItemDamageEvent 184a495d Ease ClassLoader Deadlocks Where Possible 11ac4728 Expand Boolean Prompt Values in Conversation API aae62d51 Added getAllSessionData() to the Conversation API. 9290ff91 Add InventoryView#getInventory API 995e530f Add API to get / set base arrow damage CraftBukkit Changes: c4a67eed SPIGOT-4556: Fix plugins closing inventory during drop events 5be2ddcb Replace version constants with methods to prevent compiler inlining a5b9c7b3 Use API method to create offset command completions 2bc7d1df SPIGOT-3747: Add API for force loaded chunks a408f375 SPIGOT-3538: Add getHitBlockFace for ProjectileHitEvent b54b9409 SPIGOT-2864: Make Arrow / Item setTicksLived behave like FallingBlock 79ded7a8 SPIGOT-1811: Death message not shown on respawn screen b4a4f15d SPIGOT-943: InventoryCloseEvent called on death regardless of open inventory 0afed592 SPIGOT-794: Call EntityPlaceEvent for Minecart placement 2b2d084a Add InventoryView#getSlotType 01a9959a Do not use deprecated ItemSpawnEvent constructor 9642498d SPIGOT-4547: Call EntitySpawnEvent as general spawn fallback event 963f4a5f Add PlayerItemDamageEvent 63db0445 Add API to get / set base arrow damage 531c25d7 Add CraftMagicNumbers.MAPPINGS_VERSION for use by NMS plugins d05c8b14 Mappings Update bd36e200 SPIGOT-4551: Ignore invalid attribute modifier slots Spigot Changes: 518206a1 Remove redundant trove depend 1959ad21 MC-11211,SPIGOT-4552: Fix placing double slabs at y = 255 29ab5e43 SPIGOT-3661: Allow arguments in restart-script 7cc46316 SPIGOT-852: Growth modifiers for beetroots, potatoes, carrots 82e117e1 Squelch "fatal: Resolve operation not in progress" message 0a1a68e7 Mappings Update & Patch Rebuild
2019-01-01 03:15:55 +00:00
2019-07-20 04:01:24 +00:00
@@ -13,10 +15,13 @@ public class PlayerConnectionUtils {
2019-04-24 01:00:24 +00:00
public static <T extends PacketListener> void ensureMainThread(Packet<T> packet, T t0, IAsyncTaskHandler<?> iasynctaskhandler) throws CancelledPacketHandleException {
if (!iasynctaskhandler.isMainThread()) {
2019-07-20 04:01:24 +00:00
+ Timing timing = MinecraftTimings.getPacketTiming(packet); // Paper - timings
2019-04-24 01:00:24 +00:00
iasynctaskhandler.execute(() -> {
2019-05-06 02:58:04 +00:00
if (MinecraftServer.getServer().hasStopped() || (t0 instanceof PlayerConnection && ((PlayerConnection) t0).processedDisconnect)) return; // CraftBukkit, MC-142590
2019-07-20 04:01:24 +00:00
if (t0.a().isConnected()) {
+ try (Timing ignored = timing.startTiming()) { // Paper - timings
packet.a(t0);
+ } // Paper - timings
} else {
PlayerConnectionUtils.LOGGER.debug("Ignoring packet due to disconnection: " + packet);
}
diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java
index ee22d6c81a..fb6b48e3fe 100644
--- 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 02:20:58 +00:00
@@ -895,10 +896,11 @@ public abstract class PlayerList {
}
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
}
public WhiteList getWhitelist() {
diff --git a/src/main/java/net/minecraft/server/TickListServer.java b/src/main/java/net/minecraft/server/TickListServer.java
index 00bbd34b6a..f533860bbe 100644
--- a/src/main/java/net/minecraft/server/TickListServer.java
+++ b/src/main/java/net/minecraft/server/TickListServer.java
2019-05-27 23:01:45 +00:00
@@ -28,13 +28,18 @@ public class TickListServer<T> implements TickList<T> {
private final List<NextTickListEntry<T>> h = Lists.newArrayList();
private final Consumer<NextTickListEntry<T>> i;
- 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-27 23:01:45 +00:00
this.f = worldserver;
this.i = consumer;
+ this.timingCleanup = co.aikar.timings.WorldTimingsHandler.getTickList(worldserver, timingsType + " - Cleanup");
+ this.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
2019-07-20 04:01:24 +00:00
public void b() {
2019-05-27 23:01:45 +00:00
int i = this.nextTickList.size();
@@ -57,6 +62,7 @@ public class TickListServer<T> implements TickList<T> {
2019-05-27 23:01:45 +00:00
this.f.getMethodProfiler().enter("cleaning");
+ this.timingCleanup.startTiming(); // Paper
2019-05-14 02:20:58 +00:00
NextTickListEntry nextticklistentry;
2019-05-27 23:01:45 +00:00
while (i > 0 && iterator.hasNext()) {
@@ -72,7 +78,9 @@ public class TickListServer<T> implements TickList<T> {
2019-05-14 02:20:58 +00:00
--i;
}
}
2019-05-27 23:01:45 +00:00
+ this.timingCleanup.stopTiming(); // Paper
+ this.timingTicking.startTiming(); // Paper
this.f.getMethodProfiler().exitEnter("ticking");
2019-05-27 23:01:45 +00:00
while ((nextticklistentry = (NextTickListEntry) this.g.poll()) != null) {
@@ -93,6 +101,7 @@ public class TickListServer<T> implements TickList<T> {
}
2019-05-27 23:01:45 +00:00
this.f.getMethodProfiler().exit();
+ this.timingTicking.stopTiming(); // Paper
this.h.clear();
this.g.clear();
}
diff --git a/src/main/java/net/minecraft/server/TileEntity.java b/src/main/java/net/minecraft/server/TileEntity.java
index 2efaf516ff..22a8ea916a 100644
--- a/src/main/java/net/minecraft/server/TileEntity.java
+++ b/src/main/java/net/minecraft/server/TileEntity.java
2019-05-14 02:20:58 +00:00
@@ -9,11 +9,12 @@ import org.bukkit.craftbukkit.persistence.CraftPersistentDataContainer;
2019-05-06 02:58:04 +00:00
import org.bukkit.craftbukkit.persistence.CraftPersistentDataTypeRegistry;
import org.bukkit.inventory.InventoryHolder;
// CraftBukkit end
-import org.spigotmc.CustomTimingsHandler; // Spigot
+import co.aikar.timings.MinecraftTimings; // Paper
2016-02-29 23:09:49 +00:00
+import co.aikar.timings.Timing; // Paper
public abstract class TileEntity implements KeyedObject { // Paper
- public CustomTimingsHandler tickTimer = org.bukkit.craftbukkit.SpigotTimings.getTileEntityTimings(this); // Spigot
+ public Timing tickTimer = MinecraftTimings.getTileEntityTimings(this); // Paper
2019-05-06 02:58:04 +00:00
// CraftBukkit start - data containers
private static final CraftPersistentDataTypeRegistry DATA_TYPE_REGISTRY = new CraftPersistentDataTypeRegistry();
public CraftPersistentDataContainer persistentDataContainer;
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
index a71d7a80c2..67cfcdd602 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
2019-04-24 01:00:24 +00:00
@@ -1,5 +1,7 @@
package net.minecraft.server;
2019-04-24 01:00:24 +00:00
+import co.aikar.timings.Timing;
+import co.aikar.timings.Timings;
import com.google.common.collect.Lists;
2019-04-24 01:00:24 +00:00
import java.io.IOException;
import java.util.Collection;
@@ -20,7 +22,6 @@ import java.util.ArrayList;
2016-02-29 23:09:49 +00:00
import java.util.Map;
import org.bukkit.Bukkit;
import org.bukkit.block.BlockState;
2016-02-29 23:09:49 +00:00
-import org.bukkit.craftbukkit.SpigotTimings; // Spigot
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.craftbukkit.block.CraftBlockState;
2019-04-24 01:00:24 +00:00
@@ -88,7 +89,7 @@ public abstract class World implements IIBlockAccess, GeneratorAccess, AutoClose
2016-02-29 23:09:49 +00:00
public final com.destroystokyo.paper.PaperWorldConfig paperConfig; // Paper
- public final SpigotTimings.WorldTimingsHandler timings; // Spigot
2016-02-29 23:09:49 +00:00
+ public final co.aikar.timings.WorldTimingsHandler timings; // Paper
public static BlockPosition lastPhysicsProblem; // Spigot
private org.spigotmc.TickLimiter entityLimiter;
2019-04-24 01:00:24 +00: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 04:59:37 +00:00
});
2016-03-03 09:46:26 +00:00
// 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
2019-04-24 01:00:24 +00:00
this.entityLimiter = new org.spigotmc.TickLimiter(spigotConfig.entityMaxTickTime);
this.tileLimiter = new org.spigotmc.TickLimiter(spigotConfig.tileMaxTickTime);
}
@@ -773,15 +774,14 @@ public abstract class World implements IIBlockAccess, GeneratorAccess, AutoClose
}
timings.tileEntityPending.stopTiming(); // Spigot
2016-02-29 23:09:49 +00:00
+ co.aikar.timings.TimingHistory.tileEntityTicks += this.tileEntityListTick.size(); // Paper
2019-04-24 01:00:24 +00:00
gameprofilerfiller.exit();
spigotConfig.currentPrimedTnt = 0; // Spigot
}
2018-04-22 14:40:36 +00:00
2019-04-24 01:00:24 +00:00
public void a(Consumer<Entity> consumer, Entity entity) {
try {
2019-05-14 02:20:58 +00:00
- SpigotTimings.tickEntityTimer.startTiming(); // Spigot
2019-04-24 01:00:24 +00:00
consumer.accept(entity);
2019-05-14 02:20:58 +00:00
- SpigotTimings.tickEntityTimer.stopTiming(); // Spigot
} catch (Throwable throwable) {
CrashReport crashreport = CrashReport.a(throwable, "Ticking entity");
CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Entity being ticked");
diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
index f4cefa00fa..ef9abdc28d 100644
--- a/src/main/java/net/minecraft/server/WorldServer.java
+++ b/src/main/java/net/minecraft/server/WorldServer.java
2019-04-24 01:00:24 +00:00
@@ -1,5 +1,7 @@
package net.minecraft.server;
2019-04-24 01:00:24 +00:00
+import co.aikar.timings.TimingHistory;
+import co.aikar.timings.Timings;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
2019-04-24 01:00:24 +00:00
import com.google.common.collect.Queues;
@@ -38,7 +40,6 @@ import org.apache.logging.log4j.Logger;
import java.util.logging.Level;
2019-05-14 02:20:58 +00:00
import org.bukkit.Bukkit;
2019-04-24 01:00:24 +00:00
import org.bukkit.WeatherType;
-import org.bukkit.craftbukkit.SpigotTimings; // Spigot
import org.bukkit.craftbukkit.event.CraftEventFactory;
2019-05-14 02:20:58 +00:00
import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.event.server.MapInitializeEvent;
@@ -94,10 +95,10 @@ public class WorldServer extends World {
Updated Upstream (Bukkit/CraftBukkit/Spigot) Upstream has released updates that appears to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Warning: this commit contains more mapping changes from upstream, As always, ensure that you have working backups and test this build before deployment; Developers working on paper will, yet again, need to delete their work/Minecraft/1.13.2 folder Bukkit Changes: 7fca5fd4 SPIGOT-4558: Preserve user order in the face of copied defaults in configurations 15c9b1eb Ignore spurious slot IDs sent by client, e.g. in enchanting tables 5d2a10c5 SPIGOT-3747: Add API for force loaded chunks d6dd2bb3 SPIGOT-3538: Add getHitBlockFace for ProjectileHitEvent 771db4aa SPIGOT-794: Call EntityPlaceEvent for Minecart placement 55462509 Add InventoryView#getSlotType 2f3ce5b6 Remove EntityTransformEvent and CustomItemTagContainer from draft API f04ad7b6 Make ProjectileLaunchEvent extend EntitySpawnEvent ccb85808 Define EntitySpawnEvent b8cc3ebe Add PlayerItemDamageEvent 184a495d Ease ClassLoader Deadlocks Where Possible 11ac4728 Expand Boolean Prompt Values in Conversation API aae62d51 Added getAllSessionData() to the Conversation API. 9290ff91 Add InventoryView#getInventory API 995e530f Add API to get / set base arrow damage CraftBukkit Changes: c4a67eed SPIGOT-4556: Fix plugins closing inventory during drop events 5be2ddcb Replace version constants with methods to prevent compiler inlining a5b9c7b3 Use API method to create offset command completions 2bc7d1df SPIGOT-3747: Add API for force loaded chunks a408f375 SPIGOT-3538: Add getHitBlockFace for ProjectileHitEvent b54b9409 SPIGOT-2864: Make Arrow / Item setTicksLived behave like FallingBlock 79ded7a8 SPIGOT-1811: Death message not shown on respawn screen b4a4f15d SPIGOT-943: InventoryCloseEvent called on death regardless of open inventory 0afed592 SPIGOT-794: Call EntityPlaceEvent for Minecart placement 2b2d084a Add InventoryView#getSlotType 01a9959a Do not use deprecated ItemSpawnEvent constructor 9642498d SPIGOT-4547: Call EntitySpawnEvent as general spawn fallback event 963f4a5f Add PlayerItemDamageEvent 63db0445 Add API to get / set base arrow damage 531c25d7 Add CraftMagicNumbers.MAPPINGS_VERSION for use by NMS plugins d05c8b14 Mappings Update bd36e200 SPIGOT-4551: Ignore invalid attribute modifier slots Spigot Changes: 518206a1 Remove redundant trove depend 1959ad21 MC-11211,SPIGOT-4552: Fix placing double slabs at y = 255 29ab5e43 SPIGOT-3661: Allow arguments in restart-script 7cc46316 SPIGOT-852: Growth modifiers for beetroots, potatoes, carrots 82e117e1 Squelch "fatal: Resolve operation not in progress" message 0a1a68e7 Mappings Update & Patch Rebuild
2019-01-01 03:15:55 +00:00
// CraftBukkit end
this.nextTickListBlock = new TickListServer<>(this, (block) -> {
return block == null || block.getBlockData().isAir();
2019-04-24 01:00:24 +00:00
- }, IRegistry.BLOCK::getKey, IRegistry.BLOCK::get, this::b);
+ }, IRegistry.BLOCK::getKey, IRegistry.BLOCK::get, this::b, "Blocks"); // Paper - Timings
Updated Upstream (Bukkit/CraftBukkit/Spigot) Upstream has released updates that appears to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Warning: this commit contains more mapping changes from upstream, As always, ensure that you have working backups and test this build before deployment; Developers working on paper will, yet again, need to delete their work/Minecraft/1.13.2 folder Bukkit Changes: 7fca5fd4 SPIGOT-4558: Preserve user order in the face of copied defaults in configurations 15c9b1eb Ignore spurious slot IDs sent by client, e.g. in enchanting tables 5d2a10c5 SPIGOT-3747: Add API for force loaded chunks d6dd2bb3 SPIGOT-3538: Add getHitBlockFace for ProjectileHitEvent 771db4aa SPIGOT-794: Call EntityPlaceEvent for Minecart placement 55462509 Add InventoryView#getSlotType 2f3ce5b6 Remove EntityTransformEvent and CustomItemTagContainer from draft API f04ad7b6 Make ProjectileLaunchEvent extend EntitySpawnEvent ccb85808 Define EntitySpawnEvent b8cc3ebe Add PlayerItemDamageEvent 184a495d Ease ClassLoader Deadlocks Where Possible 11ac4728 Expand Boolean Prompt Values in Conversation API aae62d51 Added getAllSessionData() to the Conversation API. 9290ff91 Add InventoryView#getInventory API 995e530f Add API to get / set base arrow damage CraftBukkit Changes: c4a67eed SPIGOT-4556: Fix plugins closing inventory during drop events 5be2ddcb Replace version constants with methods to prevent compiler inlining a5b9c7b3 Use API method to create offset command completions 2bc7d1df SPIGOT-3747: Add API for force loaded chunks a408f375 SPIGOT-3538: Add getHitBlockFace for ProjectileHitEvent b54b9409 SPIGOT-2864: Make Arrow / Item setTicksLived behave like FallingBlock 79ded7a8 SPIGOT-1811: Death message not shown on respawn screen b4a4f15d SPIGOT-943: InventoryCloseEvent called on death regardless of open inventory 0afed592 SPIGOT-794: Call EntityPlaceEvent for Minecart placement 2b2d084a Add InventoryView#getSlotType 01a9959a Do not use deprecated ItemSpawnEvent constructor 9642498d SPIGOT-4547: Call EntitySpawnEvent as general spawn fallback event 963f4a5f Add PlayerItemDamageEvent 63db0445 Add API to get / set base arrow damage 531c25d7 Add CraftMagicNumbers.MAPPINGS_VERSION for use by NMS plugins d05c8b14 Mappings Update bd36e200 SPIGOT-4551: Ignore invalid attribute modifier slots Spigot Changes: 518206a1 Remove redundant trove depend 1959ad21 MC-11211,SPIGOT-4552: Fix placing double slabs at y = 255 29ab5e43 SPIGOT-3661: Allow arguments in restart-script 7cc46316 SPIGOT-852: Growth modifiers for beetroots, potatoes, carrots 82e117e1 Squelch "fatal: Resolve operation not in progress" message 0a1a68e7 Mappings Update & Patch Rebuild
2019-01-01 03:15:55 +00:00
this.nextTickListFluid = new TickListServer<>(this, (fluidtype) -> {
return fluidtype == null || fluidtype == FluidTypes.EMPTY;
2019-04-24 01:00:24 +00:00
- }, IRegistry.FLUID::getKey, IRegistry.FLUID::get, this::a);
+ }, IRegistry.FLUID::getKey, IRegistry.FLUID::get, this::a, "Fluids"); // Paper - Timings
2019-07-20 04:01:24 +00:00
this.H = Sets.newHashSet();
this.I = new ObjectLinkedOpenHashSet();
this.dataManager = worldnbtstorage;
@@ -291,24 +292,28 @@ public class WorldServer extends World {
this.M();
this.a();
gameprofilerfiller.exitEnter("chunkSource");
+ this.timings.chunkProviderTick.startTiming(); // Paper - timings
this.getChunkProvider().tick(booleansupplier);
+ this.timings.chunkProviderTick.stopTiming(); // Paper - timings
gameprofilerfiller.exitEnter("tickPending");
- timings.doTickPending.startTiming(); // Spigot
+ timings.scheduledBlocks.startTiming(); // Spigot
if (this.worldData.getType() != WorldType.DEBUG_ALL_BLOCK_STATES) {
2019-07-20 04:01:24 +00:00
this.nextTickListBlock.b();
this.nextTickListFluid.b();
}
- timings.doTickPending.stopTiming(); // Spigot
+ timings.scheduledBlocks.stopTiming(); // Spigot
2019-07-20 04:01:24 +00:00
gameprofilerfiller.exitEnter("portalForcer");
timings.doPortalForcer.startTiming(); // Spigot
this.portalTravelAgent.a(this.getTime());
timings.doPortalForcer.stopTiming(); // Spigot
gameprofilerfiller.exitEnter("raid");
+ this.timings.raids.startTiming(); // Paper - timings
this.c.a();
if (this.mobSpawnerTrader != null) {
this.mobSpawnerTrader.a();
}
+ this.timings.raids.stopTiming(); // Paper - timings
gameprofilerfiller.exitEnter("blockEvents");
timings.doSounds.startTiming(); // Spigot
@@ -351,6 +356,7 @@ public class WorldServer extends World {
2019-04-24 01:00:24 +00: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();
@@ -377,6 +383,7 @@ public class WorldServer extends World {
gameprofilerfiller.enter("tick");
if (!entity1.dead && !(entity1 instanceof EntityComplexPart)) {
this.a(this::entityJoinedWorld, entity1);
+ ++TimingHistory.entityTicks; // Paper
}
gameprofilerfiller.exit();
@@ -393,9 +400,11 @@ public class WorldServer extends World {
this.tickingEntities = false;
+ try (co.aikar.timings.Timing ignored = this.timings.newEntities.startTiming()) { // Paper - timings
while ((entity = (Entity) this.entitiesToAdd.poll()) != null) {
this.registerEntity(entity);
}
+ } // Paper - timings
gameprofilerfiller.exit();
timings.tickEntities.stopTiming(); // Spigot
@@ -454,6 +463,7 @@ public class WorldServer extends World {
2019-04-24 01:00:24 +00:00
}
2019-04-24 01:00:24 +00:00
gameprofilerfiller.exitEnter("tickBlocks");
+ timings.chunkTicksBlocks.startTiming(); // Paper
if (i > 0) {
ChunkSection[] achunksection = chunk.getSections();
int l = achunksection.length;
@@ -485,7 +495,7 @@ public class WorldServer extends World {
}
}
2019-04-24 01:00:24 +00:00
}
-
+ timings.chunkTicksBlocks.stopTiming(); // Paper
gameprofilerfiller.exit();
}
@@ -780,6 +790,7 @@ public class WorldServer extends World {
2019-04-24 01:00:24 +00:00
if (!flag1) {
org.bukkit.Bukkit.getPluginManager().callEvent(new org.bukkit.event.world.WorldSaveEvent(getWorld())); // CraftBukkit
+ try (co.aikar.timings.Timing ignored = timings.worldSave.startTiming()) { // Paper
if (iprogressupdate != null) {
iprogressupdate.a(new ChatMessage("menu.savingLevel", new Object[0]));
}
@@ -789,7 +800,10 @@ public class WorldServer extends World {
iprogressupdate.c(new ChatMessage("menu.savingChunks", new Object[0]));
}
+ timings.worldSaveChunks.startTiming(); // Paper
2019-04-24 01:00:24 +00:00
chunkproviderserver.save(flag);
+ timings.worldSaveChunks.stopTiming(); // Paper
2019-04-24 01:00:24 +00:00
+ } // Paper
}
// CraftBukkit start - moved from MinecraftServer.saveChunks
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index dce5bde54f..a59f61e73a 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#2415) * fixup patch and rebuild * Updated Upstream (Bukkit/CraftBukkit/Spigot) Upstream has released updates that appears to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: bde198c9 SPIGOT-5246: PlayerQuitEvent.get/setQuitMessage() is incorrectly marked as NotNull 24ad5a79 SPIGOT-5240: Vector.angle not valid for angles very close to each other a143db9a SPIGOT-5231: ShotAtAngle API for Fireworks 10db5c3d SPIGOT-5226: Update Javadoc of PlayerDeathEvent CraftBukkit Changes: 1ec1b05e SPIGOT-5245: Unneeded cast to WorldNBTStorage in CraftWorld#getWorldFolder e5e8eec2 SPIGOT-5241: setAttributeModifiers does not work on untouched stack 803eaa31 SPIGOT-5231: ShotAtAngle API for Fireworks 7881d2ae SPIGOT-5237: Horses, pigs do not drop their inventory 06efc9ec Don't accept connections until all plugins have enabled da62a66a SPIGOT-5225: World handle isn't closed if world is unloaded without saving 104b3831 SPIGOT-5222: Cannot get Long values from Entity memory f0b3fe43 SPIGOT-5220: Server CPU usage reaches 100% when stdin is null Spigot Changes: e5b1b5db SPIGOT-5235: Destroy expired area effect clouds / fireworks that are inactive cbcc8e87 Make region files more reliable to write to 8887c5f4 Remove redundant late-bind option dac29063 Rebuild patches * Preserve old flush on save flag for reliable regionfiles Originally this patch was in paper * Fix some issues with the death event - Entities potentially entering a glitched state to the client where they appear to be falling over - Donkeys losing their chest if the event was cancelled (only an issue since the upstream merge) - Some wither death logic running for an entity killed by a wither
2019-08-05 16:35:40 +00:00
@@ -1932,12 +1932,31 @@ public final class CraftServer implements Server {
2016-02-29 23:09:49 +00:00
private final Spigot spigot = new Spigot()
{
+ @Deprecated
@Override
public YamlConfiguration getConfig()
{
return org.spigotmc.SpigotConfig.config;
2016-02-29 23:09:49 +00:00
}
+ @Override
+ 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-02-29 23:09:49 +00:00
+ return com.destroystokyo.paper.PaperConfig.config;
+ }
+
@Override
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
index b98a7b56a4..0000000000
--- a/src/main/java/org/bukkit/craftbukkit/SpigotTimings.java
+++ /dev/null
2019-07-20 04:01:24 +00:00
@@ -1,164 +0,0 @@
-package org.bukkit.craftbukkit;
-
-import java.util.HashMap;
2019-04-24 01:00:24 +00:00
-import net.minecraft.server.Entity;
-import net.minecraft.server.TileEntity;
-import net.minecraft.server.World;
-import org.bukkit.craftbukkit.scheduler.CraftTask;
2019-04-24 01:00:24 +00:00
-import org.bukkit.plugin.java.JavaPluginLoader;
-import org.bukkit.scheduler.BukkitTask;
-import org.spigotmc.CustomTimingsHandler;
-
-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");
- public static final CustomTimingsHandler connectionTimer = new CustomTimingsHandler("Connection Handler");
2018-10-28 22:08:08 +00:00
- public static final CustomTimingsHandler playerConnectionTimer = new CustomTimingsHandler("** PlayerConnection");
- 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 15:19:21 +00:00
- String entityType = entity.getClass().getName();
- CustomTimingsHandler result = entityTypeTimingMap.get(entityType);
- if (result == null) {
2017-10-29 15:19:21 +00:00
- result = new CustomTimingsHandler("** tickEntity - " + entity.getClass().getSimpleName(), activatedEntityTimer);
- entityTypeTimingMap.put(entityType, result);
- }
- return result;
- }
-
- /**
- * Get a named timer for the specified tile entity type to track type specific timings.
- * @param entity
- * @return
- */
- public static CustomTimingsHandler getTileEntityTimings(TileEntity entity) {
2017-10-29 15:19:21 +00:00
- String entityType = entity.getClass().getName();
- CustomTimingsHandler result = tileEntityTypeTimingMap.get(entityType);
- if (result == null) {
2017-10-29 15:19:21 +00:00
- result = new CustomTimingsHandler("** tickTileEntity - " + entity.getClass().getSimpleName(), tickTileEntityTimer);
- tileEntityTypeTimingMap.put(entityType, result);
- }
- return result;
- }
-
- /**
- * Set of timers per world, to track world specific timings.
- */
- public static class WorldTimingsHandler {
- public final CustomTimingsHandler mobSpawn;
- public final CustomTimingsHandler doChunkUnload;
- public final CustomTimingsHandler doPortalForcer;
- public final CustomTimingsHandler doTickPending;
- public final CustomTimingsHandler doTickTiles;
- public final CustomTimingsHandler 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");
- 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
index e434738cb1..9f5080b233 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -1749,6 +1749,14 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
2016-02-29 23:09:49 +00:00
packet.components = components;
getHandle().playerConnection.sendPacket(packet);
}
+
+ // Paper start
+ @Override
+ public int getPing()
+ {
+ return getHandle().ping;
+ }
+ // Paper end
};
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
index b90979c7ba..8823f94f7b 100644
--- a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java
+++ b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java
2019-04-24 01:00:24 +00:00
@@ -1,5 +1,6 @@
package org.bukkit.craftbukkit.scheduler;
+import co.aikar.timings.MinecraftTimings; // Paper
2019-04-24 01:00:24 +00:00
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import java.util.ArrayList;
import java.util.Comparator;
2019-05-06 02:58:04 +00:00
@@ -248,7 +249,7 @@ public class CraftScheduler implements BukkitScheduler {
}
}
return false;
- }});
+ }}){{this.timings=co.aikar.timings.MinecraftTimings.getCancelTasksTimer();}}; // Paper
2018-03-31 09:34:25 +00:00
handle(task, 0L);
for (CraftTask taskPending = head.getNext(); taskPending != null; taskPending = taskPending.getNext()) {
if (taskPending == task) {
2019-05-06 02:58:04 +00:00
@@ -283,7 +284,7 @@ public class CraftScheduler implements BukkitScheduler {
}
}
}
- });
+ }){{this.timings=co.aikar.timings.MinecraftTimings.getCancelTasksTimer(plugin);}}; // Paper
2018-03-31 09:34:25 +00:00
handle(task, 0L);
for (CraftTask taskPending = head.getNext(); taskPending != null; taskPending = taskPending.getNext()) {
if (taskPending == task) {
2019-05-06 02:58:04 +00:00
@@ -390,9 +391,7 @@ public class CraftScheduler implements BukkitScheduler {
if (task.isSync()) {
2018-06-21 03:29:33 +00:00
currentTask = task;
try {
- task.timings.startTiming(); // Spigot
task.run();
- task.timings.stopTiming(); // Spigot
} catch (final Throwable throwable) {
task.getOwner().getLogger().log(
Level.WARNING,
2019-05-06 02:58:04 +00:00
@@ -419,8 +418,10 @@ public class CraftScheduler implements BukkitScheduler {
runners.remove(task.getTaskId());
}
}
+ MinecraftTimings.bukkitSchedulerFinishTimer.startTiming();
pending.addAll(temp);
temp.clear();
+ MinecraftTimings.bukkitSchedulerFinishTimer.stopTiming();
debugHead = debugHead.getNextHead(currentTick);
}
2019-05-06 02:58:04 +00:00
@@ -453,6 +454,7 @@ public class CraftScheduler implements BukkitScheduler {
}
private void parsePending() {
+ MinecraftTimings.bukkitSchedulerPendingTimer.startTiming();
CraftTask head = this.head;
CraftTask task = head.getNext();
CraftTask lastTask = head;
2019-05-06 02:58:04 +00:00
@@ -471,6 +473,7 @@ public class CraftScheduler implements BukkitScheduler {
task.setNext(null);
}
this.head = lastTask;
+ MinecraftTimings.bukkitSchedulerPendingTimer.stopTiming();
}
private boolean isReady(final int currentTick) {
diff --git a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftTask.java b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftTask.java
index 3f55381c15..0d9a466809 100644
--- a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftTask.java
+++ b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftTask.java
@@ -1,9 +1,11 @@
package org.bukkit.craftbukkit.scheduler;
import java.util.function.Consumer;
+
+import co.aikar.timings.NullTimingHandler;
import org.bukkit.Bukkit;
-import org.bukkit.craftbukkit.SpigotTimings; // Spigot
-import org.spigotmc.CustomTimingsHandler; // Spigot
+import co.aikar.timings.MinecraftTimings; // Paper
2016-02-29 23:09:49 +00:00
+import co.aikar.timings.Timing; // Paper
import org.bukkit.plugin.Plugin;
import org.bukkit.scheduler.BukkitTask;
@@ -26,12 +28,12 @@ public class CraftTask implements BukkitTask, Runnable { // Spigot
*/
private volatile long period;
private long nextRun;
- private final Runnable rTask;
- private final Consumer<BukkitTask> cTask;
+ public final Runnable rTask; // Paper
+ public final Consumer<BukkitTask> cTask; // Paper
2016-02-29 23:09:49 +00:00
+ public Timing timings; // Paper
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);
}
@@ -40,7 +42,7 @@ public class CraftTask implements BukkitTask, Runnable { // Spigot
2018-03-31 09:34:25 +00:00
this(null, task, CraftTask.NO_REPEATING, CraftTask.NO_REPEATING);
}
- 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
this.plugin = plugin;
if (task instanceof Runnable) {
this.rTask = (Runnable) task;
@@ -57,7 +59,7 @@ public class CraftTask implements BukkitTask, Runnable { // Spigot
}
this.id = id;
this.period = period;
- this.timings = this.isSync() ? SpigotTimings.getPluginTaskTimings(this, period) : null; // Spigot
+ timings = task != null ? MinecraftTimings.getPluginTaskTimings(this, period) : NullTimingHandler.NULL; // Paper
}
@Override
@@ -77,11 +79,13 @@ public class CraftTask implements BukkitTask, Runnable { // Spigot
@Override
public void run() {
+ try (Timing ignored = timings.startTiming()) { // Paper
if (rTask != null) {
rTask.run();
} else {
cTask.accept(this);
}
+ } // Paper
}
long getPeriod() {
@@ -108,7 +112,7 @@ public class CraftTask implements BukkitTask, Runnable { // Spigot
this.next = next;
}
- Class<?> getTaskClass() {
+ public Class<?> getTaskClass() {
return (rTask != null) ? rTask.getClass() : ((cTask != null) ? cTask.getClass() : null);
}
@@ -132,9 +136,4 @@ public class CraftTask implements BukkitTask, Runnable { // Spigot
return true;
}
- // Spigot start
- public String getTaskName() {
- return (getTaskClass() == null) ? "Unknown" : getTaskClass().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
index e52ef47b78..3d90b34268 100644
--- 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
public CraftIconCache(final String value) {
this.value = value;
}
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
index dd602243d3..924ab7f541 100644
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
@@ -288,6 +288,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>
diff --git a/src/main/java/org/spigotmc/ActivationRange.java b/src/main/java/org/spigotmc/ActivationRange.java
index ca7789b5e0..4423839697 100644
--- a/src/main/java/org/spigotmc/ActivationRange.java
+++ b/src/main/java/org/spigotmc/ActivationRange.java
@@ -31,7 +31,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;
-import org.bukkit.craftbukkit.SpigotTimings;
+import co.aikar.timings.MinecraftTimings;
public class ActivationRange
{
@@ -75,8 +75,8 @@ public class ActivationRange
/**
* These entities are excluded from Activation range checks.
*
- * @param entity
- * @param config
+ * @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)
@@ -111,7 +111,7 @@ public class ActivationRange
*/
public static void activateEntities(World world)
{
- SpigotTimings.entityActivationCheckTimer.startTiming();
+ MinecraftTimings.entityActivationCheckTimer.startTiming();
final int miscActivationRange = world.spigotConfig.miscActivationRange;
final int raiderActivationRange = world.spigotConfig.raiderActivationRange;
final int animalActivationRange = world.spigotConfig.animalActivationRange;
@@ -148,7 +148,7 @@ public class ActivationRange
}
}
}
- SpigotTimings.entityActivationCheckTimer.stopTiming();
+ MinecraftTimings.entityActivationCheckTimer.stopTiming();
}
/**
@@ -245,10 +245,8 @@ public class ActivationRange
*/
public static boolean checkIfActive(Entity entity)
{
- SpigotTimings.checkIfActiveTimer.startTiming();
// Never safe to skip fireworks or entities not yet added to chunk
if ( !entity.inChunk || entity instanceof EntityFireworks ) {
- SpigotTimings.checkIfActiveTimer.stopTiming();
return true;
}
@@ -272,7 +270,6 @@ public class ActivationRange
{
isActive = false;
}
- SpigotTimings.checkIfActiveTimer.stopTiming();
return isActive;
}
}
--
2.22.1