Files
Shiroha/shiroha-server/minecraft-patches/features/0025-Force-clamp-grid-exponent-to-1-6.patch
T
NanaChiyo0721 1bb895c165
Shiroha CI / build (push) Canceled after 0s
Shiroha CI / Event File (push) Canceled after 0s
Fix incorrect ticket lock size computing
Yeah this would fully solve the issue of chunk unloading race condition

The same fix was already initially added at "Force clamp grid-exponent to 1~6"
2026-08-09 14:57:32 +08:00

30 lines
2.2 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: MrHua269 <mrhua269@gmail.com>
Date: Fri, 10 Jul 2026 15:48:51 +0800
Subject: [PATCH] Force clamp grid-exponent to 1~6
diff --git a/io/papermc/paper/threadedregions/TickRegions.java b/io/papermc/paper/threadedregions/TickRegions.java
index a6ab9cb01f4f49f5f44b6ed324fa6d51139aabb6..ab94ea7f18799d9dd3cf164a1332db69f40a9278 100644
--- a/io/papermc/paper/threadedregions/TickRegions.java
+++ b/io/papermc/paper/threadedregions/TickRegions.java
@@ -27,7 +27,7 @@ import java.util.function.BooleanSupplier;
public final class TickRegions implements ThreadedRegionizer.RegionCallbacks<TickRegions.TickRegionData, TickRegions.TickRegionSectionData> {
private static final Logger LOGGER = LogUtils.getLogger();
- private static int regionShift = 31;
+ private static int regionShift = ca.spottedleaf.moonrise.patches.chunk_system.scheduling.ThreadedTicketLevelPropagator.SECTION_SHIFT; // Shiroha - Force clamp grid-exponent to 1~6
public static int getRegionChunkShift() {
return regionShift;
@@ -68,7 +68,8 @@ public final class TickRegions implements ThreadedRegionizer.RegionCallbacks<Tic
initialised = true;
int gridExponent = config.gridExponent;
gridExponent = Math.max(0, gridExponent);
- gridExponent = Math.min(31, gridExponent);
+ if (gridExponent > ca.spottedleaf.moonrise.patches.chunk_system.scheduling.ThreadedTicketLevelPropagator.SECTION_SHIFT) LOGGER.warn("You are using a grid-exponent ({}) which is larger than the ticket lock shift! This would lead to randomly fatal crash !!!, Clamping back to max allowed {}", gridExponent, ca.spottedleaf.moonrise.patches.chunk_system.scheduling.ThreadedTicketLevelPropagator.SECTION_SHIFT); // Shiroha - Force clamp grid-exponent to 1~6
+ gridExponent = Math.min(ca.spottedleaf.moonrise.patches.chunk_system.scheduling.ThreadedTicketLevelPropagator.SECTION_SHIFT, gridExponent); // Shiroha - Force clamp grid-exponent to 1~6
regionShift = gridExponent;
scheduler = new TickRegionScheduler(config.scheduler, tickThreads);
LOGGER.info("Initialised " + config.scheduler + " Folia scheduler with initial " + tickThreads + " target thread(s)");