mirror of
https://github.com/PaperMC/Paper.git
synced 2025-03-23 15:29:34 +01:00
Separate dimensiondata executor
This commit is contained in:
parent
7ec2cf09a3
commit
3d14e7af19
2 changed files with 53 additions and 6 deletions
|
@ -1,12 +1,13 @@
|
||||||
--- a/net/minecraft/Util.java
|
--- a/net/minecraft/Util.java
|
||||||
+++ b/net/minecraft/Util.java
|
+++ b/net/minecraft/Util.java
|
||||||
@@ -92,9 +92,25 @@
|
@@ -92,9 +92,26 @@
|
||||||
private static final int DEFAULT_MAX_THREADS = 255;
|
private static final int DEFAULT_MAX_THREADS = 255;
|
||||||
private static final int DEFAULT_SAFE_FILE_OPERATION_RETRIES = 10;
|
private static final int DEFAULT_SAFE_FILE_OPERATION_RETRIES = 10;
|
||||||
private static final String MAX_THREADS_SYSTEM_PROPERTY = "max.bg.threads";
|
private static final String MAX_THREADS_SYSTEM_PROPERTY = "max.bg.threads";
|
||||||
- private static final TracingExecutor BACKGROUND_EXECUTOR = makeExecutor("Main");
|
- private static final TracingExecutor BACKGROUND_EXECUTOR = makeExecutor("Main");
|
||||||
+ private static final TracingExecutor BACKGROUND_EXECUTOR = makeExecutor("Main", -1); // Paper - Perf: add priority
|
+ private static final TracingExecutor BACKGROUND_EXECUTOR = makeExecutor("Main", -1); // Paper - Perf: add priority
|
||||||
private static final TracingExecutor IO_POOL = makeIoExecutor("IO-Worker-", false);
|
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);
|
private static final TracingExecutor DOWNLOAD_POOL = makeIoExecutor("Download-", true);
|
||||||
+ // Paper start - don't submit BLOCKING PROFILE LOOKUPS to the world gen thread
|
+ // 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() {
|
+ public static final ExecutorService PROFILE_EXECUTOR = Executors.newFixedThreadPool(2, new java.util.concurrent.ThreadFactory() {
|
||||||
|
@ -27,7 +28,7 @@
|
||||||
private static final DateTimeFormatter FILENAME_DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd_HH.mm.ss", Locale.ROOT);
|
private static final DateTimeFormatter FILENAME_DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd_HH.mm.ss", Locale.ROOT);
|
||||||
public static final int LINEAR_LOOKUP_THRESHOLD = 8;
|
public static final int LINEAR_LOOKUP_THRESHOLD = 8;
|
||||||
private static final Set<String> ALLOWED_UNTRUSTED_LINK_PROTOCOLS = Set.of("http", "https");
|
private static final Set<String> ALLOWED_UNTRUSTED_LINK_PROTOCOLS = Set.of("http", "https");
|
||||||
@@ -136,7 +152,7 @@
|
@@ -136,7 +153,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public static long getNanos() {
|
public static long getNanos() {
|
||||||
|
@ -36,7 +37,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public static long getEpochMillis() {
|
public static long getEpochMillis() {
|
||||||
@@ -147,15 +163,16 @@
|
@@ -147,15 +164,16 @@
|
||||||
return FILENAME_DATE_TIME_FORMATTER.format(ZonedDateTime.now());
|
return FILENAME_DATE_TIME_FORMATTER.format(ZonedDateTime.now());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,7 +59,7 @@
|
||||||
ForkJoinWorkerThread forkJoinWorkerThread = new ForkJoinWorkerThread(pool) {
|
ForkJoinWorkerThread forkJoinWorkerThread = new ForkJoinWorkerThread(pool) {
|
||||||
@Override
|
@Override
|
||||||
protected void onStart() {
|
protected void onStart() {
|
||||||
@@ -177,13 +194,26 @@
|
@@ -177,13 +195,26 @@
|
||||||
forkJoinWorkerThread.setName(string2);
|
forkJoinWorkerThread.setName(string2);
|
||||||
return forkJoinWorkerThread;
|
return forkJoinWorkerThread;
|
||||||
}, Util::onThreadException, true);
|
}, Util::onThreadException, true);
|
||||||
|
@ -87,7 +88,33 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int getMaxThreads() {
|
private static int getMaxThreads() {
|
||||||
@@ -537,7 +567,7 @@
|
@@ -229,10 +260,25 @@
|
||||||
|
TracyClient.setThreadName(string2, namePrefix.hashCode());
|
||||||
|
thread.setName(string2);
|
||||||
|
thread.setDaemon(daemon);
|
||||||
|
+ thread.setUncaughtExceptionHandler(Util::onThreadException);
|
||||||
|
+ return thread;
|
||||||
|
+ }));
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ // 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);
|
||||||
|
@@ -537,7 +583,7 @@
|
||||||
public static <K extends Enum<K>, V> EnumMap<K, V> makeEnumMap(Class<K> enumClass, Function<K, V> mapper) {
|
public static <K extends Enum<K>, V> EnumMap<K, V> makeEnumMap(Class<K> enumClass, Function<K, V> mapper) {
|
||||||
EnumMap<K, V> enumMap = new EnumMap<>(enumClass);
|
EnumMap<K, V> enumMap = new EnumMap<>(enumClass);
|
||||||
|
|
||||||
|
@ -96,7 +123,7 @@
|
||||||
enumMap.put(enum_, mapper.apply(enum_));
|
enumMap.put(enum_, mapper.apply(enum_));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1057,16 +1087,7 @@
|
@@ -1057,16 +1103,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public void openUri(URI uri) {
|
public void openUri(URI uri) {
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
--- a/net/minecraft/world/level/storage/DimensionDataStorage.java
|
||||||
|
+++ b/net/minecraft/world/level/storage/DimensionDataStorage.java
|
||||||
|
@@ -139,7 +139,7 @@
|
||||||
|
} 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 @@
|
||||||
|
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)
|
||||||
|
)
|
||||||
|
);
|
Loading…
Add table
Reference in a new issue