Paper/patches/server/0746-ChunkMap.mainInvokingExecutor.patch
Shane Freeder aa52bf9e33
Remove "Implement-Chunk-Priority-Urgency-System-for-Chunks" (Fixes #5980)
Mojang made some changes to priorities in 1.17 and it seems that these changes
conflict with the changes made in this patch, which in some cases appears to
cause excessive rescheduling of tasks.

This, however, is not confirmed as such but seems to be the behavior that we're
seeing to cause this issue, if mojang has adopted the changes we suggested,
then a good chunk of this patch may be unneeded, but, this needs a much better
look than I'm currently able to do
2021-08-14 14:55:55 +01:00

37 lines
1.8 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Shane Freeder <theboyetronic@gmail.com>
Date: Sat, 14 Aug 2021 14:49:45 +0100
Subject: [PATCH] ChunkMap.mainInvokingExecutor
This is a temp patch, this should maybe be moved to a more generic map or potentially wrapped into mcutil for the sake of this being such a generic concept
anyways
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index c42f564ecac75f7947c580e7514795c26097761e..70891232460665ff0d1f80ff09e3773753168d4a 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -150,6 +150,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
public final ServerLevel level;
private final ThreadedLevelLightEngine lightEngine;
private final BlockableEventLoop<Runnable> mainThreadExecutor;
+ final java.util.concurrent.Executor mainInvokingExecutor; // Paper // Paper - Move to MCUtil?
public final ChunkGenerator generator;
public final Supplier<DimensionDataStorage> overworldDataStorage;
private final PoiManager poiManager;
@@ -355,6 +356,15 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
this.level = world;
this.generator = chunkGenerator;
this.mainThreadExecutor = mainThreadExecutor;
+ // Paper start
+ this.mainInvokingExecutor = (run) -> {
+ if (MCUtil.isMainThread()) {
+ run.run();
+ } else {
+ mainThreadExecutor.execute(run);
+ }
+ };
+ // Paper end
ProcessorMailbox<Runnable> threadedmailbox = ProcessorMailbox.create(executor, "worldgen");
Objects.requireNonNull(mainThreadExecutor);