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.
This commit is contained in:
Aikar 2020-05-25 13:09:56 -04:00
parent 78ee3b4e88
commit b12177fb04
No known key found for this signature in database
GPG Key ID: 401ADFC9891FAAFE
1 changed files with 12 additions and 4 deletions

View File

@ -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. 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 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 --- a/src/main/java/net/minecraft/server/ChunkProviderServer.java
+++ b/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 { @@ -898,6 +898,33 @@ public class ChunkProviderServer extends IChunkProvider {
@ -28,7 +28,7 @@ index 54e89c9cc6c47ff2c4f4dd5d4c22a391f8a3d6e0..af4ffef0466966f0d333431e72163486
+ // Paper start - remove inaccessible chunks leaked + // Paper start - remove inaccessible chunks leaked
+ else if (playerchunk.getTicketLevel() == playerchunk.oldTicketLevel && + else if (playerchunk.getTicketLevel() == playerchunk.oldTicketLevel &&
+ playerChunkMap.unloadQueue.size() < 100 && + 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 + PlayerChunk.getChunkState(playerchunk.getTicketLevel()) == PlayerChunk.State.INACCESSIBLE
+ ) { + ) {
+ ChunkStatus chunkHolderStatus = playerchunk.getChunkHolderStatus(); + 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) 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); 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 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 --- a/src/main/java/net/minecraft/server/PlayerChunkMap.java
+++ b/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 { @@ -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); ChunkStatus chunkstatus = (ChunkStatus) intfunction.apply(j1);
CompletableFuture<Either<IChunkAccess, PlayerChunk.Failure>> completablefuture = playerchunk.a(chunkstatus, this); CompletableFuture<Either<IChunkAccess, PlayerChunk.Failure>> 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 while (longiterator.hasNext()) { // Spigot
long j = longiterator.nextLong(); long j = longiterator.nextLong();
longiterator.remove(); // Spigot longiterator.remove(); // Spigot