mirror of
https://github.com/BX-Team/DivineMC.git
synced 2025-12-19 14:59:25 +00:00
Upstream has released updates that appear to apply and compile correctly Purpur Changes: PurpurMC/Purpur@47e758fb Updated Upstream (Paper)
108 lines
8.6 KiB
Diff
108 lines
8.6 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com>
|
|
Date: Mon, 24 Feb 2025 19:29:58 +0300
|
|
Subject: [PATCH] Virtual Threads
|
|
|
|
|
|
diff --git a/net/minecraft/Util.java b/net/minecraft/Util.java
|
|
index 0a69469c79aaa2466cda04f6acefed18e421d555..66f7f2aa071c2811400b4fed12ccf51ca8bb6e23 100644
|
|
--- a/net/minecraft/Util.java
|
|
+++ b/net/minecraft/Util.java
|
|
@@ -98,7 +98,12 @@ public class Util {
|
|
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() {
|
|
+ // DivineMC start - Virtual Threads
|
|
+ public static final ExecutorService PROFILE_EXECUTOR = org.bxteam.divinemc.config.DivineConfig.PerformanceCategory.virtualThreadsEnabled && org.bxteam.divinemc.config.DivineConfig.PerformanceCategory.virtualProfileLookupPool
|
|
+ ? Executors.newVirtualThreadPerTaskExecutor()
|
|
+ : Executors.newFixedThreadPool(2, new java.util.concurrent.ThreadFactory()
|
|
+ {
|
|
+ // DivineMC end - Virtual Threads
|
|
|
|
private final AtomicInteger count = new AtomicInteger();
|
|
|
|
diff --git a/net/minecraft/commands/Commands.java b/net/minecraft/commands/Commands.java
|
|
index 25aeb8628a79b62b70dbbb1299d4b4e52986b96d..62aeee570d10ab4ac5c21c88987ba6d2c75ae2b8 100644
|
|
--- a/net/minecraft/commands/Commands.java
|
|
+++ b/net/minecraft/commands/Commands.java
|
|
@@ -475,7 +475,7 @@ public class Commands {
|
|
}
|
|
|
|
// Fixed pool, but with discard policy
|
|
- public static final java.util.concurrent.ExecutorService COMMAND_SENDING_POOL = new java.util.concurrent.ThreadPoolExecutor(
|
|
+ public static final java.util.concurrent.ExecutorService COMMAND_SENDING_POOL = org.bxteam.divinemc.config.DivineConfig.PerformanceCategory.virtualThreadsEnabled && org.bxteam.divinemc.config.DivineConfig.PerformanceCategory.virtualCommandBuilderScheduler ? java.util.concurrent.Executors.newVirtualThreadPerTaskExecutor() : new java.util.concurrent.ThreadPoolExecutor( // DivineMC - Virtual Threads
|
|
2, 2, 0, java.util.concurrent.TimeUnit.MILLISECONDS,
|
|
new java.util.concurrent.LinkedBlockingQueue<>(),
|
|
new com.google.common.util.concurrent.ThreadFactoryBuilder()
|
|
diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java
|
|
index 77a693f42d90b5d17bf56d86b1676247c1ad505d..5c05a41e6f64f37fc365cde6333ed5a684f167f2 100644
|
|
--- a/net/minecraft/server/MinecraftServer.java
|
|
+++ b/net/minecraft/server/MinecraftServer.java
|
|
@@ -2638,8 +2638,11 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
|
}
|
|
}
|
|
|
|
- public final java.util.concurrent.ExecutorService chatExecutor = java.util.concurrent.Executors.newCachedThreadPool(
|
|
- new com.google.common.util.concurrent.ThreadFactoryBuilder().setDaemon(true).setNameFormat("Async Chat Thread - #%d").setUncaughtExceptionHandler(new net.minecraft.DefaultUncaughtExceptionHandlerWithName(net.minecraft.server.MinecraftServer.LOGGER)).build()); // Paper
|
|
+ // DivineMC start - Virtual Threads
|
|
+ public final java.util.concurrent.ExecutorService chatExecutor = org.bxteam.divinemc.config.DivineConfig.PerformanceCategory.virtualThreadsEnabled && org.bxteam.divinemc.config.DivineConfig.PerformanceCategory.virtualChatScheduler
|
|
+ ? java.util.concurrent.Executors.newVirtualThreadPerTaskExecutor()
|
|
+ : java.util.concurrent.Executors.newCachedThreadPool(new com.google.common.util.concurrent.ThreadFactoryBuilder().setDaemon(true).setNameFormat("Async Chat Thread - #%d").setUncaughtExceptionHandler(new net.minecraft.DefaultUncaughtExceptionHandlerWithName(net.minecraft.server.MinecraftServer.LOGGER)).build()); // Paper
|
|
+ // DivineMC end - Virtual Threads
|
|
public final ChatDecorator improvedChatDecorator = new io.papermc.paper.adventure.ImprovedChatDecorator(this); // Paper - adventure
|
|
|
|
public ChatDecorator getChatDecorator() {
|
|
diff --git a/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
index 749e7dbafa44c6dcbfcebcdcba4911b872cc12c2..506c8d2d80eee5f5351c9330a7efb3f9e4cc4cf6 100644
|
|
--- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
+++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
@@ -828,8 +828,11 @@ public class ServerGamePacketListenerImpl
|
|
}
|
|
|
|
// Paper start - AsyncTabCompleteEvent
|
|
- private static final java.util.concurrent.ExecutorService TAB_COMPLETE_EXECUTOR = java.util.concurrent.Executors.newFixedThreadPool(4,
|
|
- new com.google.common.util.concurrent.ThreadFactoryBuilder().setDaemon(true).setNameFormat("Async Tab Complete Thread - #%d").setUncaughtExceptionHandler(new net.minecraft.DefaultUncaughtExceptionHandlerWithName(MinecraftServer.LOGGER)).build());
|
|
+ // DivineMC start - Virtual Threads
|
|
+ private static final java.util.concurrent.ExecutorService TAB_COMPLETE_EXECUTOR = org.bxteam.divinemc.config.DivineConfig.PerformanceCategory.virtualThreadsEnabled && org.bxteam.divinemc.config.DivineConfig.PerformanceCategory.virtualTabCompleteScheduler
|
|
+ ? java.util.concurrent.Executors.newVirtualThreadPerTaskExecutor()
|
|
+ : java.util.concurrent.Executors.newFixedThreadPool(4, new com.google.common.util.concurrent.ThreadFactoryBuilder().setDaemon(true).setNameFormat("Async Tab Complete Thread - #%d").setUncaughtExceptionHandler(new net.minecraft.DefaultUncaughtExceptionHandlerWithName(MinecraftServer.LOGGER)).build());
|
|
+ // DivineMC end - Virtual Threads
|
|
// Paper end - AsyncTabCompleteEvent
|
|
|
|
@Override
|
|
diff --git a/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
|
|
index 637b2eb7104cb0bc7f314ad6eea11a432e899861..c461440898c98f688064f552bb0e610f657237cd 100644
|
|
--- a/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
|
|
+++ b/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
|
|
@@ -54,7 +54,11 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener,
|
|
// CraftBukkit end
|
|
private static final AtomicInteger UNIQUE_THREAD_ID = new AtomicInteger(0);
|
|
static final Logger LOGGER = LogUtils.getLogger();
|
|
- private static final java.util.concurrent.ExecutorService authenticatorPool = java.util.concurrent.Executors.newCachedThreadPool(new com.google.common.util.concurrent.ThreadFactoryBuilder().setNameFormat("User Authenticator #%d").setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(LOGGER)).build()); // Paper - Cache authenticator threads
|
|
+ // DivineMC start - Virtual Threads
|
|
+ private static final java.util.concurrent.ExecutorService authenticatorPool = org.bxteam.divinemc.config.DivineConfig.PerformanceCategory.virtualThreadsEnabled && org.bxteam.divinemc.config.DivineConfig.PerformanceCategory.virtualAuthenticatorScheduler
|
|
+ ? java.util.concurrent.Executors.newVirtualThreadPerTaskExecutor()
|
|
+ : java.util.concurrent.Executors.newCachedThreadPool(new com.google.common.util.concurrent.ThreadFactoryBuilder().setNameFormat("User Authenticator #%d").setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(LOGGER)).build()); // Paper - Cache authenticator threads
|
|
+ // DivineMC end - Virtual Threads
|
|
private static final int MAX_TICKS_BEFORE_LOGIN = 600;
|
|
private final byte[] challenge;
|
|
final MinecraftServer server;
|
|
diff --git a/net/minecraft/server/network/ServerTextFilter.java b/net/minecraft/server/network/ServerTextFilter.java
|
|
index b3d46e7687c572d9847124eb58e4a6011a78066c..9d2e2b1cff68383cd19b42e24559e3009ef1df54 100644
|
|
--- a/net/minecraft/server/network/ServerTextFilter.java
|
|
+++ b/net/minecraft/server/network/ServerTextFilter.java
|
|
@@ -48,7 +48,11 @@ public abstract class ServerTextFilter implements AutoCloseable {
|
|
final ExecutorService workerPool;
|
|
|
|
protected static ExecutorService createWorkerPool(int size) {
|
|
- return Executors.newFixedThreadPool(size, THREAD_FACTORY);
|
|
+ // DivineMC start - Virtual Threads
|
|
+ return org.bxteam.divinemc.config.DivineConfig.PerformanceCategory.virtualThreadsEnabled && org.bxteam.divinemc.config.DivineConfig.PerformanceCategory.virtualServerTextFilterPool
|
|
+ ? Executors.newVirtualThreadPerTaskExecutor()
|
|
+ : Executors.newFixedThreadPool(size, THREAD_FACTORY);
|
|
+ // DivineMC end - Virtual Threads
|
|
}
|
|
|
|
protected ServerTextFilter(
|