mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-28 07:20:24 +01:00
48 lines
3.1 KiB
Diff
48 lines
3.1 KiB
Diff
|
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
|
||
|
index 175bf535066afc42de8a3f0d11c46af66f3e3e52..3b6f35b695117bd2b0c71b994efc55fa1084eddc 100644
|
||
|
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||
|
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||
|
@@ -119,7 +119,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||
|
private final PlayerMap playerMap;
|
||
|
public final Int2ObjectMap<ChunkMap.TrackedEntity> entityMap;
|
||
|
private final Long2ByteMap chunkTypeCache;
|
||
|
- private final Queue<Runnable> unloadQueue;
|
||
|
+ private final Queue<Runnable> unloadQueue; private final Queue<Runnable> getUnloadQueueTasks() { return this.unloadQueue; } // Paper - OBFHELPER
|
||
|
private int viewDistance;
|
||
|
|
||
|
// CraftBukkit start - recursion-safe executor for Chunk loadCallback() and unloadCallback()
|
||
|
@@ -177,7 +177,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 = definedstructuremanager;
|
||
|
this.storageFolder = convertable_conversionsession.getDimensionPath(worldserver.dimension());
|
||
|
this.level = worldserver;
|
||
|
@@ -435,7 +435,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() * UNLOAD_QUEUE_RESIZE_FACTOR);
|
||
|
+ int targetSize = Math.min(this.toDrop.size() - 100, (int) (this.toDrop.size() * UNLOAD_QUEUE_RESIZE_FACTOR)); // Paper - Make more aggressive
|
||
|
// Spigot end
|
||
|
while (longiterator.hasNext()) { // Spigot
|
||
|
long j = longiterator.nextLong();
|
||
|
@@ -457,7 +457,8 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||
|
|
||
|
Runnable runnable;
|
||
|
|
||
|
- while ((shouldKeepTicking.getAsBoolean() || this.unloadQueue.size() > 2000) && (runnable = (Runnable) this.unloadQueue.poll()) != null) {
|
||
|
+ int queueTarget = Math.min(this.getUnloadQueueTasks().size() - 100, (int) (this.getUnloadQueueTasks().size() * UNLOAD_QUEUE_RESIZE_FACTOR)); // Paper - Target this queue as well
|
||
|
+ while ((shouldKeepTicking.getAsBoolean() || this.getUnloadQueueTasks().size() > queueTarget) && (runnable = (Runnable)this.getUnloadQueueTasks().poll()) != null) { // Paper - Target this queue as well
|
||
|
runnable.run();
|
||
|
}
|
||
|
|