Reduce conflict blocking for unnecessary situations
This commit is contained in:
+122
@@ -0,0 +1,122 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: NanaChiyo0721 <nanachiyo0721@163.com>
|
||||||
|
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<ChunkProgressionTask> scheduledTasks, final List<NewChunkHolder> 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<ChunkProgressionTask> scheduledTasks, final List<NewChunkHolder> 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<UpdateQueueNode> 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<Tic
|
||||||
|
|
||||||
|
if (processedChunkTask) {
|
||||||
|
// if we processed any chunk tasks, try to process ticket level updates for full status changes
|
||||||
|
- this.region.world.moonrise$getChunkTaskScheduler().chunkHolderManager.processTicketUpdates();
|
||||||
|
+ this.region.world.moonrise$getChunkTaskScheduler().chunkHolderManager.processTicketUpdates(false); // Shiroha - Reduce conflict blocking for unnecessary situations
|
||||||
|
}
|
||||||
|
} finally { profiler.stopInBetweenTick(); } // Folia - profiler
|
||||||
|
}
|
||||||
+1
-1
@@ -6,7 +6,7 @@ Subject: [PATCH] Add config to enable tick command
|
|||||||
only freeze/unfreeze/step/query can run when enabled
|
only freeze/unfreeze/step/query can run when enabled
|
||||||
|
|
||||||
diff --git a/io/papermc/paper/threadedregions/RegionizedServer.java b/io/papermc/paper/threadedregions/RegionizedServer.java
|
diff --git a/io/papermc/paper/threadedregions/RegionizedServer.java b/io/papermc/paper/threadedregions/RegionizedServer.java
|
||||||
index aa575f3b76ef70ffb9f0410e7e5cfe7af384bfbd..5f6d6533067863d609484d1463fe4e64ff5f683c 100644
|
index 4b8287ab2c674b773c5ed254f5c6e72ece851684..feb21d91691e849c15976ff1f9482ad1049c4ab8 100644
|
||||||
--- a/io/papermc/paper/threadedregions/RegionizedServer.java
|
--- a/io/papermc/paper/threadedregions/RegionizedServer.java
|
||||||
+++ b/io/papermc/paper/threadedregions/RegionizedServer.java
|
+++ b/io/papermc/paper/threadedregions/RegionizedServer.java
|
||||||
@@ -233,6 +233,11 @@ public final class RegionizedServer {
|
@@ -233,6 +233,11 @@ public final class RegionizedServer {
|
||||||
+1
-1
@@ -65,7 +65,7 @@ index 724332d074bd7d3dfdcb60e83cf1fd6ce706000e..eb65077d18d86fce3ae1131445ebdcb7
|
|||||||
final long tickEnd = System.nanoTime();
|
final long tickEnd = System.nanoTime();
|
||||||
final long cpuEnd = MEASURE_CPU_TIME ? THREAD_MX_BEAN.getCurrentThreadCpuTime() : 0L;
|
final long cpuEnd = MEASURE_CPU_TIME ? THREAD_MX_BEAN.getCurrentThreadCpuTime() : 0L;
|
||||||
diff --git a/io/papermc/paper/threadedregions/TickRegions.java b/io/papermc/paper/threadedregions/TickRegions.java
|
diff --git a/io/papermc/paper/threadedregions/TickRegions.java b/io/papermc/paper/threadedregions/TickRegions.java
|
||||||
index ab94ea7f18799d9dd3cf164a1332db69f40a9278..863f78680150d87c5b82132e471baac527452b6b 100644
|
index ca24971a1dc7576e6f216dfc0fe56d2e5195a14f..aacf39922a7e338351a7fe89956162ba736d2cc2 100644
|
||||||
--- a/io/papermc/paper/threadedregions/TickRegions.java
|
--- a/io/papermc/paper/threadedregions/TickRegions.java
|
||||||
+++ b/io/papermc/paper/threadedregions/TickRegions.java
|
+++ b/io/papermc/paper/threadedregions/TickRegions.java
|
||||||
@@ -36,10 +36,12 @@ public final class TickRegions implements ThreadedRegionizer.RegionCallbacks<Tic
|
@@ -36,10 +36,12 @@ public final class TickRegions implements ThreadedRegionizer.RegionCallbacks<Tic
|
||||||
Reference in New Issue
Block a user