2018-12-17 05:18:06 +00:00
|
|
|
From 4e6ed39f4a404bdd8ed37ebb72c38d80ce475e6b Mon Sep 17 00:00:00 2001
|
2018-08-26 18:11:49 +00:00
|
|
|
From: Aikar <aikar@aikar.co>
|
|
|
|
Date: Fri, 4 Nov 2016 02:12:10 -0400
|
|
|
|
Subject: [PATCH] Chunk Save Stats Debug Option
|
|
|
|
|
|
|
|
Adds a command line flag to enable stats on how chunk saves are processing.
|
|
|
|
|
|
|
|
Stats on current queue, how many was processed and how many were queued.
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java
|
2018-12-17 05:18:06 +00:00
|
|
|
index 9990cdbcd..b1c4eb4ae 100644
|
2018-08-26 18:11:49 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/ChunkProviderServer.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java
|
|
|
|
@@ -30,6 +30,11 @@ public class ChunkProviderServer implements IChunkProvider {
|
|
|
|
public final LongSet unloadQueue = new LongOpenHashSet();
|
|
|
|
public final ChunkGenerator<?> chunkGenerator;
|
2018-10-22 23:16:21 +00:00
|
|
|
public final IChunkLoader chunkLoader;
|
2018-08-26 18:11:49 +00:00
|
|
|
+ // Paper start - chunk save stats
|
|
|
|
+ private long lastQueuedSaves = 0L; // Paper
|
|
|
|
+ private long lastProcessedSaves = 0L; // Paper
|
|
|
|
+ private long lastSaveStatPrinted = System.currentTimeMillis();
|
|
|
|
+ // Paper end
|
|
|
|
public final Long2ObjectMap<Chunk> chunks = Long2ObjectMaps.synchronize(new ChunkMap(8192));
|
|
|
|
private Chunk lastChunk;
|
|
|
|
private final ChunkTaskScheduler chunkScheduler;
|
2018-12-08 10:09:55 +00:00
|
|
|
@@ -239,6 +244,29 @@ public class ChunkProviderServer implements IChunkProvider {
|
2018-08-26 18:11:49 +00:00
|
|
|
// Paper start
|
2018-12-17 05:18:06 +00:00
|
|
|
final ChunkRegionLoader chunkLoader = (ChunkRegionLoader) world.getChunkProvider().chunkLoader;
|
2018-08-26 18:11:49 +00:00
|
|
|
final int queueSize = chunkLoader.getQueueSize();
|
|
|
|
+
|
|
|
|
+ final long now = System.currentTimeMillis();
|
|
|
|
+ final long timeSince = (now - lastSaveStatPrinted) / 1000;
|
|
|
|
+ final Integer printRateSecs = Integer.getInteger("printSaveStats");
|
|
|
|
+ if (printRateSecs != null && timeSince >= printRateSecs) {
|
|
|
|
+ final String timeStr = "/" + timeSince +"s";
|
|
|
|
+ final long queuedSaves = chunkLoader.getQueuedSaves();
|
|
|
|
+ long queuedDiff = queuedSaves - lastQueuedSaves;
|
|
|
|
+ lastQueuedSaves = queuedSaves;
|
|
|
|
+
|
|
|
|
+ final long processedSaves = chunkLoader.getProcessedSaves();
|
|
|
|
+ long processedDiff = processedSaves - lastProcessedSaves;
|
|
|
|
+ lastProcessedSaves = processedSaves;
|
|
|
|
+
|
|
|
|
+ lastSaveStatPrinted = now;
|
|
|
|
+ if (processedDiff > 0 || queueSize > 0 || queuedDiff > 0) {
|
|
|
|
+ System.out.println("[Chunk Save Stats] " + world.worldData.getName() +
|
|
|
|
+ " - Current: " + queueSize +
|
|
|
|
+ " - Queued: " + queuedDiff + timeStr +
|
|
|
|
+ " - Processed: " +processedDiff + timeStr
|
|
|
|
+ );
|
|
|
|
+ }
|
|
|
|
+ }
|
2018-10-05 15:23:20 +00:00
|
|
|
if (!flag && queueSize > world.paperConfig.queueSizeAutoSaveThreshold){
|
2018-08-26 18:11:49 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/ChunkRegionLoader.java b/src/main/java/net/minecraft/server/ChunkRegionLoader.java
|
2018-12-17 05:18:06 +00:00
|
|
|
index f17869d4d..8eecdbd33 100644
|
2018-08-26 18:11:49 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/ChunkRegionLoader.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/ChunkRegionLoader.java
|
2018-09-27 02:35:42 +00:00
|
|
|
@@ -152,7 +152,13 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver {
|
2018-08-26 18:11:49 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
- public int getQueueSize() { return queue.size(); } // Paper
|
|
|
|
+ // Paper start
|
|
|
|
+ private long queuedSaves = 0;
|
|
|
|
+ private final java.util.concurrent.atomic.AtomicLong processedSaves = new java.util.concurrent.atomic.AtomicLong(0L);
|
|
|
|
+ public int getQueueSize() { return queue.size(); }
|
|
|
|
+ public long getQueuedSaves() { return queuedSaves; }
|
|
|
|
+ public long getProcessedSaves() { return processedSaves.longValue(); }
|
|
|
|
+ // Paper end
|
|
|
|
|
|
|
|
// CraftBukkit start - Add async variant, provide compatibility
|
|
|
|
@Nullable
|
2018-09-27 02:35:42 +00:00
|
|
|
@@ -344,6 +350,7 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver {
|
2018-08-26 18:11:49 +00:00
|
|
|
protected void a(ChunkCoordIntPair chunkcoordintpair, Supplier<NBTTagCompound> nbttagcompound) { // Spigot
|
2018-09-11 02:38:42 +00:00
|
|
|
this.saveMap.put(chunkcoordintpair.asLong(), nbttagcompound); // Paper
|
|
|
|
queue.add(new QueuedChunk(chunkcoordintpair, nbttagcompound)); // Paper - Chunk queue improvements
|
2018-08-26 18:11:49 +00:00
|
|
|
+ queuedSaves++; // Paper
|
2018-09-11 02:38:42 +00:00
|
|
|
FileIOThread.a().a(this);
|
|
|
|
}
|
|
|
|
|
2018-09-27 02:35:42 +00:00
|
|
|
@@ -371,6 +378,7 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver {
|
2018-09-09 19:29:22 +00:00
|
|
|
// Paper end
|
2018-08-26 18:11:49 +00:00
|
|
|
ChunkCoordIntPair chunkcoordintpair = chunk.coords; // Paper - Chunk queue improvements
|
|
|
|
Supplier<NBTTagCompound> nbttagcompound = chunk.compoundSupplier; // Spigot // Paper
|
|
|
|
+ processedSaves.incrementAndGet(); // Paper
|
|
|
|
|
|
|
|
if (nbttagcompound == null) {
|
|
|
|
return true;
|
|
|
|
--
|
2018-12-17 05:18:06 +00:00
|
|
|
2.20.0
|
2018-08-26 18:11:49 +00:00
|
|
|
|