perf(payload): fast-path idle dimensions + scoped ownership

补充上一版按维度精细化独占:
- MainThreadPhaseCoordinator.runScoped 加快速路径:涉及维度当前都没在 tick 时,
  直接执行 action,跳过 hold/cancel/schedule 与 managedBlock 往返。
  多玩家时绝大多数 payload 落在维度空闲窗口,此路径消除其交接开销。
This commit is contained in:
Xiao-no-love committed 2026-10-13 17:45:24 +08:00
1 parent 490be29f57
commit d231930c6b
1 file changed
+7
@@ -97,6 +97,13 @@ public final class MainThreadPhaseCoordinator {
throw new IllegalStateException("Scoped phase inside synchronous Sable handoff would deadlock: " + reason);
List<LevelTickLoop> affected = loops(server).stream()
.filter(l -> scopeDimensions.contains(l.getLevel().dimension())).toList();
// 快速路径:涉及维度当前都没在 tick -> 无需挂起/等待,直接执行。
// 多玩家时绝大多数 payload 落在「维度空闲窗口」,此路径避免每次 drain 的
// hold/cancel/schedule 开销与 managedBlock 往返。
if (affected.stream().noneMatch(LevelTickLoop::isTicking)) {
action.run();
return;
}
affected.forEach(loop -> loop.holdForMainThread(true));
long began = System.nanoTime();
try {