diff --git a/Spigot-Server-Patches/Add-exception-reporting-event.patch b/Spigot-Server-Patches/Add-exception-reporting-event.patch index 06eab52683..2f765a3086 100644 --- a/Spigot-Server-Patches/Add-exception-reporting-event.patch +++ b/Spigot-Server-Patches/Add-exception-reporting-event.patch @@ -114,7 +114,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } } @@ -0,0 +0,0 @@ public class ChunkProviderServer implements IChunkProvider { - try { + try (co.aikar.timings.Timing timed = world.timings.chunkSaveNop.startTiming()) { this.chunkLoader.b(this.world, chunk); } catch (Exception exception) { - ChunkProviderServer.a.error("Couldn\'t save entities", exception); diff --git a/Spigot-Server-Patches/Auto-Save-Improvements.patch b/Spigot-Server-Patches/Auto-Save-Improvements.patch index 23d87f872d..99a6386a2b 100644 --- a/Spigot-Server-Patches/Auto-Save-Improvements.patch +++ b/Spigot-Server-Patches/Auto-Save-Improvements.patch @@ -91,7 +91,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } - if (autosavePeriod > 0 && this.ticks % autosavePeriod == 0) { // CraftBukkit - MinecraftTimings.worldSaveTimer.startTiming(); // Spigot this.methodProfiler.a("save"); + + serverAutoSave = (autosavePeriod > 0 && this.ticks % autosavePeriod == 0); // Paper @@ -112,7 +111,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 // this.saveChunks(true); // Spigot End this.methodProfiler.b(); - MinecraftTimings.worldSaveTimer.stopTiming(); // Spigot - } + //} // Paper - Incremental Auto Saving @@ -128,13 +126,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 if (chunkproviderserver.e()) { - org.bukkit.Bukkit.getPluginManager().callEvent(new org.bukkit.event.world.WorldSaveEvent(getWorld())); // CraftBukkit + if (flag) org.bukkit.Bukkit.getPluginManager().callEvent(new org.bukkit.event.world.WorldSaveEvent(getWorld())); // CraftBukkit // Paper - Incremental Auto Saving - Only fire event on full save + timings.worldSave.startTiming(); // Paper ++ if (flag || server.serverAutoSave) { // Paper if (iprogressupdate != null) { iprogressupdate.a("Saving level"); } - -- this.a(); -+ if (flag || server.serverAutoSave) this.a(); // Paper +@@ -0,0 +0,0 @@ public class WorldServer extends World implements IAsyncTaskHandler { if (iprogressupdate != null) { iprogressupdate.c("Saving chunks"); } ++ } // Paper + + timings.worldSaveChunks.startTiming(); // Paper + chunkproviderserver.a(flag); -- \ No newline at end of file diff --git a/Spigot-Server-Patches/Disable-Vanilla-Chunk-GC.patch b/Spigot-Server-Patches/Disable-Vanilla-Chunk-GC.patch index 6a52f7431a..46eadeb3f4 100644 --- a/Spigot-Server-Patches/Disable-Vanilla-Chunk-GC.patch +++ b/Spigot-Server-Patches/Disable-Vanilla-Chunk-GC.patch @@ -10,8 +10,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/server/WorldServer.java +++ b/src/main/java/net/minecraft/server/WorldServer.java @@ -0,0 +0,0 @@ public class WorldServer extends World implements IAsyncTaskHandler { - chunkproviderserver.a(flag); + timings.worldSaveChunks.stopTiming(); // Paper // CraftBukkit - ArrayList -> Collection - Collection arraylist = chunkproviderserver.a(); + /* //Paper start Collection arraylist = chunkproviderserver.a(); @@ -25,7 +25,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - } + }*/ + // Paper end - + timings.worldSave.stopTiming(); // Paper } } -- \ No newline at end of file diff --git a/Spigot-Server-Patches/Lighting-Queue.patch b/Spigot-Server-Patches/Lighting-Queue.patch index 829555a1d7..24ec84b50e 100644 --- a/Spigot-Server-Patches/Lighting-Queue.patch +++ b/Spigot-Server-Patches/Lighting-Queue.patch @@ -10,8 +10,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/co/aikar/timings/WorldTimingsHandler.java +++ b/src/main/java/co/aikar/timings/WorldTimingsHandler.java @@ -0,0 +0,0 @@ public class WorldTimingsHandler { - public final Timing chunkIOStage1; - public final Timing chunkIOStage2; + public final Timing chunkSaveNop; + public final Timing chunkSaveData; + public final Timing lightingQueueTimer; + diff --git a/Spigot-Server-Patches/Timings-v2.patch b/Spigot-Server-Patches/Timings-v2.patch index 93dfb2030f..8ea072fb69 100644 --- a/Spigot-Server-Patches/Timings-v2.patch +++ b/Spigot-Server-Patches/Timings-v2.patch @@ -45,7 +45,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + 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 worldSaveTimer = Timings.ofSafe("World Save"); ++ public static final Timing savePlayers = Timings.ofSafe("Save Players"); + + public static final Timing tickEntityTimer = Timings.ofSafe("## tickEntity"); + public static final Timing tickTileEntityTimer = Timings.ofSafe("## tickTileEntity"); @@ -325,6 +325,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + 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 chunkSaveNop; ++ public final Timing chunkSaveData; + + public WorldTimingsHandler(World server) { + String name = server.worldData.getName() +" - "; @@ -363,6 +368,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + 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"); ++ chunkSaveNop = Timings.ofSafe(name + "Chunk Save - NOP"); ++ chunkSaveData = Timings.ofSafe(name + "Chunk Save - Data"); + + tracker1 = Timings.ofSafe(name + "tracker stage 1"); + tracker2 = Timings.ofSafe(name + "tracker stage 2"); @@ -482,6 +492,28 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } private void z() { +diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/server/ChunkProviderServer.java ++++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java +@@ -0,0 +0,0 @@ public class ChunkProviderServer implements IChunkProvider { + } + + public void saveChunkNOP(Chunk chunk) { +- try { ++ try (co.aikar.timings.Timing timed = world.timings.chunkSaveNop.startTiming()) { + this.chunkLoader.b(this.world, chunk); + } catch (Exception exception) { + ChunkProviderServer.a.error("Couldn\'t save entities", exception); +@@ -0,0 +0,0 @@ public class ChunkProviderServer implements IChunkProvider { + } + + public void saveChunk(Chunk chunk) { +- try { ++ try (co.aikar.timings.Timing timed = world.timings.chunkSaveData.startTiming()) { + chunk.setLastSaved(this.world.getTime()); + this.chunkLoader.a(this.world, chunk); + } catch (IOException ioexception) { diff --git a/src/main/java/net/minecraft/server/ChunkRegionLoader.java b/src/main/java/net/minecraft/server/ChunkRegionLoader.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/server/ChunkRegionLoader.java @@ -729,7 +761,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 if (autosavePeriod > 0 && this.ticks % autosavePeriod == 0) { // CraftBukkit - SpigotTimings.worldSaveTimer.startTiming(); // Spigot -+ MinecraftTimings.worldSaveTimer.startTiming(); // Spigot this.methodProfiler.a("save"); this.v.savePlayers(); // Spigot Start @@ -738,7 +769,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 // Spigot End this.methodProfiler.b(); - SpigotTimings.worldSaveTimer.stopTiming(); // Spigot -+ MinecraftTimings.worldSaveTimer.stopTiming(); // Spigot } this.methodProfiler.a("tallying"); @@ -986,6 +1016,30 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 // this.minecraftServer.getCommandHandler().a(this.player, s); // CraftBukkit end } +diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/server/PlayerList.java ++++ b/src/main/java/net/minecraft/server/PlayerList.java +@@ -0,0 +0,0 @@ + 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; +@@ -0,0 +0,0 @@ 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 void addWhitelist(GameProfile gameprofile) { diff --git a/src/main/java/net/minecraft/server/StructureGenerator.java b/src/main/java/net/minecraft/server/StructureGenerator.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/server/StructureGenerator.java @@ -1244,6 +1298,49 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 // CraftBukkit end } +@@ -0,0 +0,0 @@ public class WorldServer extends World implements IAsyncTaskHandler { + + if (chunkproviderserver.e()) { + org.bukkit.Bukkit.getPluginManager().callEvent(new org.bukkit.event.world.WorldSaveEvent(getWorld())); // CraftBukkit ++ timings.worldSave.startTiming(); // Paper + if (iprogressupdate != null) { + iprogressupdate.a("Saving level"); + } +@@ -0,0 +0,0 @@ public class WorldServer extends World implements IAsyncTaskHandler { + iprogressupdate.c("Saving chunks"); + } + ++ timings.worldSaveChunks.startTiming(); // Paper + chunkproviderserver.a(flag); ++ timings.worldSaveChunks.stopTiming(); // Paper + // CraftBukkit - ArrayList -> Collection + Collection arraylist = chunkproviderserver.a(); + Iterator iterator = arraylist.iterator(); +@@ -0,0 +0,0 @@ public class WorldServer extends World implements IAsyncTaskHandler { + chunkproviderserver.unload(chunk); + } + } +- ++ timings.worldSave.stopTiming(); // Paper + } + } + +@@ -0,0 +0,0 @@ public class WorldServer extends World implements IAsyncTaskHandler { + } + + protected void a() throws ExceptionWorldConflict { ++ timings.worldSaveLevel.startTiming(); // Paper + this.checkSession(); + WorldServer[] aworldserver = this.server.worldServer; + int i = aworldserver.length; +@@ -0,0 +0,0 @@ public class WorldServer extends World implements IAsyncTaskHandler { + this.worldData.e(this.getWorldBorder().i()); + this.dataManager.saveWorldData(this.worldData, this.server.getPlayerList().t()); + this.worldMaps.a(); ++ timings.worldSaveLevel.stopTiming(); // Paper + } + + // CraftBukkit start diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java