9
0
mirror of https://github.com/BX-Team/DivineMC.git synced 2025-12-19 14:59:25 +00:00

forgot some things

This commit is contained in:
NONPLAYT
2025-07-09 04:56:47 +03:00
parent 4b57eed3fb
commit 5d52cbcbcd
9 changed files with 59 additions and 4 deletions

View File

@@ -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

View File

@@ -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.");