mirror of
https://github.com/BX-Team/DivineMC.git
synced 2025-12-19 14:59:25 +00:00
61 lines
3.7 KiB
Diff
61 lines
3.7 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com>
|
|
Date: Wed, 29 Oct 2025 01:31:51 +0300
|
|
Subject: [PATCH] Implement chunk system algorithm
|
|
|
|
This patch adds configurable chunk system algorithms for determining
|
|
worker thread allocation for chunk loading and generation.
|
|
|
|
diff --git a/src/main/java/ca/spottedleaf/moonrise/common/util/MoonriseCommon.java b/src/main/java/ca/spottedleaf/moonrise/common/util/MoonriseCommon.java
|
|
index 9a1fbd88e56f8dd01368a0a5e74cfa8c54965d7f..0a21222c77b84601841e1750daf3eb0865d99b67 100644
|
|
--- a/src/main/java/ca/spottedleaf/moonrise/common/util/MoonriseCommon.java
|
|
+++ b/src/main/java/ca/spottedleaf/moonrise/common/util/MoonriseCommon.java
|
|
@@ -34,27 +34,17 @@ public final class MoonriseCommon {
|
|
public static final BalancedPrioritisedThreadPool.OrderedStreamGroup CLIENT_GROUP = MoonriseCommon.WORKER_POOL.createOrderedStreamGroup();
|
|
public static final BalancedPrioritisedThreadPool.OrderedStreamGroup SERVER_GROUP = MoonriseCommon.WORKER_POOL.createOrderedStreamGroup();
|
|
|
|
- public static void adjustWorkerThreads(final int configWorkerThreads, final int configIoThreads) {
|
|
- int defaultWorkerThreads = Runtime.getRuntime().availableProcessors() / 2;
|
|
- if (defaultWorkerThreads <= 4) {
|
|
- defaultWorkerThreads = defaultWorkerThreads <= 3 ? 1 : 2;
|
|
- } else {
|
|
- defaultWorkerThreads = defaultWorkerThreads / 2;
|
|
- }
|
|
- defaultWorkerThreads = Integer.getInteger(PlatformHooks.get().getBrand() + ".WorkerThreadCount", Integer.valueOf(defaultWorkerThreads));
|
|
-
|
|
- int workerThreads = configWorkerThreads;
|
|
-
|
|
- if (workerThreads <= 0) {
|
|
- workerThreads = defaultWorkerThreads;
|
|
- }
|
|
-
|
|
- final int ioThreads = Math.max(1, configIoThreads);
|
|
+ public static void init(final int configWorkerThreads, final int configIoThreads) {
|
|
+ // DivineMC start - Implement chunk system algorithm
|
|
+ org.bxteam.divinemc.chunk.ChunkSystemAlgorithm algorithm = org.bxteam.divinemc.config.DivineConfig.PerformanceCategory.chunkWorkerAlgorithm;
|
|
+ int workerThreads = algorithm.evalWorkers(configWorkerThreads, configIoThreads);
|
|
+ int ioThreads = algorithm.evalIO(configWorkerThreads, configIoThreads);
|
|
+ // DivineMC end - Implement chunk system algorithm
|
|
|
|
WORKER_POOL.adjustThreadCount(workerThreads);
|
|
IO_POOL.adjustThreadCount(ioThreads);
|
|
|
|
- LOGGER.info(PlatformHooks.get().getBrand() + " is using " + workerThreads + " worker threads, " + ioThreads + " I/O threads");
|
|
+ LOGGER.info("{} is using {} worker threads, {} I/O threads", PlatformHooks.get().getBrand(), workerThreads, ioThreads); // DivineMC - Implement chunk system algorithm - better logging
|
|
}
|
|
|
|
public static final long IO_QUEUE_HOLD_TIME = (long)(25.0e6); // 25ms
|
|
diff --git a/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java b/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java
|
|
index 6c23b24477dd24ed43932d0c5ae5d97f80d968f6..982ffe9c9ec54242cdf7ee6dca42e9f815666260 100644
|
|
--- a/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java
|
|
+++ b/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java
|
|
@@ -227,7 +227,7 @@ public class GlobalConfiguration extends ConfigurationPart {
|
|
|
|
@PostProcess
|
|
private void postProcess() {
|
|
- ca.spottedleaf.moonrise.common.util.MoonriseCommon.adjustWorkerThreads(this.workerThreads, this.ioThreads);
|
|
+ ca.spottedleaf.moonrise.common.util.MoonriseCommon.init(this.workerThreads, this.ioThreads); // DivineMC - Implement chunk system algorithm
|
|
}
|
|
}
|
|
|