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
and reduce worldgen thread worker count for low core count CPUs.

== AT ==
public net.minecraft.Util onThreadException(Ljava/lang/Thread;Ljava/lang/Throwable;)V

Co-authored-by: Spottedleaf <Spottedleaf@users.noreply.github.com>
This commit is contained in:
Aikar
2018-10-23 23:14:38 -04:00
parent 539f1ba018
commit 9902ba8869
3 changed files with 129 additions and 52 deletions

View File

@@ -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);
}
}