testserver/patches/server/0133-Make-targetSize-more-a...

38 lines
2.2 KiB
Diff
Raw Normal View History

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Brokkonaut <hannos17@gmx.de>
Date: Tue, 7 Feb 2017 16:55:35 -0600
Subject: [PATCH] Make targetSize more aggressive in the chunk unload queue
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
2021-12-10 14:24:07 +00:00
index c72d19a903a5cbb48d38f493e00e8c54a8e23b9c..065ee0486ec275f9b61dc18afa86023183f0c73b 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
2021-11-30 07:32:30 +00:00
@@ -221,7 +221,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
this.playerMap = new PlayerMap();
this.entityMap = new Int2ObjectOpenHashMap();
this.chunkTypeCache = new Long2ByteOpenHashMap();
- this.unloadQueue = Queues.newConcurrentLinkedQueue();
+ this.unloadQueue = new com.destroystokyo.paper.utils.CachedSizeConcurrentLinkedQueue<>(); // Paper - need constant-time size()
this.structureManager = structureManager;
2021-11-30 07:32:30 +00:00
Path path = session.getDimensionPath(world.dimension());
2021-07-07 06:52:40 +00:00
2021-12-10 14:24:07 +00:00
@@ -529,7 +529,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
// Spigot start
org.spigotmc.SlackActivityAccountant activityAccountant = this.level.getServer().slackActivityAccountant;
activityAccountant.startActivity(0.5);
- int targetSize = (int) (this.toDrop.size() * ChunkMap.UNLOAD_QUEUE_RESIZE_FACTOR);
+ int targetSize = Math.min(this.toDrop.size() - 100, (int) (this.toDrop.size() * ChunkMap.UNLOAD_QUEUE_RESIZE_FACTOR)); // Paper - Make more aggressive
// Spigot end
while (longiterator.hasNext()) { // Spigot
long j = longiterator.nextLong();
2021-12-10 14:24:07 +00:00
@@ -549,7 +549,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
2021-11-30 07:32:30 +00:00
}
activityAccountant.endActivity(); // Spigot
2021-11-30 07:32:30 +00:00
- int k = Math.max(0, this.unloadQueue.size() - 2000);
+ int k = Math.max(0, Math.min(100, this.unloadQueue.size() - (int) (this.unloadQueue.size() * UNLOAD_QUEUE_RESIZE_FACTOR))); // Paper - Target this queue as well
2021-11-30 07:32:30 +00:00
Runnable runnable;