From c6fc144ba0088b5daa2f2ea8415e8e5cf7ae9c86 Mon Sep 17 00:00:00 2001 From: Spottedleaf Date: Mon, 28 Feb 2022 18:33:20 -0800 Subject: [PATCH] Fix unload stall Also added required tickets that should not be removed during shutdown --- patches/server/0006-MC-Utils.patch | 13 +++++++++++-- .../0257-Asynchronous-chunk-IO-and-loading.patch | 13 +++++++++++++ ...ad-calls-removing-tickets-for-sync-loads.patch | 13 +++++++++++++ .../server/0807-Rewrite-the-light-engine.patch | 15 ++++++++++++++- .../0864-Replace-player-chunk-loader-system.patch | 11 ++++++----- .../0866-Replace-ticket-level-propagator.patch | 4 ++-- 6 files changed, 59 insertions(+), 10 deletions(-) diff --git a/patches/server/0006-MC-Utils.patch b/patches/server/0006-MC-Utils.patch index 31374dfb5..04cfaaa99 100644 --- a/patches/server/0006-MC-Utils.patch +++ b/patches/server/0006-MC-Utils.patch @@ -5464,7 +5464,7 @@ index 27592093939d3ee3d0395527eead160ecec9330c..a5eb77f3d7cdbf656d11e97f4c27054b @Override diff --git a/src/main/java/net/minecraft/server/level/DistanceManager.java b/src/main/java/net/minecraft/server/level/DistanceManager.java -index 6c98676827ceb6999f340fa2b06a0b3e1cb4cae2..2012831c4e9573118209672c8a0170573566b491 100644 +index 6c98676827ceb6999f340fa2b06a0b3e1cb4cae2..f08089b8672454acf8c2309e850466b335248692 100644 --- a/src/main/java/net/minecraft/server/level/DistanceManager.java +++ b/src/main/java/net/minecraft/server/level/DistanceManager.java @@ -60,8 +60,9 @@ public abstract class DistanceManager { @@ -5486,6 +5486,15 @@ index 6c98676827ceb6999f340fa2b06a0b3e1cb4cae2..2012831c4e9573118209672c8a017057 } protected void purgeStaleTickets() { +@@ -382,7 +384,7 @@ public abstract class DistanceManager { + } + + public void removeTicketsOnClosing() { +- ImmutableSet> immutableset = ImmutableSet.of(TicketType.UNKNOWN, TicketType.POST_TELEPORT, TicketType.LIGHT); ++ ImmutableSet> immutableset = ImmutableSet.of(TicketType.UNKNOWN, TicketType.POST_TELEPORT, TicketType.LIGHT, TicketType.FUTURE_AWAIT); // Paper - add additional tickets to preserve + ObjectIterator objectiterator = this.tickets.long2ObjectEntrySet().fastIterator(); + + while (objectiterator.hasNext()) { diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java index 2015e527044db26bed960b2915b5422a7d7ad0e3..94d717f43336ace9375409b48d1e0e4291072656 100644 --- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java @@ -6121,7 +6130,7 @@ index 197a27274c9277c41bb7fcda34afa7ef652e1a9b..c94c62e7e32f55d322ddfed930e1aaa6 @Override public float getBukkitYaw() { diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java -index 351f7c08d5903113ba19205509e3fc68fc31e338..711c130a6d725d8a7f2a77e74b51c6123d7856d2 100644 +index aebf603ed909eb36d02f30391c56c85f8508361e..ee0bf9cd5da91bd5593e4e183084b5db77522cce 100644 --- a/src/main/java/net/minecraft/world/entity/Mob.java +++ b/src/main/java/net/minecraft/world/entity/Mob.java @@ -238,6 +238,7 @@ public abstract class Mob extends LivingEntity { diff --git a/patches/server/0257-Asynchronous-chunk-IO-and-loading.patch b/patches/server/0257-Asynchronous-chunk-IO-and-loading.patch index fc3ef231e..956b289d8 100644 --- a/patches/server/0257-Asynchronous-chunk-IO-and-loading.patch +++ b/patches/server/0257-Asynchronous-chunk-IO-and-loading.patch @@ -2610,6 +2610,19 @@ index b64f42b9ca1da5b6d5c290c157e510797e524117..6a7e6cbc188619b0239e97237069c895 @Nullable public CompoundTag readChunk(ChunkPos pos) throws IOException { CompoundTag nbttagcompound = this.read(pos); +diff --git a/src/main/java/net/minecraft/server/level/DistanceManager.java b/src/main/java/net/minecraft/server/level/DistanceManager.java +index f08089b8672454acf8c2309e850466b335248692..ab785bfc29c0b120b7c6fed2d15460c86e020291 100644 +--- a/src/main/java/net/minecraft/server/level/DistanceManager.java ++++ b/src/main/java/net/minecraft/server/level/DistanceManager.java +@@ -384,7 +384,7 @@ public abstract class DistanceManager { + } + + public void removeTicketsOnClosing() { +- ImmutableSet> immutableset = ImmutableSet.of(TicketType.UNKNOWN, TicketType.POST_TELEPORT, TicketType.LIGHT, TicketType.FUTURE_AWAIT); // Paper - add additional tickets to preserve ++ ImmutableSet> immutableset = ImmutableSet.of(TicketType.UNKNOWN, TicketType.POST_TELEPORT, TicketType.LIGHT, TicketType.FUTURE_AWAIT, TicketType.ASYNC_LOAD); // Paper - add additional tickets to preserve + ObjectIterator objectiterator = this.tickets.long2ObjectEntrySet().fastIterator(); + + while (objectiterator.hasNext()) { diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java index efb735f2cf0d232db83ade7332250e455c276bea..b6737c0b74e821c948919ca4184dfe0281a19894 100644 --- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java diff --git a/patches/server/0742-Prevent-unload-calls-removing-tickets-for-sync-loads.patch b/patches/server/0742-Prevent-unload-calls-removing-tickets-for-sync-loads.patch index ef1dd7758..e2c441623 100644 --- a/patches/server/0742-Prevent-unload-calls-removing-tickets-for-sync-loads.patch +++ b/patches/server/0742-Prevent-unload-calls-removing-tickets-for-sync-loads.patch @@ -4,6 +4,19 @@ Date: Thu, 18 Jun 2020 18:23:20 -0700 Subject: [PATCH] Prevent unload() calls removing tickets for sync loads +diff --git a/src/main/java/net/minecraft/server/level/DistanceManager.java b/src/main/java/net/minecraft/server/level/DistanceManager.java +index d2865ce0523b74aaa935db72c6f3478894e13408..ea4e46c113d3f0a5db6c891021e2e4c5eb275cd4 100644 +--- a/src/main/java/net/minecraft/server/level/DistanceManager.java ++++ b/src/main/java/net/minecraft/server/level/DistanceManager.java +@@ -545,7 +545,7 @@ public abstract class DistanceManager { + } + + public void removeTicketsOnClosing() { +- ImmutableSet> immutableset = ImmutableSet.of(TicketType.UNKNOWN, TicketType.POST_TELEPORT, TicketType.LIGHT, TicketType.FUTURE_AWAIT, TicketType.ASYNC_LOAD); // Paper - add additional tickets to preserve ++ ImmutableSet> immutableset = ImmutableSet.of(TicketType.UNKNOWN, TicketType.POST_TELEPORT, TicketType.LIGHT, TicketType.FUTURE_AWAIT, TicketType.ASYNC_LOAD, TicketType.REQUIRED_LOAD); // Paper - add additional tickets to preserve + ObjectIterator objectiterator = this.tickets.long2ObjectEntrySet().fastIterator(); + + while (objectiterator.hasNext()) { diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java index 718c89f421637d623a92e5167397870562593a04..adab778c11ef11cb57418675a98129afb01ec06e 100644 --- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java diff --git a/patches/server/0807-Rewrite-the-light-engine.patch b/patches/server/0807-Rewrite-the-light-engine.patch index 19214644e..159272cec 100644 --- a/patches/server/0807-Rewrite-the-light-engine.patch +++ b/patches/server/0807-Rewrite-the-light-engine.patch @@ -4432,7 +4432,7 @@ index 1a7fc533afced7235162f81b2de8148cef05414a..36b6e7295cf7484675c8c2b9624c1f6f private final DebugBuffer chunkToSaveHistory; public int oldTicketLevel; diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java -index 5a4431adefa6d0baef1d46b97a2ee7d5d6a56ec9..0120480bc569f84d9036b90fd0c0f2f33c9c6a9f 100644 +index 7f73703cf9dc4ecdd049d6c72c0ecbdcca95a784..7d877eb5f87b718306ac2fd6cf2dd4106d99d823 100644 --- a/src/main/java/net/minecraft/server/level/ChunkMap.java +++ b/src/main/java/net/minecraft/server/level/ChunkMap.java @@ -133,7 +133,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -4444,6 +4444,19 @@ index 5a4431adefa6d0baef1d46b97a2ee7d5d6a56ec9..0120480bc569f84d9036b90fd0c0f2f3 final java.util.concurrent.Executor mainInvokingExecutor; // Paper public ChunkGenerator generator; public final Supplier overworldDataStorage; +diff --git a/src/main/java/net/minecraft/server/level/DistanceManager.java b/src/main/java/net/minecraft/server/level/DistanceManager.java +index ea4e46c113d3f0a5db6c891021e2e4c5eb275cd4..b22c771ca35466574d5a73f2da3fc8762cb29487 100644 +--- a/src/main/java/net/minecraft/server/level/DistanceManager.java ++++ b/src/main/java/net/minecraft/server/level/DistanceManager.java +@@ -545,7 +545,7 @@ public abstract class DistanceManager { + } + + public void removeTicketsOnClosing() { +- ImmutableSet> immutableset = ImmutableSet.of(TicketType.UNKNOWN, TicketType.POST_TELEPORT, TicketType.LIGHT, TicketType.FUTURE_AWAIT, TicketType.ASYNC_LOAD, TicketType.REQUIRED_LOAD); // Paper - add additional tickets to preserve ++ ImmutableSet> immutableset = ImmutableSet.of(TicketType.UNKNOWN, TicketType.POST_TELEPORT, TicketType.LIGHT, TicketType.FUTURE_AWAIT, TicketType.ASYNC_LOAD, TicketType.REQUIRED_LOAD, TicketType.CHUNK_RELIGHT, ca.spottedleaf.starlight.common.light.StarLightInterface.CHUNK_WORK_TICKET); // Paper - add additional tickets to preserve + ObjectIterator objectiterator = this.tickets.long2ObjectEntrySet().fastIterator(); + + while (objectiterator.hasNext()) { diff --git a/src/main/java/net/minecraft/server/level/ThreadedLevelLightEngine.java b/src/main/java/net/minecraft/server/level/ThreadedLevelLightEngine.java index bd475554a630fb68433dd6e6640586cf5240cfed..d572d44bdc053c29b2b10f4720d4b940fc47252f 100644 --- a/src/main/java/net/minecraft/server/level/ThreadedLevelLightEngine.java diff --git a/patches/server/0864-Replace-player-chunk-loader-system.patch b/patches/server/0864-Replace-player-chunk-loader-system.patch index 9bf16bb72..4a26151c1 100644 --- a/patches/server/0864-Replace-player-chunk-loader-system.patch +++ b/patches/server/0864-Replace-player-chunk-loader-system.patch @@ -1632,7 +1632,7 @@ index b2efa5f24d20cb16218a0e7522866ee2faaef244..e6c6432f35add7f4c27375e4420179a8 double d2 = d0 * d0; boolean flag = d1 <= d2 && this.entity.broadcastToPlayer(player); diff --git a/src/main/java/net/minecraft/server/level/DistanceManager.java b/src/main/java/net/minecraft/server/level/DistanceManager.java -index 005d75c93387a8c34a9ff7413ba09cb1ae788a74..efb6b5cda6ef4015e283902e237a05af6f56cbc6 100644 +index b22c771ca35466574d5a73f2da3fc8762cb29487..3542b8b347b9a142c53f300251a05a11e421c36f 100644 --- a/src/main/java/net/minecraft/server/level/DistanceManager.java +++ b/src/main/java/net/minecraft/server/level/DistanceManager.java @@ -50,8 +50,8 @@ public abstract class DistanceManager { @@ -1784,8 +1784,8 @@ index 005d75c93387a8c34a9ff7413ba09cb1ae788a74..efb6b5cda6ef4015e283902e237a05af + // Paper - replace player chunk loader public void removeTicketsOnClosing() { - ImmutableSet> immutableset = ImmutableSet.of(TicketType.UNKNOWN, TicketType.POST_TELEPORT, TicketType.LIGHT); -@@ -559,12 +558,12 @@ public abstract class DistanceManager { + ImmutableSet> immutableset = ImmutableSet.of(TicketType.UNKNOWN, TicketType.POST_TELEPORT, TicketType.LIGHT, TicketType.FUTURE_AWAIT, TicketType.ASYNC_LOAD, TicketType.REQUIRED_LOAD, TicketType.CHUNK_RELIGHT, ca.spottedleaf.starlight.common.light.StarLightInterface.CHUNK_WORK_TICKET); // Paper - add additional tickets to preserve +@@ -559,12 +558,13 @@ public abstract class DistanceManager { if (!immutableset.contains(ticket.getType())) { iterator.remove(); flag = true; @@ -1796,11 +1796,12 @@ index 005d75c93387a8c34a9ff7413ba09cb1ae788a74..efb6b5cda6ef4015e283902e237a05af if (flag) { - this.ticketTracker.update(entry.getLongKey(), DistanceManager.getTicketLevelAt((SortedArraySet) entry.getValue()), false); ++ this.updateTicketLevel(entry.getLongKey(), getTicketLevelAt(entry.getValue())); // Paper - replace ticket level propagator + // this.ticketTracker.update(entry.getLongKey(), DistanceManager.getTicketLevelAt((SortedArraySet) entry.getValue()), false); // Paper - no longer used } if (((SortedArraySet) entry.getValue()).isEmpty()) { -@@ -598,6 +597,7 @@ public abstract class DistanceManager { +@@ -598,6 +598,7 @@ public abstract class DistanceManager { } // CraftBukkit end @@ -1808,7 +1809,7 @@ index 005d75c93387a8c34a9ff7413ba09cb1ae788a74..efb6b5cda6ef4015e283902e237a05af private class ChunkTicketTracker extends ChunkTracker { public ChunkTicketTracker() { -@@ -816,4 +816,5 @@ public abstract class DistanceManager { +@@ -816,4 +817,5 @@ public abstract class DistanceManager { return distance <= this.viewDistance - 2; } } diff --git a/patches/server/0866-Replace-ticket-level-propagator.patch b/patches/server/0866-Replace-ticket-level-propagator.patch index 8eedad187..03d6ba0cb 100644 --- a/patches/server/0866-Replace-ticket-level-propagator.patch +++ b/patches/server/0866-Replace-ticket-level-propagator.patch @@ -15,7 +15,7 @@ will be more effective, since more time will be allocated to actually processing chunk tasks vs the ticket level updates. diff --git a/src/main/java/net/minecraft/server/level/DistanceManager.java b/src/main/java/net/minecraft/server/level/DistanceManager.java -index d428da9060693db4e60d456b370d7b4db7bc6792..67dcbf2b8c8c5a700d34027379abe641ad0a6b23 100644 +index 3542b8b347b9a142c53f300251a05a11e421c36f..2c5cf08e16669d5be8ba7d6e3f9282c74f9ea295 100644 --- a/src/main/java/net/minecraft/server/level/DistanceManager.java +++ b/src/main/java/net/minecraft/server/level/DistanceManager.java @@ -38,6 +38,7 @@ import net.minecraft.world.level.chunk.ChunkStatus; @@ -238,7 +238,7 @@ index d428da9060693db4e60d456b370d7b4db7bc6792..67dcbf2b8c8c5a700d34027379abe641 } // Paper end return removed; // CraftBukkit -@@ -586,7 +660,7 @@ public abstract class DistanceManager { +@@ -587,7 +661,7 @@ public abstract class DistanceManager { SortedArraySet> tickets = entry.getValue(); if (tickets.remove(target)) { // copied from removeTicket