From b12177fb04a02c084cf2bf761e29824749db1abb Mon Sep 17 00:00:00 2001 From: Aikar Date: Mon, 25 May 2020 13:09:56 -0400 Subject: [PATCH] One more to seal the deal to improve unloading inactive chunks While last was mostly there, still had some slight risk of unloading before it was fully finished. So just going to bump the delay to 3 minutes to be safe. Better than forever at least. Was really hoping we could unload them as soon as they were done to any memory prematurely promoting to old generation, but guess we can't. --- .../0532-Unload-leaked-Cached-Chunks.patch | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/Spigot-Server-Patches/0532-Unload-leaked-Cached-Chunks.patch b/Spigot-Server-Patches/0532-Unload-leaked-Cached-Chunks.patch index 0f4c508bd..fb0d8df26 100644 --- a/Spigot-Server-Patches/0532-Unload-leaked-Cached-Chunks.patch +++ b/Spigot-Server-Patches/0532-Unload-leaked-Cached-Chunks.patch @@ -18,7 +18,7 @@ We will now detect these chunks in that iteration, and automatically add it to the unload queue when the chunk is found without any tickets. diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java -index 54e89c9cc6c47ff2c4f4dd5d4c22a391f8a3d6e0..af4ffef0466966f0d333431e72163486dc3ba49d 100644 +index 54e89c9cc6c47ff2c4f4dd5d4c22a391f8a3d6e0..5254e436ce42dd2ab5e0aac5168a9f1f92c9da26 100644 --- a/src/main/java/net/minecraft/server/ChunkProviderServer.java +++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java @@ -898,6 +898,33 @@ public class ChunkProviderServer extends IChunkProvider { @@ -28,7 +28,7 @@ index 54e89c9cc6c47ff2c4f4dd5d4c22a391f8a3d6e0..af4ffef0466966f0d333431e72163486 + // Paper start - remove inaccessible chunks leaked + else if (playerchunk.getTicketLevel() == playerchunk.oldTicketLevel && + playerChunkMap.unloadQueue.size() < 100 && -+ (playerchunk.lastActivity == 0 || world.getTime() - playerchunk.lastActivity > 20*15) && ++ (playerchunk.lastActivity == 0 || world.getTime() - playerchunk.lastActivity > 20*180) && + PlayerChunk.getChunkState(playerchunk.getTicketLevel()) == PlayerChunk.State.INACCESSIBLE + ) { + ChunkStatus chunkHolderStatus = playerchunk.getChunkHolderStatus(); @@ -76,7 +76,7 @@ index b8fe42e8123e972b1ec97b048c35d90118076e66..ecac7b72759a3884020b9c19c58d3db3 boolean flag1 = this.ticketLevel <= PlayerChunkMap.GOLDEN_TICKET; // Paper - diff on change: (flag1 = new ticket level is in loadable range) PlayerChunk.State playerchunk_state = getChunkState(this.oldTicketLevel); diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java -index 2b09437642ec846d025b226692f2290f9bb5b556..f0bb519450d5ff2a5c8f7364fa8d8ecac03a6c59 100644 +index 2b09437642ec846d025b226692f2290f9bb5b556..b7d8a7487e303c2c44160ec1093987b3e0d175bc 100644 --- a/src/main/java/net/minecraft/server/PlayerChunkMap.java +++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java @@ -639,6 +639,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { @@ -87,7 +87,15 @@ index 2b09437642ec846d025b226692f2290f9bb5b556..f0bb519450d5ff2a5c8f7364fa8d8eca ChunkStatus chunkstatus = (ChunkStatus) intfunction.apply(j1); CompletableFuture> completablefuture = playerchunk.a(chunkstatus, this); -@@ -871,6 +872,8 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { +@@ -646,6 +647,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { + if (requestingNeighbor != null && requestingNeighbor != playerchunk && !completablefuture.isDone()) { + requestingNeighbor.onNeighborRequest(playerchunk, chunkstatus); + completablefuture.thenAccept(either -> { ++ playerchunk.lastActivity = world.getTime(); // Paper - chunk leak + requestingNeighbor.onNeighborDone(playerchunk, chunkstatus, either.left().orElse(null)); + }); + } +@@ -871,6 +873,8 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { while (longiterator.hasNext()) { // Spigot long j = longiterator.nextLong(); longiterator.remove(); // Spigot