2018-01-18 07:00:51 +01:00
|
|
|
From deb93a88dc54ae8e37230bcdd14ba69d941ff82e Mon Sep 17 00:00:00 2001
|
2016-11-04 07:21:33 +01: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-01-18 07:00:51 +01:00
|
|
|
index 2b87329f4..73554a518 100644
|
2016-11-04 07:21:33 +01:00
|
|
|
--- a/src/main/java/net/minecraft/server/ChunkProviderServer.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java
|
2016-11-17 03:23:38 +01:00
|
|
|
@@ -28,6 +28,11 @@ public class ChunkProviderServer implements IChunkProvider {
|
2017-07-27 06:25:13 +02:00
|
|
|
public final Set<Long> unloadQueue = Sets.newHashSet();
|
2016-11-04 07:21:33 +01:00
|
|
|
public final ChunkGenerator chunkGenerator;
|
|
|
|
private final IChunkLoader chunkLoader;
|
|
|
|
+ // Paper start - chunk save stats
|
|
|
|
+ private long lastQueuedSaves = 0L; // Paper
|
|
|
|
+ private long lastProcessedSaves = 0L; // Paper
|
|
|
|
+ private long lastSaveStatPrinted = System.currentTimeMillis();
|
|
|
|
+ // Paper end
|
|
|
|
// Paper start
|
|
|
|
protected Chunk lastChunkByPos = null;
|
|
|
|
public Long2ObjectOpenHashMap<Chunk> chunks = new Long2ObjectOpenHashMap<Chunk>(8192) {
|
2016-11-17 03:23:38 +01:00
|
|
|
@@ -257,6 +262,30 @@ public class ChunkProviderServer implements IChunkProvider {
|
2016-11-04 07:21:33 +01:00
|
|
|
// Paper start
|
|
|
|
final ChunkRegionLoader chunkLoader = (ChunkRegionLoader) world.getChunkProviderServer().chunkLoader;
|
|
|
|
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
|
|
|
|
+ );
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
if (queueSize > world.paperConfig.queueSizeAutoSaveThreshold){
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/ChunkRegionLoader.java b/src/main/java/net/minecraft/server/ChunkRegionLoader.java
|
2018-01-18 07:00:51 +01:00
|
|
|
index 77943821e..14f88e91d 100644
|
2016-11-04 07:21:33 +01:00
|
|
|
--- a/src/main/java/net/minecraft/server/ChunkRegionLoader.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/ChunkRegionLoader.java
|
2017-08-12 23:32:01 +02:00
|
|
|
@@ -39,7 +39,13 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver {
|
2017-04-29 02:25:52 +02:00
|
|
|
this.e = dataconvertermanager;
|
2016-11-04 07:21:33 +01: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
|
|
|
|
|
2017-04-29 02:25:52 +02:00
|
|
|
// CraftBukkit start - Add async variant, provide compatibility
|
|
|
|
@Nullable
|
2017-08-12 23:32:01 +02:00
|
|
|
@@ -163,6 +169,7 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver {
|
2016-11-04 07:21:33 +01:00
|
|
|
synchronized (lock) { // Paper - Chunk queue improvements
|
|
|
|
this.b.put(chunkcoordintpair, nbttagcompound);
|
|
|
|
}
|
|
|
|
+ queuedSaves++; // Paper
|
|
|
|
queue.add(new QueuedChunk(chunkcoordintpair, nbttagcompound)); // Paper - Chunk queue improvements
|
|
|
|
|
|
|
|
FileIOThread.a().a(this);
|
2017-08-12 23:32:01 +02:00
|
|
|
@@ -187,6 +194,7 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver {
|
2016-11-04 07:21:33 +01:00
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
ChunkCoordIntPair chunkcoordintpair = chunk.coords; // Paper - Chunk queue improvements
|
|
|
|
+ processedSaves.incrementAndGet(); // Paper
|
|
|
|
|
|
|
|
boolean flag;
|
|
|
|
|
|
|
|
--
|
2018-01-18 07:00:51 +01:00
|
|
|
2.16.1
|
2016-11-04 07:21:33 +01:00
|
|
|
|