From d52bcc8c1d791ad564bfe048f837e91051d23b46 Mon Sep 17 00:00:00 2001 From: NanaChiyo0721 Date: Sun, 23 Aug 2026 00:07:52 +0800 Subject: [PATCH] Reduce conflict blocking for unnecessary situations --- ...blocking-for-unnecessary-situations-.patch | 122 ++++++++++++++++++ ...cket-processing-queue-with-mt-queue.patch} | 0 ...0034-Reduce-allocation-in-PoiAccess.patch} | 0 ...5-Reduce-allocation-in-SignalGetter.patch} | 0 ...location-in-unlistened-spawn-events.patch} | 0 ...ync-protocol-switching-optimization.patch} | 0 ...0038-Improved-server-health-command.patch} | 0 ...iju-Entity-tick-and-removal-limiter.patch} | 0 ...ju-Vanilla-end-portal-teleportation.patch} | 0 ...-to-support-for-long-command-inputs.patch} | 0 ...0042-Add-config-for-server-mod-name.patch} | 0 ...=> 0043-Add-config-for-cpu-affinity.patch} | 0 ...Add-config-for-unsafe-teleportation.patch} | 0 ...045-Add-config-for-watchdog-timeout.patch} | 0 ...fig-to-disable-entity-tick-catchers.patch} | 0 ...47-Add-config-for-heightmap-warning.patch} | 0 ...atch => 0048-Add-config-gui-support.patch} | 0 ...e-data-command-to-be-enabled-config.patch} | 0 ...config-for-command-block-command-ex.patch} | 0 ...-config-to-modify-tripwire-behavior.patch} | 0 ... 0052-Add-config-for-item-multitask.patch} | 0 ...3-Add-config-to-enable-tick-command.patch} | 2 +- ...-for-whether-to-save-portal-tickets.patch} | 0 ...tch => 0055-Add-portal-rate-limiter.patch} | 0 ...us-bar.patch => 0056-Add-status-bar.patch} | 0 ...patch => 0057-Leaves-Vanilla-hopper.patch} | 0 ...eaves-Lithium-Sleeping-Block-Entity.patch} | 0 ...ch => 0059-Petal-Reduce-sensor-work.patch} | 0 ...0-Purpur-Lobotomize-stuck-villagers.patch} | 0 ...ish-Reduce-projectile-chunk-loading.patch} | 0 ...le-goal-selector-during-inactive-ti.patch} | 0 ...Secure-seed-and-matter-seed-command.patch} | 0 ... => 0064-Secure-seed-V2-with-Blake3.patch} | 0 ...rain-maps-with-optimized-collection.patch} | 0 ...ss-creating-stats-json-bases-on-pla.patch} | 0 ...mize-PatchedDataComponentMap-equals.patch} | 0 ...r-checking-for-useless-move-packets.patch} | 0 ...ch => 0069-Leaf-fast-bit-radix-sort.patch} | 0 ...Configurable-vanilla-username-check.patch} | 0 ...71-Leaf-Lithium-faster-hash-palette.patch} | 0 ...cket-limit-Shiroha-Option-to-full-d.patch} | 0 ...ves-Configurable-collision-behavior.patch} | 0 ...074-Leaves-Optimized-dragon-respawn.patch} | 0 ...le-Variable-entity-wake-up-duration.patch} | 0 ...ttributes-with-optimized-collection.patch} | 0 ...kip-entity-move-if-movement-is-zero.patch} | 0 ...8-Gale-Store-mob-counts-in-an-array.patch} | 0 ...imize-random-calls-in-chunk-ticking.patch} | 0 ...uce-enderman-teleport-chunk-lookups.patch} | 0 ...> 0081-Gale-Cache-ShapePairKey-hash.patch} | 0 ...n-check-has-physics-before-same-veh.patch} | 0 ...ible-planar-movement-multiplication.patch} | 0 ...-Gale-Optimize-matching-item-checks.patch} | 0 ...a-and-Optional-allocation-in-Entity.patch} | 0 ... 0086-Gale-Reduce-array-allocations.patch} | 0 ...087-Some-optimizations-from-krypton.patch} | 0 ...imized-collections-for-WeightedList.patch} | 0 ...m-optimized-non-poi-block-searching.patch} | 0 ...p-unnecessary-secondary-poi-sensing.patch} | 0 ...h => 0091-Per-region-async-profiler.patch} | 2 +- 60 files changed, 124 insertions(+), 2 deletions(-) create mode 100644 shiroha-server/minecraft-patches/features/0032-Reduce-conflict-blocking-for-unnecessary-situations-.patch rename shiroha-server/minecraft-patches/features/{0032-Replace-packet-processing-queue-with-mt-queue.patch => 0033-Replace-packet-processing-queue-with-mt-queue.patch} (100%) rename shiroha-server/minecraft-patches/features/{0033-Reduce-allocation-in-PoiAccess.patch => 0034-Reduce-allocation-in-PoiAccess.patch} (100%) rename shiroha-server/minecraft-patches/features/{0034-Reduce-allocation-in-SignalGetter.patch => 0035-Reduce-allocation-in-SignalGetter.patch} (100%) rename shiroha-server/minecraft-patches/features/{0035-Reduce-allocation-in-unlistened-spawn-events.patch => 0036-Reduce-allocation-in-unlistened-spawn-events.patch} (100%) rename shiroha-server/minecraft-patches/features/{0036-Async-protocol-switching-optimization.patch => 0037-Async-protocol-switching-optimization.patch} (100%) rename shiroha-server/minecraft-patches/features/{0037-Improved-server-health-command.patch => 0038-Improved-server-health-command.patch} (100%) rename shiroha-server/minecraft-patches/features/{0038-Kaiiju-Entity-tick-and-removal-limiter.patch => 0039-Kaiiju-Entity-tick-and-removal-limiter.patch} (100%) rename shiroha-server/minecraft-patches/features/{0039-Kaiiju-Vanilla-end-portal-teleportation.patch => 0040-Kaiiju-Vanilla-end-portal-teleportation.patch} (100%) rename shiroha-server/minecraft-patches/features/{0040-Add-config-to-support-for-long-command-inputs.patch => 0041-Add-config-to-support-for-long-command-inputs.patch} (100%) rename shiroha-server/minecraft-patches/features/{0041-Add-config-for-server-mod-name.patch => 0042-Add-config-for-server-mod-name.patch} (100%) rename shiroha-server/minecraft-patches/features/{0042-Add-config-for-cpu-affinity.patch => 0043-Add-config-for-cpu-affinity.patch} (100%) rename shiroha-server/minecraft-patches/features/{0043-Add-config-for-unsafe-teleportation.patch => 0044-Add-config-for-unsafe-teleportation.patch} (100%) rename shiroha-server/minecraft-patches/features/{0044-Add-config-for-watchdog-timeout.patch => 0045-Add-config-for-watchdog-timeout.patch} (100%) rename shiroha-server/minecraft-patches/features/{0045-Add-config-to-disable-entity-tick-catchers.patch => 0046-Add-config-to-disable-entity-tick-catchers.patch} (100%) rename shiroha-server/minecraft-patches/features/{0046-Add-config-for-heightmap-warning.patch => 0047-Add-config-for-heightmap-warning.patch} (100%) rename shiroha-server/minecraft-patches/features/{0047-Add-config-gui-support.patch => 0048-Add-config-gui-support.patch} (100%) rename shiroha-server/minecraft-patches/features/{0048-Add-force-the-data-command-to-be-enabled-config.patch => 0049-Add-force-the-data-command-to-be-enabled-config.patch} (100%) rename shiroha-server/minecraft-patches/features/{0049-Add-experimental-config-for-command-block-command-ex.patch => 0050-Add-experimental-config-for-command-block-command-ex.patch} (100%) rename shiroha-server/minecraft-patches/features/{0050-Add-config-to-modify-tripwire-behavior.patch => 0051-Add-config-to-modify-tripwire-behavior.patch} (100%) rename shiroha-server/minecraft-patches/features/{0051-Add-config-for-item-multitask.patch => 0052-Add-config-for-item-multitask.patch} (100%) rename shiroha-server/minecraft-patches/features/{0052-Add-config-to-enable-tick-command.patch => 0053-Add-config-to-enable-tick-command.patch} (98%) rename shiroha-server/minecraft-patches/features/{0053-Add-config-for-whether-to-save-portal-tickets.patch => 0054-Add-config-for-whether-to-save-portal-tickets.patch} (100%) rename shiroha-server/minecraft-patches/features/{0054-Add-portal-rate-limiter.patch => 0055-Add-portal-rate-limiter.patch} (100%) rename shiroha-server/minecraft-patches/features/{0055-Add-status-bar.patch => 0056-Add-status-bar.patch} (100%) rename shiroha-server/minecraft-patches/features/{0056-Leaves-Vanilla-hopper.patch => 0057-Leaves-Vanilla-hopper.patch} (100%) rename shiroha-server/minecraft-patches/features/{0057-Leaves-Lithium-Sleeping-Block-Entity.patch => 0058-Leaves-Lithium-Sleeping-Block-Entity.patch} (100%) rename shiroha-server/minecraft-patches/features/{0058-Petal-Reduce-sensor-work.patch => 0059-Petal-Reduce-sensor-work.patch} (100%) rename shiroha-server/minecraft-patches/features/{0059-Purpur-Lobotomize-stuck-villagers.patch => 0060-Purpur-Lobotomize-stuck-villagers.patch} (100%) rename shiroha-server/minecraft-patches/features/{0060-Pufferfish-Reduce-projectile-chunk-loading.patch => 0061-Pufferfish-Reduce-projectile-chunk-loading.patch} (100%) rename shiroha-server/minecraft-patches/features/{0061-Pufferfish-Throttle-goal-selector-during-inactive-ti.patch => 0062-Pufferfish-Throttle-goal-selector-during-inactive-ti.patch} (100%) rename shiroha-server/minecraft-patches/features/{0062-Leaf-Secure-seed-and-matter-seed-command.patch => 0063-Leaf-Secure-seed-and-matter-seed-command.patch} (100%) rename shiroha-server/minecraft-patches/features/{0063-Secure-seed-V2-with-Blake3.patch => 0064-Secure-seed-V2-with-Blake3.patch} (100%) rename shiroha-server/minecraft-patches/features/{0064-Leaf-Replace-brain-maps-with-optimized-collection.patch => 0065-Leaf-Replace-brain-maps-with-optimized-collection.patch} (100%) rename shiroha-server/minecraft-patches/features/{0065-Leaf-Remove-useless-creating-stats-json-bases-on-pla.patch => 0066-Leaf-Remove-useless-creating-stats-json-bases-on-pla.patch} (100%) rename shiroha-server/minecraft-patches/features/{0066-Leaf-Optimize-PatchedDataComponentMap-equals.patch => 0067-Leaf-Optimize-PatchedDataComponentMap-equals.patch} (100%) rename shiroha-server/minecraft-patches/features/{0067-Leaf-Better-checking-for-useless-move-packets.patch => 0068-Leaf-Better-checking-for-useless-move-packets.patch} (100%) rename shiroha-server/minecraft-patches/features/{0068-Leaf-fast-bit-radix-sort.patch => 0069-Leaf-fast-bit-radix-sort.patch} (100%) rename shiroha-server/minecraft-patches/features/{0069-Leaf-Configurable-vanilla-username-check.patch => 0070-Leaf-Configurable-vanilla-username-check.patch} (100%) rename shiroha-server/minecraft-patches/features/{0070-Leaf-Lithium-faster-hash-palette.patch => 0071-Leaf-Lithium-faster-hash-palette.patch} (100%) rename shiroha-server/minecraft-patches/features/{0071-Leaves-Disable-packet-limit-Shiroha-Option-to-full-d.patch => 0072-Leaves-Disable-packet-limit-Shiroha-Option-to-full-d.patch} (100%) rename shiroha-server/minecraft-patches/features/{0072-Leaves-Configurable-collision-behavior.patch => 0073-Leaves-Configurable-collision-behavior.patch} (100%) rename shiroha-server/minecraft-patches/features/{0073-Leaves-Optimized-dragon-respawn.patch => 0074-Leaves-Optimized-dragon-respawn.patch} (100%) rename shiroha-server/minecraft-patches/features/{0074-Gale-Variable-entity-wake-up-duration.patch => 0075-Gale-Variable-entity-wake-up-duration.patch} (100%) rename shiroha-server/minecraft-patches/features/{0075-Gale-Replace-AI-attributes-with-optimized-collection.patch => 0076-Gale-Replace-AI-attributes-with-optimized-collection.patch} (100%) rename shiroha-server/minecraft-patches/features/{0076-Gale-Skip-entity-move-if-movement-is-zero.patch => 0077-Gale-Skip-entity-move-if-movement-is-zero.patch} (100%) rename shiroha-server/minecraft-patches/features/{0077-Gale-Store-mob-counts-in-an-array.patch => 0078-Gale-Store-mob-counts-in-an-array.patch} (100%) rename shiroha-server/minecraft-patches/features/{0078-Gale-Optimize-random-calls-in-chunk-ticking.patch => 0079-Gale-Optimize-random-calls-in-chunk-ticking.patch} (100%) rename shiroha-server/minecraft-patches/features/{0079-Gale-Reduce-enderman-teleport-chunk-lookups.patch => 0080-Gale-Reduce-enderman-teleport-chunk-lookups.patch} (100%) rename shiroha-server/minecraft-patches/features/{0080-Gale-Cache-ShapePairKey-hash.patch => 0081-Gale-Cache-ShapePairKey-hash.patch} (100%) rename shiroha-server/minecraft-patches/features/{0081-Gale-For-collision-check-has-physics-before-same-veh.patch => 0082-Gale-For-collision-check-has-physics-before-same-veh.patch} (100%) rename shiroha-server/minecraft-patches/features/{0082-Gale-Skip-negligible-planar-movement-multiplication.patch => 0083-Gale-Skip-negligible-planar-movement-multiplication.patch} (100%) rename shiroha-server/minecraft-patches/features/{0083-Gale-Optimize-matching-item-checks.patch => 0084-Gale-Optimize-matching-item-checks.patch} (100%) rename shiroha-server/minecraft-patches/features/{0084-Gale-Reduce-lambda-and-Optional-allocation-in-Entity.patch => 0085-Gale-Reduce-lambda-and-Optional-allocation-in-Entity.patch} (100%) rename shiroha-server/minecraft-patches/features/{0085-Gale-Reduce-array-allocations.patch => 0086-Gale-Reduce-array-allocations.patch} (100%) rename shiroha-server/minecraft-patches/features/{0086-Some-optimizations-from-krypton.patch => 0087-Some-optimizations-from-krypton.patch} (100%) rename shiroha-server/minecraft-patches/features/{0087-Lithium-optimized-collections-for-WeightedList.patch => 0088-Lithium-optimized-collections-for-WeightedList.patch} (100%) rename shiroha-server/minecraft-patches/features/{0088-Lithium-optimized-non-poi-block-searching.patch => 0089-Lithium-optimized-non-poi-block-searching.patch} (100%) rename shiroha-server/minecraft-patches/features/{0089-Lithium-skip-unnecessary-secondary-poi-sensing.patch => 0090-Lithium-skip-unnecessary-secondary-poi-sensing.patch} (100%) rename shiroha-server/minecraft-patches/features/{0090-Per-region-async-profiler.patch => 0091-Per-region-async-profiler.patch} (98%) diff --git a/shiroha-server/minecraft-patches/features/0032-Reduce-conflict-blocking-for-unnecessary-situations-.patch b/shiroha-server/minecraft-patches/features/0032-Reduce-conflict-blocking-for-unnecessary-situations-.patch new file mode 100644 index 0000000..d1e9d21 --- /dev/null +++ b/shiroha-server/minecraft-patches/features/0032-Reduce-conflict-blocking-for-unnecessary-situations-.patch @@ -0,0 +1,122 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: NanaChiyo0721 +Date: Sat, 22 Aug 2026 23:28:32 +0800 +Subject: [PATCH] Reduce conflict blocking for unnecessary situations in ticket + update processing + + +diff --git a/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ChunkHolderManager.java b/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ChunkHolderManager.java +index 352325aeea9e4f797893911d81703262b198ecd5..b4184b794c1e2a152531cffba493edc455399ff5 100644 +--- a/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ChunkHolderManager.java ++++ b/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ChunkHolderManager.java +@@ -1566,7 +1566,12 @@ public final class ChunkHolderManager { + BLOCK_TICKET_UPDATES.set(before); + } + ++ // Shiroha start - Reduce conflict blocking for unnecessary situations + public boolean processTicketUpdates() { ++ return processTicketUpdates(true); ++ } ++ // Shiroha end - Reduce conflict blocking for unnecessary situations ++ public boolean processTicketUpdates(boolean blockForUnacquirable) { // Shiroha - Reduce conflict blocking for unnecessary situations + final ca.spottedleaf.leafprofiler.RegionizedProfiler.Handle profiler = io.papermc.paper.threadedregions.TickRegionScheduler.getProfiler(); profiler.startTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.TICKET_LEVEL_UPDATE_PROCESSING); try { // Folia - profiler + if (BLOCK_TICKET_UPDATES.get() == Boolean.TRUE) { + throw new IllegalStateException("Cannot update ticket level while unloading chunks or updating entity manager"); +@@ -1587,7 +1592,7 @@ public final class ChunkHolderManager { + try { + ret |= this.ticketLevelPropagator.performUpdates( + this.ticketLockArea, this.taskScheduler.schedulingLockArea, +- scheduledTasks, changedFullStatus ++ scheduledTasks, changedFullStatus, blockForUnacquirable // Shiroha - Reduce conflict blocking for unnecessary situations + ); + } finally { + this.unblockTicketUpdates(Boolean.FALSE); +diff --git a/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ThreadedTicketLevelPropagator.java b/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ThreadedTicketLevelPropagator.java +index 3922616c82a9a38fb51038cd4f4c10d7921b649a..d88e7a9d681554e264429226bd695a1ce75b3876 100644 +--- a/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ThreadedTicketLevelPropagator.java ++++ b/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ThreadedTicketLevelPropagator.java +@@ -339,8 +339,15 @@ public abstract class ThreadedTicketLevelPropagator { + return ret; + } + ++ // Shiroha start - Reduce conflict blocking for unnecessary situations + public boolean performUpdates(final ReentrantAreaLock ticketLock, final ReentrantAreaLock schedulingLock, + final List scheduledTasks, final List changedFullStatus) { ++ return this.performUpdates(ticketLock, schedulingLock, scheduledTasks, changedFullStatus, true); ++ } ++ // Shiroha end - Reduce conflict blocking for unnecessary situations ++ ++ public boolean performUpdates(final ReentrantAreaLock ticketLock, final ReentrantAreaLock schedulingLock, ++ final List scheduledTasks, final List changedFullStatus, boolean blockForUnacquirableNode) { // Shiroha - Reduce conflict blocking for unnecessary situations + if (this.updateQueue.isEmpty()) { + return false; + } +@@ -351,9 +358,9 @@ public abstract class ThreadedTicketLevelPropagator { + Propagator propagator = null; + + for (;;) { +- final UpdateQueue.UpdateQueueNode toUpdate = this.updateQueue.acquireNextOrWait(maxOrder); ++ final UpdateQueue.UpdateQueueNode toUpdate = this.updateQueue.acquireNextOrWait(maxOrder, blockForUnacquirableNode); // Shiroha - Reduce conflict blocking for unnecessary situations + if (toUpdate == null) { +- if (!this.updateQueue.hasRemainingUpdates(maxOrder)) { ++ if (!this.updateQueue.hasRemainingUpdates(maxOrder) || !blockForUnacquirableNode) { // Shiroha - Reduce conflict blocking for unnecessary situations + if (propagator != null) { + Propagator.returnPropagator(propagator); + } +@@ -467,7 +474,7 @@ public abstract class ThreadedTicketLevelPropagator { + } + } + +- public UpdateQueueNode acquireNextOrWait(final long maxOrder) { ++ public UpdateQueueNode acquireNextOrWait(final long maxOrder, boolean blockForUnacquirable) { // Shiroha - Reduce conflict blocking for unnecessary situations + final List blocking = new ArrayList<>(); + + node_search: +@@ -497,7 +504,7 @@ public abstract class ThreadedTicketLevelPropagator { + return curr; + } + +- if (!blocking.isEmpty()) { ++ if (!blocking.isEmpty() && blockForUnacquirable) { // Shiroha - Reduce conflict blocking for unnecessary situations + await(blocking.get(0)); + } + +diff --git a/io/papermc/paper/threadedregions/RegionizedServer.java b/io/papermc/paper/threadedregions/RegionizedServer.java +index aa575f3b76ef70ffb9f0410e7e5cfe7af384bfbd..4b8287ab2c674b773c5ed254f5c6e72ece851684 100644 +--- a/io/papermc/paper/threadedregions/RegionizedServer.java ++++ b/io/papermc/paper/threadedregions/RegionizedServer.java +@@ -371,7 +371,7 @@ public final class RegionizedServer { + + world.updateTickData(); + +- world.moonrise$getChunkTaskScheduler().chunkHolderManager.processTicketUpdates(); // required to eventually process ticket updates ++ world.moonrise$getChunkTaskScheduler().chunkHolderManager.processTicketUpdates(false); // required to eventually process ticket updates // Shiroha - Reduce conflict blocking for unnecessary situations + + this.autoSaveMaps(world); + } +diff --git a/io/papermc/paper/threadedregions/RegionizedTaskQueue.java b/io/papermc/paper/threadedregions/RegionizedTaskQueue.java +index 3a7e4b57dc41030295f5e9da58a0fcd1270c521f..863421cedc33204a60ac77af30b67cca8a268dea 100644 +--- a/io/papermc/paper/threadedregions/RegionizedTaskQueue.java ++++ b/io/papermc/paper/threadedregions/RegionizedTaskQueue.java +@@ -386,7 +386,7 @@ public final class RegionizedTaskQueue { + + if (processedChunkTask) { // Shiroha - Fix wrong ticket update determination in RegionizedTaskQueue + // if we executed chunk tasks, we should try to process ticket updates for full status changes +- this.worldRegionTaskData.world.moonrise$getChunkTaskScheduler().chunkHolderManager.processTicketUpdates(); ++ this.worldRegionTaskData.world.moonrise$getChunkTaskScheduler().chunkHolderManager.processTicketUpdates(false); // Shiroha - Reduce conflict blocking for unnecessary situations + } + } + +diff --git a/io/papermc/paper/threadedregions/TickRegions.java b/io/papermc/paper/threadedregions/TickRegions.java +index ab94ea7f18799d9dd3cf164a1332db69f40a9278..ca24971a1dc7576e6f216dfc0fe56d2e5195a14f 100644 +--- a/io/papermc/paper/threadedregions/TickRegions.java ++++ b/io/papermc/paper/threadedregions/TickRegions.java +@@ -508,7 +508,7 @@ public final class TickRegions implements ThreadedRegionizer.RegionCallbacks