Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-16 03:20:07 +01:00
de04cbced5
Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: f29cb801 Separate checkstyle-suppressions file is not required 86f99bbe SPIGOT-7540, PR-946: Add ServerTickManager API d4119585 SPIGOT-6903, PR-945: Add BlockData#getMapColor b7a2ed41 SPIGOT-7530, PR-947: Add Player#removeResourcePack 9dd56255 SPIGOT-7527, PR-944: Add WindCharge#explode() 994a6163 Attempt upgrade of resolver libraries CraftBukkit Changes: b3b43a6ad Add Checkstyle check for unused imports 13fb3358e SPIGOT-7544: Scoreboard#getEntries() doesn't get entries but class names 3dda99c06 SPIGOT-7540, PR-1312: Add ServerTickManager API 2ab4508c0 SPIGOT-6903, PR-1311: Add BlockData#getMapColor 1dbdbbed4 PR-1238: Remove unnecessary sign ticking 659728d2a MC-264285, SPIGOT-7439, PR-1237: Fix unbreakable flint and steel is completely consumed while igniting creeper e37e29ce0 Increase outdated build delay c00438b39 SPIGOT-7530, PR-1313: Add Player#removeResourcePack 492dd80ce SPIGOT-7527, PR-1310: Add WindCharge#explode() e11fbb9d7 Upgrade MySQL driver 9f3a0bd2a Attempt upgrade of resolver libraries 60d16d7ca PR-1306: Centralize Bukkit and Minecraft entity conversion Spigot Changes: 06d602e7 Rebuild patches
94 Zeilen
4.8 KiB
Diff
94 Zeilen
4.8 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Aikar <aikar@aikar.co>
|
|
Date: Tue, 23 Oct 2018 23:14:38 -0400
|
|
Subject: [PATCH] Improve Server Thread Pool and Thread Priorities
|
|
|
|
Use a simple executor since Fork join is a much more complex pool
|
|
type and we are not using its capabilities.
|
|
|
|
Set thread priorities so main thread has above normal priority over
|
|
server threads
|
|
|
|
Allow usage of a single thread executor by not using ForkJoin so single core CPU's.
|
|
|
|
== AT ==
|
|
public net.minecraft.Util onThreadException(Ljava/lang/Thread;Ljava/lang/Throwable;)V
|
|
|
|
diff --git a/src/main/java/io/papermc/paper/util/ServerWorkerThread.java b/src/main/java/io/papermc/paper/util/ServerWorkerThread.java
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..b60f59cf5cc8eb84a6055b7861857dece7f2501b
|
|
--- /dev/null
|
|
+++ b/src/main/java/io/papermc/paper/util/ServerWorkerThread.java
|
|
@@ -0,0 +1,14 @@
|
|
+package io.papermc.paper.util;
|
|
+
|
|
+import java.util.concurrent.atomic.AtomicInteger;
|
|
+import net.minecraft.Util;
|
|
+
|
|
+public class ServerWorkerThread extends Thread {
|
|
+ private static final AtomicInteger threadId = new AtomicInteger(1);
|
|
+ public ServerWorkerThread(Runnable target, String poolName, int prioritityModifier) {
|
|
+ super(target, "Worker-" + poolName + "-" + threadId.getAndIncrement());
|
|
+ setPriority(Thread.NORM_PRIORITY+prioritityModifier); // Deprioritize over main
|
|
+ this.setDaemon(true);
|
|
+ this.setUncaughtExceptionHandler(Util::onThreadException);
|
|
+ }
|
|
+}
|
|
diff --git a/src/main/java/net/minecraft/Util.java b/src/main/java/net/minecraft/Util.java
|
|
index aa52b271bd556a29f774fde375b713d0d187521b..8188febd6f1039a31619b42af23df18afd2e985c 100644
|
|
--- a/src/main/java/net/minecraft/Util.java
|
|
+++ b/src/main/java/net/minecraft/Util.java
|
|
@@ -86,7 +86,7 @@ public class Util {
|
|
private static final int DEFAULT_MAX_THREADS = 255;
|
|
private static final int DEFAULT_SAFE_FILE_OPERATION_RETRIES = 10;
|
|
private static final String MAX_THREADS_SYSTEM_PROPERTY = "max.bg.threads";
|
|
- private static final ExecutorService BACKGROUND_EXECUTOR = makeExecutor("Main");
|
|
+ private static final ExecutorService BACKGROUND_EXECUTOR = makeExecutor("Main", -1); // Paper - add -1 priority
|
|
private static final ExecutorService IO_POOL = makeIoExecutor("IO-Worker-", false);
|
|
private static final ExecutorService DOWNLOAD_POOL = makeIoExecutor("Download-", true);
|
|
// Paper start - don't submit BLOCKING PROFILE LOOKUPS to the world gen thread
|
|
@@ -152,15 +152,18 @@ public class Util {
|
|
return FILENAME_DATE_TIME_FORMATTER.format(ZonedDateTime.now());
|
|
}
|
|
|
|
- private static ExecutorService makeExecutor(String name) {
|
|
- int i = Mth.clamp(Runtime.getRuntime().availableProcessors() - 1, 1, getMaxThreads());
|
|
+ private static ExecutorService makeExecutor(String s, int priorityModifier) { // Paper - add priority
|
|
+ // Paper start - use simpler thread pool that allows 1 thread
|
|
+ int i = Math.min(8, Math.max(Runtime.getRuntime().availableProcessors() - 2, 1));
|
|
+ i = Integer.getInteger("Paper.WorkerThreadCount", i);
|
|
ExecutorService executorService;
|
|
+
|
|
if (i <= 0) {
|
|
executorService = MoreExecutors.newDirectExecutorService();
|
|
} else {
|
|
- AtomicInteger atomicInteger = new AtomicInteger(1);
|
|
- executorService = new ForkJoinPool(i, (pool) -> {
|
|
- ForkJoinWorkerThread forkJoinWorkerThread = new ForkJoinWorkerThread(pool) {
|
|
+ executorService = new java.util.concurrent.ThreadPoolExecutor(i, i,0L, TimeUnit.MILLISECONDS, new java.util.concurrent.LinkedBlockingQueue<>(), target -> new io.papermc.paper.util.ServerWorkerThread(target, s, priorityModifier));
|
|
+ }
|
|
+ /*
|
|
@Override
|
|
protected void onTermination(Throwable throwable) {
|
|
if (throwable != null) {
|
|
@@ -176,6 +179,7 @@ public class Util {
|
|
return forkJoinWorkerThread;
|
|
}, Util::onThreadException, true);
|
|
}
|
|
+ }*/ // Paper end
|
|
|
|
return executorService;
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
index 06d9cafeeedb3020c5e2313d32c6fe9285f99925..eac560bf8af3c7c28ed5eed61ef352f52d823cef 100644
|
|
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
@@ -312,6 +312,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
|
thread.setUncaughtExceptionHandler((thread1, throwable) -> {
|
|
MinecraftServer.LOGGER.error("Uncaught exception in server thread", throwable);
|
|
});
|
|
+ thread.setPriority(Thread.NORM_PRIORITY+2); // Paper - boost priority
|
|
if (Runtime.getRuntime().availableProcessors() > 4) {
|
|
thread.setPriority(8);
|
|
}
|