Fix loading spawn chunks when async chunks is off

I feel sorry for those who need to do this, and now feel sorry more
since back to slow startups again.

There is keep-spawn-loaded-range in paper.yml to reduce the range to
mitigate this if you must keep async chunks off.
This commit is contained in:
Aikar 2020-04-22 05:47:35 -04:00
parent 8a91bfd240
commit 509a828e06
No known key found for this signature in database
GPG key ID: 401ADFC9891FAAFE

View file

@ -1,4 +1,4 @@
From 69897be16837751a2d87f41c6fb978442000b145 Mon Sep 17 00:00:00 2001
From e3c9ff6e47758371f5ee677cede836b6756b5af9 Mon Sep 17 00:00:00 2001
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
Date: Sat, 13 Jul 2019 09:23:10 -0700
Subject: [PATCH] Asynchronous chunk IO and loading
@ -121,7 +121,7 @@ tasks required to be executed by the chunk load task (i.e lighting
and some poi tasks).
diff --git a/src/main/java/co/aikar/timings/WorldTimingsHandler.java b/src/main/java/co/aikar/timings/WorldTimingsHandler.java
index 27ce4a82..30bafb21 100644
index 27ce4a828e..30bafb214b 100644
--- a/src/main/java/co/aikar/timings/WorldTimingsHandler.java
+++ b/src/main/java/co/aikar/timings/WorldTimingsHandler.java
@@ -61,6 +61,17 @@ public class WorldTimingsHandler {
@ -161,7 +161,7 @@ index 27ce4a82..30bafb21 100644
public static Timing getTickList(WorldServer worldserver, String timingsType) {
diff --git a/src/main/java/com/destroystokyo/paper/PaperConfig.java b/src/main/java/com/destroystokyo/paper/PaperConfig.java
index dbd14399..6916ed30 100644
index dbd1439970..6916ed30c4 100644
--- a/src/main/java/com/destroystokyo/paper/PaperConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java
@@ -1,5 +1,6 @@
@ -237,7 +237,7 @@ index dbd14399..6916ed30 100644
+ }
}
diff --git a/src/main/java/com/destroystokyo/paper/antixray/ChunkPacketBlockControllerAntiXray.java b/src/main/java/com/destroystokyo/paper/antixray/ChunkPacketBlockControllerAntiXray.java
index 23626bef..1edcecd2 100644
index 23626bef3a..1edcecd2ee 100644
--- a/src/main/java/com/destroystokyo/paper/antixray/ChunkPacketBlockControllerAntiXray.java
+++ b/src/main/java/com/destroystokyo/paper/antixray/ChunkPacketBlockControllerAntiXray.java
@@ -9,6 +9,7 @@ import java.util.concurrent.Executors;
@ -318,7 +318,7 @@ index 23626bef..1edcecd2 100644
diff --git a/src/main/java/com/destroystokyo/paper/io/IOUtil.java b/src/main/java/com/destroystokyo/paper/io/IOUtil.java
new file mode 100644
index 00000000..5af0ac3d
index 0000000000..5af0ac3d9e
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/io/IOUtil.java
@@ -0,0 +1,62 @@
@ -386,7 +386,7 @@ index 00000000..5af0ac3d
+}
diff --git a/src/main/java/com/destroystokyo/paper/io/PaperFileIOThread.java b/src/main/java/com/destroystokyo/paper/io/PaperFileIOThread.java
new file mode 100644
index 00000000..4f10a831
index 0000000000..4f10a8311e
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/io/PaperFileIOThread.java
@@ -0,0 +1,661 @@
@ -1053,7 +1053,7 @@ index 00000000..4f10a831
+}
diff --git a/src/main/java/com/destroystokyo/paper/io/PrioritizedTaskQueue.java b/src/main/java/com/destroystokyo/paper/io/PrioritizedTaskQueue.java
new file mode 100644
index 00000000..97f2e433
index 0000000000..97f2e433c4
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/io/PrioritizedTaskQueue.java
@@ -0,0 +1,277 @@
@ -1336,7 +1336,7 @@ index 00000000..97f2e433
+}
diff --git a/src/main/java/com/destroystokyo/paper/io/QueueExecutorThread.java b/src/main/java/com/destroystokyo/paper/io/QueueExecutorThread.java
new file mode 100644
index 00000000..ee906b59
index 0000000000..ee906b594b
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/io/QueueExecutorThread.java
@@ -0,0 +1,241 @@
@ -1583,7 +1583,7 @@ index 00000000..ee906b59
+}
diff --git a/src/main/java/com/destroystokyo/paper/io/chunk/ChunkLoadTask.java b/src/main/java/com/destroystokyo/paper/io/chunk/ChunkLoadTask.java
new file mode 100644
index 00000000..305da478
index 0000000000..305da47868
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/io/chunk/ChunkLoadTask.java
@@ -0,0 +1,149 @@
@ -1738,7 +1738,7 @@ index 00000000..305da478
+}
diff --git a/src/main/java/com/destroystokyo/paper/io/chunk/ChunkSaveTask.java b/src/main/java/com/destroystokyo/paper/io/chunk/ChunkSaveTask.java
new file mode 100644
index 00000000..60312b85
index 0000000000..60312b85f9
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/io/chunk/ChunkSaveTask.java
@@ -0,0 +1,112 @@
@ -1856,7 +1856,7 @@ index 00000000..60312b85
+}
diff --git a/src/main/java/com/destroystokyo/paper/io/chunk/ChunkTask.java b/src/main/java/com/destroystokyo/paper/io/chunk/ChunkTask.java
new file mode 100644
index 00000000..1dfa8abf
index 0000000000..1dfa8abfd8
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/io/chunk/ChunkTask.java
@@ -0,0 +1,40 @@
@ -1902,7 +1902,7 @@ index 00000000..1dfa8abf
+}
diff --git a/src/main/java/com/destroystokyo/paper/io/chunk/ChunkTaskManager.java b/src/main/java/com/destroystokyo/paper/io/chunk/ChunkTaskManager.java
new file mode 100644
index 00000000..2b20c159
index 0000000000..2b20c159f6
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/io/chunk/ChunkTaskManager.java
@@ -0,0 +1,492 @@
@ -2399,7 +2399,7 @@ index 00000000..2b20c159
+
+}
diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java
index 262055fc..68bac9a3 100644
index 262055fccd..68bac9a3c0 100644
--- a/src/main/java/net/minecraft/server/ChunkProviderServer.java
+++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java
@@ -297,11 +297,137 @@ public class ChunkProviderServer extends IChunkProvider {
@ -2569,7 +2569,7 @@ index 262055fc..68bac9a3 100644
} finally {
playerChunkMap.callbackExecutor.run();
diff --git a/src/main/java/net/minecraft/server/ChunkRegionLoader.java b/src/main/java/net/minecraft/server/ChunkRegionLoader.java
index 8816c90e..1298a07d 100644
index 8816c90e2d..1298a07dc7 100644
--- a/src/main/java/net/minecraft/server/ChunkRegionLoader.java
+++ b/src/main/java/net/minecraft/server/ChunkRegionLoader.java
@@ -6,6 +6,7 @@ import it.unimi.dsi.fastutil.longs.LongOpenHashSet;
@ -2834,7 +2834,7 @@ index 8816c90e..1298a07d 100644
nbttagcompound1.set("PostProcessing", a(ichunkaccess.l()));
diff --git a/src/main/java/net/minecraft/server/ChunkStatus.java b/src/main/java/net/minecraft/server/ChunkStatus.java
index 134a4f0b..40ce30cd 100644
index 134a4f0b7d..40ce30cdc2 100644
--- a/src/main/java/net/minecraft/server/ChunkStatus.java
+++ b/src/main/java/net/minecraft/server/ChunkStatus.java
@@ -153,6 +153,7 @@ public class ChunkStatus {
@ -2870,7 +2870,7 @@ index 134a4f0b..40ce30cd 100644
return this.c() >= chunkstatus.c();
}
diff --git a/src/main/java/net/minecraft/server/IAsyncTaskHandler.java b/src/main/java/net/minecraft/server/IAsyncTaskHandler.java
index 7e5ece9d..cfe43e88 100644
index 7e5ece9d50..cfe43e882e 100644
--- a/src/main/java/net/minecraft/server/IAsyncTaskHandler.java
+++ b/src/main/java/net/minecraft/server/IAsyncTaskHandler.java
@@ -91,7 +91,7 @@ public abstract class IAsyncTaskHandler<R extends Runnable> implements Mailbox<R
@ -2883,7 +2883,7 @@ index 7e5ece9d..cfe43e88 100644
;
}
diff --git a/src/main/java/net/minecraft/server/IChunkLoader.java b/src/main/java/net/minecraft/server/IChunkLoader.java
index 2f95174f..134c7606 100644
index 2f95174fcc..134c76065b 100644
--- a/src/main/java/net/minecraft/server/IChunkLoader.java
+++ b/src/main/java/net/minecraft/server/IChunkLoader.java
@@ -3,37 +3,49 @@ package net.minecraft.server;
@ -3008,7 +3008,7 @@ index 2f95174f..134c7606 100644
+// Paper end
}
diff --git a/src/main/java/net/minecraft/server/MCUtil.java b/src/main/java/net/minecraft/server/MCUtil.java
index 2dcecc1b..d9941b38 100644
index 2dcecc1bbd..d9941b38ca 100644
--- a/src/main/java/net/minecraft/server/MCUtil.java
+++ b/src/main/java/net/minecraft/server/MCUtil.java
@@ -627,4 +627,9 @@ public final class MCUtil {
@ -3022,7 +3022,7 @@ index 2dcecc1b..d9941b38 100644
+ }
}
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 7ca4a7cc..61fc659e 100644
index 7ca4a7cca8..61fc659ed2 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -777,6 +777,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
@ -3034,7 +3034,7 @@ index 7ca4a7cc..61fc659e 100644
public String getServerIp() {
diff --git a/src/main/java/net/minecraft/server/NextTickListEntry.java b/src/main/java/net/minecraft/server/NextTickListEntry.java
index e9c405fb..33cfeabd 100644
index e9c405fb53..33cfeabdee 100644
--- a/src/main/java/net/minecraft/server/NextTickListEntry.java
+++ b/src/main/java/net/minecraft/server/NextTickListEntry.java
@@ -4,7 +4,7 @@ import java.util.Comparator;
@ -3056,7 +3056,7 @@ index e9c405fb..33cfeabd 100644
this.e = t0;
this.b = i;
diff --git a/src/main/java/net/minecraft/server/NibbleArray.java b/src/main/java/net/minecraft/server/NibbleArray.java
index ed8c4a87..996c8326 100644
index ed8c4a87b5..996c832638 100644
--- a/src/main/java/net/minecraft/server/NibbleArray.java
+++ b/src/main/java/net/minecraft/server/NibbleArray.java
@@ -71,6 +71,7 @@ public class NibbleArray {
@ -3068,7 +3068,7 @@ index ed8c4a87..996c8326 100644
return this.a == null ? new NibbleArray() : new NibbleArray((byte[]) this.a.clone());
}
diff --git a/src/main/java/net/minecraft/server/PlayerChunk.java b/src/main/java/net/minecraft/server/PlayerChunk.java
index f1620ba8..74e6b8b9 100644
index f1620ba80e..74e6b8b973 100644
--- a/src/main/java/net/minecraft/server/PlayerChunk.java
+++ b/src/main/java/net/minecraft/server/PlayerChunk.java
@@ -127,6 +127,18 @@ public class PlayerChunk {
@ -3113,7 +3113,7 @@ index f1620ba8..74e6b8b9 100644
completablefuture = (CompletableFuture) this.statusFutures.get(i);
if (completablefuture != null) {
diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java
index b4c9d544..7e5fa016 100644
index b4c9d544fe..7e5fa016c7 100644
--- a/src/main/java/net/minecraft/server/PlayerChunkMap.java
+++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java
@@ -63,7 +63,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@ -3596,7 +3596,7 @@ index b4c9d544..7e5fa016 100644
return this.m;
}
diff --git a/src/main/java/net/minecraft/server/RegionFile.java b/src/main/java/net/minecraft/server/RegionFile.java
index d37abf2c..df728e2c 100644
index d37abf2cf3..df728e2c0a 100644
--- a/src/main/java/net/minecraft/server/RegionFile.java
+++ b/src/main/java/net/minecraft/server/RegionFile.java
@@ -36,6 +36,8 @@ public class RegionFile implements AutoCloseable {
@ -3641,7 +3641,7 @@ index d37abf2c..df728e2c 100644
}
diff --git a/src/main/java/net/minecraft/server/RegionFileCache.java b/src/main/java/net/minecraft/server/RegionFileCache.java
index e07ae985..0f201000 100644
index e07ae98540..0f201000f6 100644
--- a/src/main/java/net/minecraft/server/RegionFileCache.java
+++ b/src/main/java/net/minecraft/server/RegionFileCache.java
@@ -9,7 +9,7 @@ import java.io.File;
@ -3746,7 +3746,7 @@ index e07ae985..0f201000 100644
return regionfile != null ? regionfile.chunkExists(pos) : false;
diff --git a/src/main/java/net/minecraft/server/RegionFileSection.java b/src/main/java/net/minecraft/server/RegionFileSection.java
index db9f0196..a6d8ef5e 100644
index db9f0196bd..a6d8ef5eb4 100644
--- a/src/main/java/net/minecraft/server/RegionFileSection.java
+++ b/src/main/java/net/minecraft/server/RegionFileSection.java
@@ -20,28 +20,29 @@ import javax.annotation.Nullable;
@ -3882,7 +3882,7 @@ index db9f0196..a6d8ef5e 100644
+ // Paper end
}
diff --git a/src/main/java/net/minecraft/server/TicketType.java b/src/main/java/net/minecraft/server/TicketType.java
index 4cf28bc2..6e0d0a54 100644
index 4cf28bc2df..6e0d0a54a2 100644
--- a/src/main/java/net/minecraft/server/TicketType.java
+++ b/src/main/java/net/minecraft/server/TicketType.java
@@ -23,6 +23,7 @@ public class TicketType<T> {
@ -3894,7 +3894,7 @@ index 4cf28bc2..6e0d0a54 100644
public static <T> TicketType<T> a(String s, Comparator<T> comparator) {
return new TicketType<>(s, comparator, 0L);
diff --git a/src/main/java/net/minecraft/server/VillagePlace.java b/src/main/java/net/minecraft/server/VillagePlace.java
index c999f8c9..b59ef1a6 100644
index c999f8c9bf..b59ef1a633 100644
--- a/src/main/java/net/minecraft/server/VillagePlace.java
+++ b/src/main/java/net/minecraft/server/VillagePlace.java
@@ -24,8 +24,16 @@ public class VillagePlace extends RegionFileSection<VillagePlaceSection> {
@ -3983,7 +3983,7 @@ index c999f8c9..b59ef1a6 100644
HAS_SPACE(VillagePlaceRecord::d), IS_OCCUPIED(VillagePlaceRecord::e), ANY((villageplacerecord) -> {
diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
index e3913952..b967f6a1 100644
index e3913952d9..3db0ad0a46 100644
--- a/src/main/java/net/minecraft/server/WorldServer.java
+++ b/src/main/java/net/minecraft/server/WorldServer.java
@@ -82,6 +82,79 @@ public class WorldServer extends World {
@ -4075,17 +4075,21 @@ index e3913952..b967f6a1 100644
}
// CraftBukkit start
@@ -1675,7 +1750,7 @@ public class WorldServer extends World {
@@ -1675,7 +1750,11 @@ public class WorldServer extends World {
}
MCUtil.getSpiralOutChunks(spawn, radiusInBlocks >> 4).forEach(pair -> {
- getChunkProvider().getChunkAtMainThread(pair.x, pair.z);
+ getChunkProvider().getChunkAtAsynchronously(pair.x, pair.z, true, (c) -> {});
+ if (com.destroystokyo.paper.PaperConfig.asyncChunks) {
+ getChunkProvider().getChunkAtAsynchronously(pair.x, pair.z, true, (c) -> {});
+ } else {
+ getChunkProvider().getChunkAtMainThread(pair.x, pair.z);
+ }
});
}
public void removeTicketsForSpawn(int radiusInBlocks, BlockPosition spawn) {
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index a71bb865..1d275520 100644
index a71bb86508..1d275520fb 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -554,22 +554,23 @@ public class CraftWorld implements World {
@ -4146,7 +4150,7 @@ index a71bb865..1d275520 100644
// Spigot start
@Override
diff --git a/src/main/java/org/spigotmc/WatchdogThread.java b/src/main/java/org/spigotmc/WatchdogThread.java
index 07936eeb..5bdcdcf9 100644
index 07936eeba2..5bdcdcf9e8 100644
--- a/src/main/java/org/spigotmc/WatchdogThread.java
+++ b/src/main/java/org/spigotmc/WatchdogThread.java
@@ -6,6 +6,7 @@ import java.lang.management.ThreadInfo;
@ -4166,5 +4170,5 @@ index 07936eeb..5bdcdcf9 100644
log.log( Level.SEVERE, "------------------------------" );
//
--
2.25.1.windows.1
2.25.1