diff --git a/divinemc-server/paper-patches/features/0015-Virtual-Threads.patch b/divinemc-server/paper-patches/features/0015-Virtual-Threads.patch new file mode 100644 index 0000000..80f48f8 --- /dev/null +++ b/divinemc-server/paper-patches/features/0015-Virtual-Threads.patch @@ -0,0 +1,59 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com> +Date: Mon, 24 Feb 2025 19:36:33 +0300 +Subject: [PATCH] Virtual Threads + + +diff --git a/src/main/java/io/papermc/paper/util/MCUtil.java b/src/main/java/io/papermc/paper/util/MCUtil.java +index 8492a06883e2ff597bbbdaa74fe5e5cdd0a0a1b1..862e49f510720f3546c339f5c4cf1945303dd8c9 100644 +--- a/src/main/java/io/papermc/paper/util/MCUtil.java ++++ b/src/main/java/io/papermc/paper/util/MCUtil.java +@@ -37,7 +37,7 @@ public final class MCUtil { + run.run(); + } + }; +- public static final ExecutorService ASYNC_EXECUTOR = Executors.newFixedThreadPool(2, new ThreadFactoryBuilder() ++ public static final ExecutorService ASYNC_EXECUTOR = org.bxteam.divinemc.config.DivineConfig.PerformanceCategory.virtualThreadsEnabled && org.bxteam.divinemc.config.DivineConfig.PerformanceCategory.virtualAsyncExecutor ? Executors.newVirtualThreadPerTaskExecutor() : Executors.newFixedThreadPool(2, new ThreadFactoryBuilder() // DivineMC - Virtual Threads + .setNameFormat("Paper Async Task Handler Thread - %1$d") + .setUncaughtExceptionHandler(new net.minecraft.DefaultUncaughtExceptionHandlerWithName(MinecraftServer.LOGGER)) + .build() +diff --git a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftAsyncScheduler.java b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftAsyncScheduler.java +index 0ca279fb71d39c81b1f608e0ee9ba3e498d55fa3..8f82c034de320af7b65bad1602ebb561dd844e59 100644 +--- a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftAsyncScheduler.java ++++ b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftAsyncScheduler.java +@@ -31,14 +31,18 @@ import java.util.ArrayList; + import java.util.Iterator; + import java.util.List; + import java.util.concurrent.Executor; ++import java.util.concurrent.ExecutorService; + import java.util.concurrent.Executors; + import java.util.concurrent.SynchronousQueue; + import java.util.concurrent.ThreadPoolExecutor; + import java.util.concurrent.TimeUnit; + + public class CraftAsyncScheduler extends CraftScheduler { +- +- private final ThreadPoolExecutor executor = new ThreadPoolExecutor( ++ // DivineMC start - Virtual Threads ++ private final ExecutorService executor = org.bxteam.divinemc.config.DivineConfig.PerformanceCategory.virtualThreadsEnabled && org.bxteam.divinemc.config.DivineConfig.PerformanceCategory.virtualBukkitScheduler ++ ? Executors.newVirtualThreadPerTaskExecutor() ++ : new ThreadPoolExecutor( ++ // DivineMC end - Virtual Threads + 4, Integer.MAX_VALUE,30L, TimeUnit.SECONDS, new SynchronousQueue<>(), + new ThreadFactoryBuilder().setNameFormat("Craft Scheduler Thread - %1$d").build()); + private final Executor management = Executors.newSingleThreadExecutor(new ThreadFactoryBuilder() +@@ -47,8 +51,12 @@ public class CraftAsyncScheduler extends CraftScheduler { + + CraftAsyncScheduler() { + super(true); +- executor.allowCoreThreadTimeOut(true); +- executor.prestartAllCoreThreads(); ++ // DivineMC start - Virtual Threads ++ if (!org.bxteam.divinemc.config.DivineConfig.PerformanceCategory.virtualThreadsEnabled && !org.bxteam.divinemc.config.DivineConfig.PerformanceCategory.virtualBukkitScheduler) { ++ ((ThreadPoolExecutor) executor).allowCoreThreadTimeOut(true); ++ ((ThreadPoolExecutor) executor).prestartAllCoreThreads(); ++ } ++ // DivineMC end - Virtual Threads + } + + @Override diff --git a/divinemc-server/paper-patches/features/0015-Implement-Secure-Seed.patch b/divinemc-server/paper-patches/features/0016-Implement-Secure-Seed.patch similarity index 100% rename from divinemc-server/paper-patches/features/0015-Implement-Secure-Seed.patch rename to divinemc-server/paper-patches/features/0016-Implement-Secure-Seed.patch diff --git a/divinemc-server/paper-patches/features/0016-Petal-Multithreaded-Tracker.patch b/divinemc-server/paper-patches/features/0017-Petal-Multithreaded-Tracker.patch similarity index 100% rename from divinemc-server/paper-patches/features/0016-Petal-Multithreaded-Tracker.patch rename to divinemc-server/paper-patches/features/0017-Petal-Multithreaded-Tracker.patch diff --git a/divinemc-server/paper-patches/features/0017-Pufferfish-Optimize-mob-spawning.patch b/divinemc-server/paper-patches/features/0018-Pufferfish-Optimize-mob-spawning.patch similarity index 100% rename from divinemc-server/paper-patches/features/0017-Pufferfish-Optimize-mob-spawning.patch rename to divinemc-server/paper-patches/features/0018-Pufferfish-Optimize-mob-spawning.patch diff --git a/divinemc-server/paper-patches/features/0018-Pufferfish-Simpler-ShapelessRecipes-comparison-for-V.patch b/divinemc-server/paper-patches/features/0019-Pufferfish-Simpler-ShapelessRecipes-comparison-for-V.patch similarity index 100% rename from divinemc-server/paper-patches/features/0018-Pufferfish-Simpler-ShapelessRecipes-comparison-for-V.patch rename to divinemc-server/paper-patches/features/0019-Pufferfish-Simpler-ShapelessRecipes-comparison-for-V.patch diff --git a/divinemc-server/paper-patches/features/0019-SparklyPaper-Parallel-world-ticking.patch b/divinemc-server/paper-patches/features/0020-SparklyPaper-Parallel-world-ticking.patch similarity index 100% rename from divinemc-server/paper-patches/features/0019-SparklyPaper-Parallel-world-ticking.patch rename to divinemc-server/paper-patches/features/0020-SparklyPaper-Parallel-world-ticking.patch diff --git a/divinemc-server/paper-patches/features/0020-Rewrite-ReferenceList.patch b/divinemc-server/paper-patches/features/0021-Rewrite-ReferenceList.patch similarity index 100% rename from divinemc-server/paper-patches/features/0020-Rewrite-ReferenceList.patch rename to divinemc-server/paper-patches/features/0021-Rewrite-ReferenceList.patch diff --git a/divinemc-server/paper-patches/features/0021-Configurable-Max-View-Distance.patch b/divinemc-server/paper-patches/features/0022-Configurable-Max-View-Distance.patch similarity index 100% rename from divinemc-server/paper-patches/features/0021-Configurable-Max-View-Distance.patch rename to divinemc-server/paper-patches/features/0022-Configurable-Max-View-Distance.patch diff --git a/divinemc-server/src/main/java/org/bxteam/divinemc/config/DivineConfig.java b/divinemc-server/src/main/java/org/bxteam/divinemc/config/DivineConfig.java index 14ac0ee..933eb96 100644 --- a/divinemc-server/src/main/java/org/bxteam/divinemc/config/DivineConfig.java +++ b/divinemc-server/src/main/java/org/bxteam/divinemc/config/DivineConfig.java @@ -338,7 +338,6 @@ public class DivineConfig { public static long chunkDataCacheLimit = 32678L; public static int maxViewDistance = 32; public static int playerNearChunkDetectionRange = 128; - public static int threadPoolPriority = Thread.NORM_PRIORITY + 1; public static boolean smoothBedrockLayer = false; public static boolean enableDensityFunctionCompiler = false; public static boolean enableStructureLayoutOptimizer = true; @@ -401,9 +400,6 @@ public class DivineConfig { playerNearChunkDetectionRange = 128; } - threadPoolPriority = getInt(ConfigCategory.PERFORMANCE.key("chunks.thread-pool-priority"), threadPoolPriority, - "Sets the priority of the thread pool used for chunk generation"); - smoothBedrockLayer = getBoolean(ConfigCategory.PERFORMANCE.key("chunks.smooth-bedrock-layer"), smoothBedrockLayer, "Smoothens the bedrock layer at the bottom of overworld, and on the top of nether during the world generation.");