Improve Thread Pool usage to allow single threads for single cpu servers

Switch to a standard fixed size ThreadPoolExecutor as we don't use the
advanced capabilities of a ForkJoinPool.

ForkJoinPool does not allow single threads, and really rather not use
2 different executor types based on core count.

Also, change thread priorities so that main thread is prioritized by
the OS at a higher priority than the other threads. May not help too much
but it at least signals the OS the information to know main is more important.
This commit is contained in:
Aikar
2020-06-02 02:19:07 -04:00
parent 55e3e3d0f8
commit 9ad7e2fe15
3 changed files with 90 additions and 33 deletions

View File

@@ -3830,19 +3830,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
}
+ // Paper end
}
diff --git a/src/main/java/net/minecraft/server/SystemUtils.java b/src/main/java/net/minecraft/server/SystemUtils.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/server/SystemUtils.java
+++ b/src/main/java/net/minecraft/server/SystemUtils.java
@@ -0,0 +0,0 @@ public class SystemUtils {
i = Integer.getInteger("Paper.WorkerThreadCount", i); // Paper - allow overriding
Object object;
- if (i <= 0) {
+ if (i <= 0 || (Runtime.getRuntime().availableProcessors() == 1 && !Boolean.getBoolean("Paper.allowAsyncChunksSingleCore"))) { // Paper - disable server worker queue if single core system
object = MoreExecutors.newDirectExecutorService();
} else {
object = new ForkJoinPool(i, (forkjoinpool) -> {
diff --git a/src/main/java/net/minecraft/server/TicketType.java b/src/main/java/net/minecraft/server/TicketType.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/server/TicketType.java