2018-08-06 01:46:43 +02:00
|
|
|
From 4acb687be9e81d3882d1dcc889a97acc566f8eb3 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-07-26 01:05:07 +02:00
|
|
|
index c1a42e61e7..c96f1b2753 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
|
2018-07-16 22:08:09 +02:00
|
|
|
@@ -36,6 +36,11 @@ public class ChunkProviderServer implements IChunkProvider {
|
|
|
|
public final Long2ObjectMap<Chunk> chunks = Long2ObjectMaps.synchronize(new ChunkMap(8192));
|
|
|
|
private final ChunkTaskScheduler f;
|
|
|
|
private final SchedulerBatch<ChunkCoordIntPair, ChunkStatus, ProtoChunk> g;
|
2016-11-04 07:21:33 +01:00
|
|
|
+ // Paper start - chunk save stats
|
|
|
|
+ private long lastQueuedSaves = 0L; // Paper
|
|
|
|
+ private long lastProcessedSaves = 0L; // Paper
|
|
|
|
+ private long lastSaveStatPrinted = System.currentTimeMillis();
|
|
|
|
+ // Paper end
|
2018-07-16 22:08:09 +02:00
|
|
|
public final WorldServer world;
|
|
|
|
|
|
|
|
public ChunkProviderServer(WorldServer worldserver, IChunkLoader ichunkloader, ChunkGenerator<?> chunkgenerator, IAsyncTaskHandler iasynctaskhandler) {
|
2018-07-26 01:05:07 +02:00
|
|
|
@@ -263,6 +268,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-07-23 10:39:55 +02:00
|
|
|
index 859148cb86..ea8684747d 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
|
2018-07-19 06:42:43 +02:00
|
|
|
@@ -137,7 +137,13 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver {
|
2018-07-16 22:08:09 +02:00
|
|
|
}
|
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
|
2018-07-22 07:27:46 +02:00
|
|
|
@@ -325,6 +331,7 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver {
|
2016-11-04 07:21:33 +01:00
|
|
|
|
2018-07-16 22:08:09 +02:00
|
|
|
protected synchronized void a(ChunkCoordIntPair chunkcoordintpair, Supplier<NBTTagCompound> nbttagcompound) { // Spigot
|
|
|
|
queue.add(new QueuedChunk(chunkcoordintpair, nbttagcompound)); // Paper - Chunk queue improvements
|
|
|
|
+ queuedSaves++; // Paper
|
|
|
|
this.b.put(chunkcoordintpair, nbttagcompound);
|
2016-11-04 07:21:33 +01:00
|
|
|
FileIOThread.a().a(this);
|
2018-07-16 22:08:09 +02:00
|
|
|
}
|
2018-07-22 07:27:46 +02:00
|
|
|
@@ -348,6 +355,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-07-04 09:55:24 +02:00
|
|
|
2.18.0
|
2016-11-04 07:21:33 +01:00
|
|
|
|