mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-03 21:52:05 -07:00
Even more work
This commit is contained in:
62
patches/server/Separate-dimensiondata-executor.patch
Normal file
62
patches/server/Separate-dimensiondata-executor.patch
Normal file
@@ -0,0 +1,62 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Nassim Jahnke <nassim@njahnke.dev>
|
||||
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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/Util.java
|
||||
+++ b/src/main/java/net/minecraft/Util.java
|
||||
@@ -0,0 +0,0 @@ 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() {
|
||||
@@ -0,0 +0,0 @@ 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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/storage/DimensionDataStorage.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/storage/DimensionDataStorage.java
|
||||
@@ -0,0 +0,0 @@ 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);
|
||||
@@ -0,0 +0,0 @@ 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)
|
||||
)
|
||||
);
|
Reference in New Issue
Block a user