diff options
Diffstat (limited to 'patches/server/1032-Separate-dimensiondata-executor.patch')
-rw-r--r-- | patches/server/1032-Separate-dimensiondata-executor.patch | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/patches/server/1032-Separate-dimensiondata-executor.patch b/patches/server/1032-Separate-dimensiondata-executor.patch new file mode 100644 index 0000000000..901507d860 --- /dev/null +++ b/patches/server/1032-Separate-dimensiondata-executor.patch @@ -0,0 +1,62 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Nassim Jahnke <[email protected]> +Date: Thu, 28 Nov 2024 10:35:58 +0100 +Subject: [PATCH] Separate dimensiondata executor + + +diff --git a/src/main/java/net/minecraft/Util.java b/src/main/java/net/minecraft/Util.java +index 1a31024b46a5d7960f1e0f172f8ebcf396dd3139..38ffa1c4c204f73746c4b87127de92b631548eb1 100644 +--- a/src/main/java/net/minecraft/Util.java ++++ b/src/main/java/net/minecraft/Util.java +@@ -94,6 +94,7 @@ public class Util { + private static final String MAX_THREADS_SYSTEM_PROPERTY = "max.bg.threads"; + private static final TracingExecutor BACKGROUND_EXECUTOR = makeExecutor("Main", -1); // Paper - Perf: add priority + private static final TracingExecutor IO_POOL = makeIoExecutor("IO-Worker-", false); ++ public static final TracingExecutor DIMENSION_DATA_IO_POOL = makeExtraIoExecutor("Dimension-Data-IO-Worker-"); // Paper - Separate dimension data IO pool + private static final TracingExecutor DOWNLOAD_POOL = makeIoExecutor("Download-", true); + // Paper start - don't submit BLOCKING PROFILE LOOKUPS to the world gen thread + public static final ExecutorService PROFILE_EXECUTOR = Executors.newFixedThreadPool(2, new java.util.concurrent.ThreadFactory() { +@@ -265,6 +266,21 @@ public class Util { + })); + } + ++ // Paper start - Separate dimension data IO pool ++ private static TracingExecutor makeExtraIoExecutor(String namePrefix) { ++ AtomicInteger atomicInteger = new AtomicInteger(1); ++ return new TracingExecutor(Executors.newFixedThreadPool(4, runnable -> { ++ Thread thread = new Thread(runnable); ++ String string2 = namePrefix + atomicInteger.getAndIncrement(); ++ TracyClient.setThreadName(string2, namePrefix.hashCode()); ++ thread.setName(string2); ++ thread.setDaemon(false); ++ thread.setUncaughtExceptionHandler(Util::onThreadException); ++ return thread; ++ })); ++ } ++ // Paper end - Separate dimension data IO pool ++ + public static void throwAsRuntime(Throwable t) { + throw t instanceof RuntimeException ? (RuntimeException)t : new RuntimeException(t); + } +diff --git a/src/main/java/net/minecraft/world/level/storage/DimensionDataStorage.java b/src/main/java/net/minecraft/world/level/storage/DimensionDataStorage.java +index 3c3b18e5b419a0f785467c511dcdd65873ad0989..9272c91e0ee489091fdf1fedcf3801c070e9e82a 100644 +--- a/src/main/java/net/minecraft/world/level/storage/DimensionDataStorage.java ++++ b/src/main/java/net/minecraft/world/level/storage/DimensionDataStorage.java +@@ -139,7 +139,7 @@ public class DimensionDataStorage implements AutoCloseable { + } else { + int i = Util.maxAllowedExecutorThreads(); + int j = map.size(); +- if (j > i) { ++ if (false && j > i) { // Paper - Separate dimension data IO pool; just throw them into the fixed pool queue + this.pendingWriteFuture = this.pendingWriteFuture.thenCompose(object -> { + List<CompletableFuture<?>> list = new ArrayList<>(i); + int k = Mth.positiveCeilDiv(j, i); +@@ -160,7 +160,7 @@ public class DimensionDataStorage implements AutoCloseable { + v -> CompletableFuture.allOf( + map.entrySet() + .stream() +- .map(entry -> CompletableFuture.runAsync(() -> tryWrite(entry.getKey(), entry.getValue()), Util.ioPool())) ++ .map(entry -> CompletableFuture.runAsync(() -> tryWrite(entry.getKey(), entry.getValue()), Util.DIMENSION_DATA_IO_POOL)) // Paper - Separate dimension data IO pool + .toArray(CompletableFuture[]::new) + ) + ); |