mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-01 04:32:11 -07:00
Clean up Timings and Async Chunk Configs
Renames a bunch of timings to be more appropriate for the new environment. Many things dealt with sync loads which wasn't correct anymore. adjusted timings to be a little bit more accurate here. Also cleaned up old 1.13 async chunks configs so people won't keep thinking they can change some of those configs when they can't.
This commit is contained in:
@@ -121,7 +121,7 @@ tasks required to be executed by the chunk load task (i.e lighting
|
||||
and some poi tasks).
|
||||
|
||||
diff --git a/src/main/java/co/aikar/timings/WorldTimingsHandler.java b/src/main/java/co/aikar/timings/WorldTimingsHandler.java
|
||||
index 27ce4a828e..30bafb214b 100644
|
||||
index fa1c920ea6..98acbfa44d 100644
|
||||
--- 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 {
|
||||
@@ -161,7 +161,7 @@ index 27ce4a828e..30bafb214b 100644
|
||||
|
||||
public static Timing getTickList(WorldServer worldserver, String timingsType) {
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/PaperConfig.java b/src/main/java/com/destroystokyo/paper/PaperConfig.java
|
||||
index dbd1439970..6916ed30c4 100644
|
||||
index dbd1439970..f4836e2da1 100644
|
||||
--- a/src/main/java/com/destroystokyo/paper/PaperConfig.java
|
||||
+++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java
|
||||
@@ -0,0 +0,0 @@
|
||||
@@ -177,62 +177,48 @@ index dbd1439970..6916ed30c4 100644
|
||||
}
|
||||
+
|
||||
+ public static boolean asyncChunks = false;
|
||||
+ //public static boolean asyncChunkGeneration = true; // Leave out for now until we can control this
|
||||
+ //public static boolean asyncChunkGenThreadPerWorld = true; // Leave out for now until we can control this
|
||||
+ public static int asyncChunkLoadThreads = -1;
|
||||
+ private static void asyncChunks() {
|
||||
+ ConfigurationSection section;
|
||||
+ if (version < 15) {
|
||||
+ boolean enabled = config.getBoolean("settings.async-chunks", true);
|
||||
+ ConfigurationSection section = config.createSection("settings.async-chunks");
|
||||
+ section = config.createSection("settings.async-chunks");
|
||||
+ section.set("enable", enabled);
|
||||
+ section.set("load-threads", -1);
|
||||
+ section.set("generation", true);
|
||||
+ section.set("thread-per-world-generation", true);
|
||||
+ section.set("threads", -1);
|
||||
+ } else {
|
||||
+ section = config.getConfigurationSection("settings.async-chunks");
|
||||
+ if (section == null) {
|
||||
+ section = config.createSection("settings.async-chunks");
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ // TODO load threads now control async chunk save for unloading chunks, look into renaming this?
|
||||
+ // Clean up old configs
|
||||
+ if (section.contains("load-threads")) {
|
||||
+ if (!section.contains("threads")) {
|
||||
+ section.set("threads", section.get("load-threads"));
|
||||
+ }
|
||||
+ section.set("load-threads", null);
|
||||
+ }
|
||||
+ section.set("generation", null);
|
||||
+ section.set("thread-per-world-generation", null);
|
||||
+
|
||||
+ asyncChunks = getBoolean("settings.async-chunks.enable", true);
|
||||
+ //asyncChunkGeneration = getBoolean("settings.async-chunks.generation", true); // Leave out for now until we can control this
|
||||
+ //asyncChunkGenThreadPerWorld = getBoolean("settings.async-chunks.thread-per-world-generation", true); // Leave out for now until we can control this
|
||||
+ asyncChunkLoadThreads = getInt("settings.async-chunks.load-threads", -1);
|
||||
+ if (asyncChunkLoadThreads <= 0) {
|
||||
+ asyncChunkLoadThreads = (int) Math.min(Integer.getInteger("paper.maxChunkThreads", 8), Math.max(1, Runtime.getRuntime().availableProcessors() - 1));
|
||||
+ int threads = getInt("settings.async-chunks.threads", -1);
|
||||
+ if (threads <= 0) {
|
||||
+ threads = (int) Math.min(Integer.getInteger("paper.maxChunkThreads", 8), Math.max(1, Runtime.getRuntime().availableProcessors() - 1));
|
||||
+ }
|
||||
+
|
||||
+ // Let Shared Host set some limits
|
||||
+ String sharedHostEnvGen = System.getenv("PAPER_ASYNC_CHUNKS_SHARED_HOST_GEN");
|
||||
+ String sharedHostEnvLoad = System.getenv("PAPER_ASYNC_CHUNKS_SHARED_HOST_LOAD");
|
||||
+ /* Ignore temporarily - we cannot control the gen threads (for now)
|
||||
+ if ("1".equals(sharedHostEnvGen)) {
|
||||
+ log("Async Chunks - Generation: Your host has requested to use a single thread world generation");
|
||||
+ asyncChunkGenThreadPerWorld = false;
|
||||
+ } else if ("2".equals(sharedHostEnvGen)) {
|
||||
+ log("Async Chunks - Generation: Your host has disabled async world generation - You will experience lag from world generation");
|
||||
+ asyncChunkGeneration = false;
|
||||
+ }
|
||||
+ */
|
||||
+
|
||||
+ if (sharedHostEnvLoad != null) {
|
||||
+ String sharedHostThreads = System.getenv("PAPER_ASYNC_CHUNKS_SHARED_HOST_THREADS");
|
||||
+ if (sharedHostThreads != null) {
|
||||
+ try {
|
||||
+ asyncChunkLoadThreads = Math.max(1, Math.min(asyncChunkLoadThreads, Integer.parseInt(sharedHostEnvLoad)));
|
||||
+ threads = Math.max(1, Math.min(threads, Integer.parseInt(sharedHostThreads)));
|
||||
+ } catch (NumberFormatException ignored) {}
|
||||
+ }
|
||||
+
|
||||
+ if (!asyncChunks) {
|
||||
+ log("Async Chunks: Disabled - Chunks will be managed synchronosuly, and will cause tremendous lag.");
|
||||
+ } else {
|
||||
+ ChunkTaskManager.initGlobalLoadThreads(asyncChunkLoadThreads);
|
||||
+ ChunkTaskManager.initGlobalLoadThreads(threads);
|
||||
+ log("Async Chunks: Enabled - Chunks will be loaded much faster, without lag.");
|
||||
+ /* Ignore temporarily - we cannot control the gen threads (for now)
|
||||
+ if (!asyncChunkGeneration) {
|
||||
+ log("Async Chunks - Generation: Disabled - Chunks will be generated synchronosuly, and will cause tremendous lag.");
|
||||
+ } else if (asyncChunkGenThreadPerWorld) {
|
||||
+ log("Async Chunks - Generation: Enabled - Chunks will be generated much faster, without lag.");
|
||||
+ } else {
|
||||
+ log("Async Chunks - Generation: Enabled (Single Thread) - Chunks will be generated much faster, without lag.");
|
||||
+ }
|
||||
+ */
|
||||
+ }
|
||||
+ }
|
||||
}
|
||||
@@ -1583,7 +1569,7 @@ index 0000000000..ee906b594b
|
||||
+}
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/io/chunk/ChunkLoadTask.java b/src/main/java/com/destroystokyo/paper/io/chunk/ChunkLoadTask.java
|
||||
new file mode 100644
|
||||
index 0000000000..305da47868
|
||||
index 0000000000..ac9bc3e231
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/com/destroystokyo/paper/io/chunk/ChunkLoadTask.java
|
||||
@@ -0,0 +0,0 @@
|
||||
@@ -1675,7 +1661,7 @@ index 0000000000..305da47868
|
||||
+
|
||||
+ final PlayerChunkMap chunkManager = this.world.getChunkProvider().playerChunkMap;
|
||||
+
|
||||
+ try (Timing ignored = this.world.timings.chunkIOStage1.startTimingIfSync()) {
|
||||
+ try (Timing ignored = this.world.timings.chunkLoadLevelTimer.startTimingIfSync()) {
|
||||
+ final ChunkRegionLoader.InProgressChunkHolder chunkHolder;
|
||||
+
|
||||
+ // apply fixes
|
||||
@@ -2399,7 +2385,7 @@ index 0000000000..2b20c159f6
|
||||
+
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java
|
||||
index 5e4f3612ba..5b10562369 100644
|
||||
index 4c9c8e4839..259af7095c 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 extends IChunkProvider {
|
||||
@@ -2548,10 +2534,10 @@ index 5e4f3612ba..5b10562369 100644
|
||||
+ this.world.asyncChunkTaskManager.raisePriority(x, z, com.destroystokyo.paper.io.PrioritizedTaskQueue.HIGHEST_PRIORITY);
|
||||
+ com.destroystokyo.paper.io.chunk.ChunkTaskManager.pushChunkWait(this.world, x, z);
|
||||
+ // Paper end
|
||||
this.world.timings.chunkAwait.startTiming(); // Paper
|
||||
this.world.timings.syncChunkLoad.startTiming(); // Paper
|
||||
this.serverThreadQueue.awaitTasks(completablefuture::isDone);
|
||||
+ com.destroystokyo.paper.io.chunk.ChunkTaskManager.popChunkWait(); // Paper - async chunk debug
|
||||
this.world.timings.chunkAwait.stopTiming(); // Paper
|
||||
this.world.timings.syncChunkLoad.stopTiming(); // Paper
|
||||
} // Paper
|
||||
ichunkaccess = (IChunkAccess) ((Either) completablefuture.join()).map((ichunkaccess1) -> {
|
||||
@@ -0,0 +0,0 @@ public class ChunkProviderServer extends IChunkProvider {
|
||||
@@ -2569,7 +2555,7 @@ index 5e4f3612ba..5b10562369 100644
|
||||
} finally {
|
||||
playerChunkMap.callbackExecutor.run();
|
||||
diff --git a/src/main/java/net/minecraft/server/ChunkRegionLoader.java b/src/main/java/net/minecraft/server/ChunkRegionLoader.java
|
||||
index 8816c90e2d..1298a07dc7 100644
|
||||
index 79e85520f3..7389aba1a4 100644
|
||||
--- a/src/main/java/net/minecraft/server/ChunkRegionLoader.java
|
||||
+++ b/src/main/java/net/minecraft/server/ChunkRegionLoader.java
|
||||
@@ -0,0 +0,0 @@ import it.unimi.dsi.fastutil.longs.LongOpenHashSet;
|
||||
@@ -3113,7 +3099,7 @@ index f1620ba80e..74e6b8b973 100644
|
||||
completablefuture = (CompletableFuture) this.statusFutures.get(i);
|
||||
if (completablefuture != null) {
|
||||
diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java
|
||||
index b4c9d544fe..c4fb0c68dd 100644
|
||||
index 9c627bf3b4..19603343b2 100644
|
||||
--- a/src/main/java/net/minecraft/server/PlayerChunkMap.java
|
||||
+++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java
|
||||
@@ -0,0 +0,0 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
|
||||
@@ -3284,36 +3270,37 @@ index b4c9d544fe..c4fb0c68dd 100644
|
||||
- return CompletableFuture.supplyAsync(() -> {
|
||||
+ // Paper start - Async chunk io
|
||||
+ final java.util.function.BiFunction<ChunkRegionLoader.InProgressChunkHolder, Throwable, Either<IChunkAccess, PlayerChunk.Failure>> syncLoadComplete = (chunkHolder, ioThrowable) -> {
|
||||
try (Timing ignored = this.world.timings.syncChunkLoadTimer.startTimingIfSync()) { // Paper
|
||||
try (Timing ignored = this.world.timings.chunkLoad.startTimingIfSync()) { // Paper
|
||||
this.world.getMethodProfiler().c("chunkLoad");
|
||||
- NBTTagCompound nbttagcompound; // Paper
|
||||
- try (Timing ignored2 = this.world.timings.chunkIOStage1.startTimingIfSync()) { // Paper start - timings
|
||||
- try (Timing ignored2 = this.world.timings.chunkIO.startTimingIfSync()) { // Paper start - timings
|
||||
- nbttagcompound = this.readChunkData(chunkcoordintpair);
|
||||
- } // Paper end
|
||||
-
|
||||
- if (nbttagcompound != null) {
|
||||
- if (nbttagcompound != null) {try (Timing ignored2 = this.world.timings.chunkLoadLevelTimer.startTimingIfSync()) { // Paper start - timings
|
||||
- boolean flag = nbttagcompound.hasKeyOfType("Level", 10) && nbttagcompound.getCompound("Level").hasKeyOfType("Status", 8);
|
||||
-
|
||||
- if (flag) {
|
||||
- ProtoChunk protochunk = ChunkRegionLoader.loadChunk(this.world, this.definedStructureManager, this.m, chunkcoordintpair, nbttagcompound);
|
||||
+ if (ioThrowable != null) {
|
||||
+ com.destroystokyo.paper.io.IOUtil.rethrow(ioThrowable);
|
||||
+ }
|
||||
|
||||
- if (flag) {
|
||||
- ProtoChunk protochunk = ChunkRegionLoader.loadChunk(this.world, this.definedStructureManager, this.m, chunkcoordintpair, nbttagcompound);
|
||||
- protochunk.setLastSaved(this.world.getTime());
|
||||
- return Either.left(protochunk);
|
||||
- }
|
||||
+ this.getVillagePlace().loadInData(chunkcoordintpair, chunkHolder.poiData);
|
||||
+ chunkHolder.tasks.forEach(Runnable::run);
|
||||
+ // Paper - async load completes this
|
||||
+ // Paper end
|
||||
|
||||
- protochunk.setLastSaved(this.world.getTime());
|
||||
- return Either.left(protochunk);
|
||||
- }
|
||||
-
|
||||
- PlayerChunkMap.LOGGER.error("Chunk file at {} is missing level data, skipping", chunkcoordintpair);
|
||||
- }} // Paper
|
||||
+ // Paper start - This is done async
|
||||
+ if (chunkHolder.protoChunk != null) {
|
||||
+ chunkHolder.protoChunk.setLastSaved(this.world.getTime());
|
||||
+ return Either.left(chunkHolder.protoChunk);
|
||||
}
|
||||
+ }
|
||||
+ // Paper end
|
||||
} catch (ReportedException reportedexception) {
|
||||
Throwable throwable = reportedexception.getCause();
|
||||
|
Reference in New Issue
Block a user