mirror of
https://github.com/BX-Team/DivineMC.git
synced 2025-12-19 14:59:25 +00:00
73 lines
5.6 KiB
Diff
73 lines
5.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/commands/Commands.java b/net/minecraft/commands/Commands.java
|
|
index 9a7a40c1dcea57ba674d8431077d2477104a456f..8e41097f978800039e6e057c5bbcfcf03f5a9c89 100644
|
|
--- a/net/minecraft/commands/Commands.java
|
|
+++ b/net/minecraft/commands/Commands.java
|
|
@@ -482,7 +482,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 3de2d76bf118750932a56d02233e4e6aff0b2728..690c67f2051996d0888a946b8c089d39dcb004f6 100644
|
|
--- a/net/minecraft/server/MinecraftServer.java
|
|
+++ b/net/minecraft/server/MinecraftServer.java
|
|
@@ -2738,8 +2738,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 93885af89a402bdadaccd598c7c2939c96fdf6e4..3bd279d72d06f30c9b20146ba932a8f4832dee50 100644
|
|
--- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
+++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
@@ -845,8 +845,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/ServerTextFilter.java b/net/minecraft/server/network/ServerTextFilter.java
|
|
index 37f46955af227c390329f44cbe2c58bf33672daf..c3f90c251a86ff72eb678d9ecdc572a950aeb2fd 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(
|