diff options
author | Jason Penilla <[email protected]> | 2021-12-27 03:53:25 -0800 |
---|---|---|
committer | Jason Penilla <[email protected]> | 2021-12-27 03:53:25 -0800 |
commit | 692283dbe2d37d81903bca61a99ab0904be8d5fe (patch) | |
tree | 1bab88575e74dba4080bcb84afb131a8e7dd7d5c | |
parent | e9947f8145ea1fa87d995fbf7df4868a556e78db (diff) | |
download | Paper-692283dbe2d37d81903bca61a99ab0904be8d5fe.tar.gz Paper-692283dbe2d37d81903bca61a99ab0904be8d5fe.zip |
Remove making unused copy of visible chunks in ChunkMap#processUnloads
8 files changed, 41 insertions, 44 deletions
diff --git a/patches/server/0458-incremental-chunk-and-player-saving.patch b/patches/server/0458-incremental-chunk-and-player-saving.patch index f5e658a985..def62a5b6d 100644 --- a/patches/server/0458-incremental-chunk-and-player-saving.patch +++ b/patches/server/0458-incremental-chunk-and-player-saving.patch @@ -165,7 +165,7 @@ index 626bcbc6dd013260c3f8b38a1d14e7ba35dc1e01..9e96b0465717bfa761289c255fd8d2f1 for (int i = 0; i < this.futures.length(); ++i) { CompletableFuture<Either<ChunkAccess, ChunkHolder.ChunkLoadingFailure>> completablefuture = (CompletableFuture) this.futures.get(i); diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java -index 847c4705f88b999976c9a99519939eb2e71e7f1d..1ff5ca11e3550dc730dd9d44acd666119f42898f 100644 +index 847c4705f88b999976c9a99519939eb2e71e7f1d..42814c37f558b3fc0e59ba80c2ddaba3e6596d57 100644 --- a/src/main/java/net/minecraft/server/level/ChunkMap.java +++ b/src/main/java/net/minecraft/server/level/ChunkMap.java @@ -101,6 +101,7 @@ import net.minecraft.world.level.levelgen.structure.templatesystem.StructureMana @@ -241,16 +241,22 @@ index 847c4705f88b999976c9a99519939eb2e71e7f1d..1ff5ca11e3550dc730dd9d44acd66611 protected void saveAllChunks(boolean flush) { if (flush) { List<ChunkHolder> list = (List) this.visibleChunkMap.values().stream().filter(ChunkHolder::wasAccessibleSinceLastSave).peek(ChunkHolder::refreshAccessibility).collect(Collectors.toList()); -@@ -734,7 +793,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider - int l = 0; - ObjectIterator objectiterator = this.visibleChunkMap.values().iterator(); +@@ -732,13 +791,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider + } + int l = 0; +- ObjectIterator objectiterator = this.visibleChunkMap.values().iterator(); +- - while (l < 20 && shouldKeepTicking.getAsBoolean() && objectiterator.hasNext()) { -+ while (false && l < 20 && shouldKeepTicking.getAsBoolean() && objectiterator.hasNext()) { // Paper - incremental chunk and player saving - if (this.saveChunkIfNeeded((ChunkHolder) objectiterator.next())) { - ++l; - } -@@ -776,6 +835,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +- if (this.saveChunkIfNeeded((ChunkHolder) objectiterator.next())) { +- ++l; +- } +- } ++ // Paper - incremental chunk and player saving + + } + +@@ -776,6 +829,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider this.level.unload(chunk); } @@ -258,7 +264,7 @@ index 847c4705f88b999976c9a99519939eb2e71e7f1d..1ff5ca11e3550dc730dd9d44acd66611 this.lightEngine.updateChunkStatus(ichunkaccess.getPos()); this.lightEngine.tryScheduleUpdate(); -@@ -1173,6 +1233,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1173,6 +1227,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider asyncSaveData, chunk); chunk.setUnsaved(false); @@ -266,7 +272,7 @@ index 847c4705f88b999976c9a99519939eb2e71e7f1d..1ff5ca11e3550dc730dd9d44acd66611 } // Paper end -@@ -1182,6 +1243,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1182,6 +1237,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider if (!chunk.isUnsaved()) { return false; } else { diff --git a/patches/server/0472-Implement-Chunk-Priority-Urgency-System-for-Chunks.patch b/patches/server/0472-Implement-Chunk-Priority-Urgency-System-for-Chunks.patch index ed0e3e94c7..a710839c7e 100644 --- a/patches/server/0472-Implement-Chunk-Priority-Urgency-System-for-Chunks.patch +++ b/patches/server/0472-Implement-Chunk-Priority-Urgency-System-for-Chunks.patch @@ -360,7 +360,7 @@ index 9e96b0465717bfa761289c255fd8d2f1df1be3d8..87271552aa85626f22f7f8569c8fb48f return this.isEntityTickingReady; } diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java -index 1ff5ca11e3550dc730dd9d44acd666119f42898f..0b8b813d329aa1de912057ddeb52c0442f262f13 100644 +index 42814c37f558b3fc0e59ba80c2ddaba3e6596d57..d9f1456f5f217655396c4095e1595f55024efa76 100644 --- a/src/main/java/net/minecraft/server/level/ChunkMap.java +++ b/src/main/java/net/minecraft/server/level/ChunkMap.java @@ -128,6 +128,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -448,7 +448,7 @@ index 1ff5ca11e3550dc730dd9d44acd666119f42898f..0b8b813d329aa1de912057ddeb52c044 list1.add(playerchunk); list.add(completablefuture); -@@ -875,11 +925,19 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -869,11 +919,19 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider if (requiredStatus == ChunkStatus.EMPTY) { return this.scheduleChunkLoad(chunkcoordintpair); } else { @@ -469,7 +469,7 @@ index 1ff5ca11e3550dc730dd9d44acd666119f42898f..0b8b813d329aa1de912057ddeb52c044 if (optional.isPresent() && ((ChunkAccess) optional.get()).getStatus().isOrAfter(requiredStatus)) { CompletableFuture<Either<ChunkAccess, ChunkHolder.ChunkLoadingFailure>> completablefuture = requiredStatus.load(this.level, this.structureManager, this.lightEngine, (ichunkaccess) -> { -@@ -891,6 +949,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -885,6 +943,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider } else { return this.scheduleChunkGeneration(holder, requiredStatus); } @@ -477,7 +477,7 @@ index 1ff5ca11e3550dc730dd9d44acd666119f42898f..0b8b813d329aa1de912057ddeb52c044 } } -@@ -947,14 +1006,24 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -941,14 +1000,24 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider }; CompletableFuture<CompoundTag> chunkSaveFuture = this.level.asyncChunkTaskManager.getChunkSaveFuture(pos.x, pos.z); @@ -507,7 +507,7 @@ index 1ff5ca11e3550dc730dd9d44acd666119f42898f..0b8b813d329aa1de912057ddeb52c044 return ret; // Paper end } -@@ -1006,7 +1075,10 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1000,7 +1069,10 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider this.releaseLightTicket(chunkcoordintpair); return CompletableFuture.completedFuture(Either.right(playerchunk_failure)); }); @@ -519,7 +519,7 @@ index 1ff5ca11e3550dc730dd9d44acd666119f42898f..0b8b813d329aa1de912057ddeb52c044 } protected void releaseLightTicket(ChunkPos pos) { -@@ -1090,7 +1162,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1084,7 +1156,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider long i = chunkHolder.getPos().toLong(); Objects.requireNonNull(chunkHolder); diff --git a/patches/server/0492-Improve-Chunk-Status-Transition-Speed.patch b/patches/server/0492-Improve-Chunk-Status-Transition-Speed.patch index e3f37a7db6..b3b6dae006 100644 --- a/patches/server/0492-Improve-Chunk-Status-Transition-Speed.patch +++ b/patches/server/0492-Improve-Chunk-Status-Transition-Speed.patch @@ -54,7 +54,7 @@ index 87271552aa85626f22f7f8569c8fb48fe4b30bf3..80aae4303e011dad13ce818136f0383e public ChunkHolder(ChunkPos pos, int level, LevelHeightAccessor world, LevelLightEngine lightingProvider, ChunkHolder.LevelChangeListener levelUpdateListener, ChunkHolder.PlayerProvider playersWatchingChunkProvider) { this.futures = new AtomicReferenceArray(ChunkHolder.CHUNK_STATUSES.size()); diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java -index 0b8b813d329aa1de912057ddeb52c0442f262f13..a97bf06a0e8ba1cd612f7e8be2585bfdfbdfa969 100644 +index d9f1456f5f217655396c4095e1595f55024efa76..71cfc51223e12cdd1030f0e5bb2263d594fa4c3c 100644 --- a/src/main/java/net/minecraft/server/level/ChunkMap.java +++ b/src/main/java/net/minecraft/server/level/ChunkMap.java @@ -636,7 +636,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -66,7 +66,7 @@ index 0b8b813d329aa1de912057ddeb52c0442f262f13..a97bf06a0e8ba1cd612f7e8be2585bfd } @Nullable -@@ -1046,6 +1046,12 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1040,6 +1040,12 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider return "chunkGenerate " + requiredStatus.getName(); }); Executor executor = (runnable) -> { diff --git a/patches/server/0739-Fix-chunks-refusing-to-unload-at-low-TPS.patch b/patches/server/0739-Fix-chunks-refusing-to-unload-at-low-TPS.patch index b0b95db3bf..54cb6296c5 100644 --- a/patches/server/0739-Fix-chunks-refusing-to-unload-at-low-TPS.patch +++ b/patches/server/0739-Fix-chunks-refusing-to-unload-at-low-TPS.patch @@ -10,10 +10,10 @@ chunk future to complete. We can simply schedule to the immediate executor to get this effect, rather than the main mailbox. diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java -index 2af478902b528f335797c691730afb2657d4e6c4..71ca2c2edc6a89e9365b4686c233f60cea12a472 100644 +index 76f40342098c1cc1ffb855ef41349953f8b94d0f..0090ef1df54c5b438bc4b23d2ed8978575e48dae 100644 --- a/src/main/java/net/minecraft/server/level/ChunkMap.java +++ b/src/main/java/net/minecraft/server/level/ChunkMap.java -@@ -1259,9 +1259,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1253,9 +1253,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider return chunk; }); diff --git a/patches/server/0740-Do-not-allow-ticket-level-changes-while-unloading-pl.patch b/patches/server/0740-Do-not-allow-ticket-level-changes-while-unloading-pl.patch index af693f3838..2083e35d2c 100644 --- a/patches/server/0740-Do-not-allow-ticket-level-changes-while-unloading-pl.patch +++ b/patches/server/0740-Do-not-allow-ticket-level-changes-while-unloading-pl.patch @@ -8,7 +8,7 @@ Sync loading the chunk at this stage would cause it to load older data, as well as screwing our region state. diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java -index 71ca2c2edc6a89e9365b4686c233f60cea12a472..09bb6e14864af68e9833e171a33aa981f51c8569 100644 +index 0090ef1df54c5b438bc4b23d2ed8978575e48dae..e0b445c13bae4205bb33b082dfb0b6b6a4351e6d 100644 --- a/src/main/java/net/minecraft/server/level/ChunkMap.java +++ b/src/main/java/net/minecraft/server/level/ChunkMap.java @@ -296,6 +296,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -27,7 +27,7 @@ index 71ca2c2edc6a89e9365b4686c233f60cea12a472..09bb6e14864af68e9833e171a33aa981 if (k > ChunkMap.MAX_CHUNK_DISTANCE && level > ChunkMap.MAX_CHUNK_DISTANCE) { return holder; } else { -@@ -870,6 +872,12 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -864,6 +866,12 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider if (completablefuture1 != completablefuture) { this.scheduleUnload(pos, holder); } else { @@ -40,7 +40,7 @@ index 71ca2c2edc6a89e9365b4686c233f60cea12a472..09bb6e14864af68e9833e171a33aa981 // Paper start boolean removed; if ((removed = this.pendingUnloads.remove(pos, holder)) && ichunkaccess != null) { -@@ -906,6 +914,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -900,6 +908,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider this.regionManagers.get(index).removeChunk(holder.pos.x, holder.pos.z); } } // Paper end diff --git a/patches/server/0753-Do-not-copy-visible-chunks.patch b/patches/server/0753-Do-not-copy-visible-chunks.patch index d17bb54692..a45225000c 100644 --- a/patches/server/0753-Do-not-copy-visible-chunks.patch +++ b/patches/server/0753-Do-not-copy-visible-chunks.patch @@ -35,7 +35,7 @@ index b3516862d796c2d9fcc1c67a6073445403d73088..b61abf227a04b4565c2525e5f469db30 List<ChunkHolder> allChunks = new ArrayList<>(visibleChunks.values()); List<ServerPlayer> players = world.players; diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java -index 09bb6e14864af68e9833e171a33aa981f51c8569..53399b80e60872224ba6b77f41626b2beef236d2 100644 +index e0b445c13bae4205bb33b082dfb0b6b6a4351e6d..9c729af97a7658778bd96c121823bc9023f35c12 100644 --- a/src/main/java/net/minecraft/server/level/ChunkMap.java +++ b/src/main/java/net/minecraft/server/level/ChunkMap.java @@ -120,9 +120,11 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -117,16 +117,7 @@ index 09bb6e14864af68e9833e171a33aa981f51c8569..53399b80e60872224ba6b77f41626b2b if (playerchunk != null) { this.pendingUnloads.put(j, playerchunk); -@@ -854,7 +861,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider - } - - int l = 0; -- ObjectIterator objectiterator = this.visibleChunkMap.values().iterator(); -+ Iterator objectiterator = this.updatingChunks.getVisibleValuesCopy().iterator(); // Paper - - while (false && l < 20 && shouldKeepTicking.getAsBoolean() && objectiterator.hasNext()) { // Paper - incremental chunk and player saving - if (this.saveChunkIfNeeded((ChunkHolder) objectiterator.next())) { -@@ -933,7 +940,12 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -927,7 +934,12 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider if (!this.modified) { return false; } else { @@ -140,7 +131,7 @@ index 09bb6e14864af68e9833e171a33aa981f51c8569..53399b80e60872224ba6b77f41626b2b this.modified = false; return true; } -@@ -1411,7 +1423,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1405,7 +1417,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider this.viewDistance = j; this.distanceManager.updatePlayerTickets(this.viewDistance + 1); @@ -149,7 +140,7 @@ index 09bb6e14864af68e9833e171a33aa981f51c8569..53399b80e60872224ba6b77f41626b2b while (objectiterator.hasNext()) { ChunkHolder playerchunk = (ChunkHolder) objectiterator.next(); -@@ -1454,7 +1466,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1448,7 +1460,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider } public int size() { @@ -158,7 +149,7 @@ index 09bb6e14864af68e9833e171a33aa981f51c8569..53399b80e60872224ba6b77f41626b2b } public DistanceManager getDistanceManager() { -@@ -1462,13 +1474,13 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1456,13 +1468,13 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider } protected Iterable<ChunkHolder> getChunks() { diff --git a/patches/server/0770-Oprimise-map-impl-for-tracked-players.patch b/patches/server/0770-Oprimise-map-impl-for-tracked-players.patch index 977c8a0a81..c5baf6fa12 100644 --- a/patches/server/0770-Oprimise-map-impl-for-tracked-players.patch +++ b/patches/server/0770-Oprimise-map-impl-for-tracked-players.patch @@ -7,7 +7,7 @@ Reference2BooleanOpenHashMap is going to have better lookups than HashMap. diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java -index 53399b80e60872224ba6b77f41626b2beef236d2..087eec200cec325edb11f7fbae1a81a216b019d6 100644 +index 9c729af97a7658778bd96c121823bc9023f35c12..ad0997ec4e36937e937195d95df701b1954ef885 100644 --- a/src/main/java/net/minecraft/server/level/ChunkMap.java +++ b/src/main/java/net/minecraft/server/level/ChunkMap.java @@ -108,6 +108,7 @@ import org.apache.logging.log4j.LogManager; @@ -18,7 +18,7 @@ index 53399b80e60872224ba6b77f41626b2beef236d2..087eec200cec325edb11f7fbae1a81a2 public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider { -@@ -2101,7 +2102,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -2095,7 +2096,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider final Entity entity; private final int range; SectionPos lastSectionPos; diff --git a/patches/server/0823-Actually-unload-POI-data.patch b/patches/server/0823-Actually-unload-POI-data.patch index c03e727b8f..e3a703270e 100644 --- a/patches/server/0823-Actually-unload-POI-data.patch +++ b/patches/server/0823-Actually-unload-POI-data.patch @@ -10,7 +10,7 @@ This patch also prevents the saving/unloading of POI data when world saving is disabled. diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java -index 0c046cd0fab44aecd41ef5c1477b13ea9606aee4..0e474819c506e6d5e1731d49610c7cf472aa49c4 100644 +index 3be958576599995e083d4bea85e89099911795a6..cd85d1d97b8fbc8979100f2097e77070a840f3b1 100644 --- a/src/main/java/net/minecraft/server/level/ChunkMap.java +++ b/src/main/java/net/minecraft/server/level/ChunkMap.java @@ -792,6 +792,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -30,7 +30,7 @@ index 0c046cd0fab44aecd41ef5c1477b13ea9606aee4..0e474819c506e6d5e1731d49610c7cf4 private void processUnloads(BooleanSupplier shouldKeepTicking) { LongIterator longiterator = this.toDrop.iterator(); -@@ -1006,6 +1007,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1000,6 +1001,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider this.regionManagers.get(index).removeChunk(holder.pos.x, holder.pos.z); } // Paper end @@ -38,7 +38,7 @@ index 0c046cd0fab44aecd41ef5c1477b13ea9606aee4..0e474819c506e6d5e1731d49610c7cf4 if (ichunkaccess instanceof LevelChunk) { ((LevelChunk) ichunkaccess).setLoaded(false); } -@@ -1034,6 +1036,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1028,6 +1030,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider for (int index = 0, len = this.regionManagers.size(); index < len; ++index) { this.regionManagers.get(index).removeChunk(holder.pos.x, holder.pos.z); } @@ -46,7 +46,7 @@ index 0c046cd0fab44aecd41ef5c1477b13ea9606aee4..0e474819c506e6d5e1731d49610c7cf4 } // Paper end } finally { this.unloadingPlayerChunk = unloadingBefore; } // Paper - do not allow ticket level changes while unloading chunks -@@ -1110,6 +1113,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1104,6 +1107,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider } this.poiManager.loadInData(pos, chunkHolder.poiData); chunkHolder.tasks.forEach(Runnable::run); |