Archiviert
13
0

Chunk save queue improvements

Dieser Commit ist enthalten in:
Aikar 2016-03-04 20:14:27 -06:00 committet von Zach Brown
Ursprung 43091edd3a
Commit 417017308c
25 geänderte Dateien mit 198 neuen und 70 gelöschten Zeilen

Datei anzeigen

@ -1,41 +0,0 @@
From fb3e3db9d19ad2ba0f09063e00af66182e2b7134 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Wed, 2 Mar 2016 23:58:29 -0600
Subject: [PATCH] Don't sleep between chunk saves
For some unknown reason, Minecraft is sleeping 10ms between every single chunk being saved to disk.
Under high chunk load/unload activity (lots of movement / teleporting), this causes the chunk unload queue
to build up in size.
This has multiple impacts:
1) Performance of the unload queue itself - The save thread is pretty ineffecient for how it accesses it
By letting the queue get larger, checking and popping work off the queue can get less performant.
2) Performance of chunk loading - As with #1, chunk loads also have to check this queue when loading
chunk data so that it doesn't load stale data if new data is pending write to disk.
3) Memory Usage - The entire chunk has been serialized to NBT, and now sits in this queue. This leads to
elevated memory usage, and then the objects used in the serialization sit around longer than needed,
resulting in promotion to Old Generation instead of dying young.
If there is work to do, then the thread should be doing its work, and only sleep when it is done.
diff --git a/src/main/java/net/minecraft/server/FileIOThread.java b/src/main/java/net/minecraft/server/FileIOThread.java
index 198b00f..07072ba 100644
--- a/src/main/java/net/minecraft/server/FileIOThread.java
+++ b/src/main/java/net/minecraft/server/FileIOThread.java
@@ -39,11 +39,12 @@ public class FileIOThread implements Runnable {
++this.d;
}
+ /* // Paper start - don't sleep in between chunks so we unload faster.
try {
Thread.sleep(this.e ? 0L : 10L);
} catch (InterruptedException interruptedexception) {
interruptedexception.printStackTrace();
- }
+ } */ // Paper end
}
if (this.b.isEmpty()) {
--
2.7.2

Datei anzeigen

@ -1,4 +1,4 @@
From a45c3b27afcf811da685d0fc12d9f1f9fc337b1f Mon Sep 17 00:00:00 2001 From a7b8c6d02ae86f3bb6b1efae9c6527e21baf6921 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co> From: Aikar <aikar@aikar.co>
Date: Thu, 3 Mar 2016 00:07:23 -0600 Date: Thu, 3 Mar 2016 00:07:23 -0600
Subject: [PATCH] EAR: Fix bug with teleporting entities Subject: [PATCH] EAR: Fix bug with teleporting entities
@ -7,7 +7,7 @@ Subject: [PATCH] EAR: Fix bug with teleporting entities
https://hub.spigotmc.org/stash/projects/SPIGOT/repos/spigot/pull-requests/52/overview https://hub.spigotmc.org/stash/projects/SPIGOT/repos/spigot/pull-requests/52/overview
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
index b0834dc..7fa5440 100644 index 3af445b..429749a 100644
--- a/src/main/java/net/minecraft/server/Entity.java --- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java +++ b/src/main/java/net/minecraft/server/Entity.java
@@ -118,9 +118,17 @@ public abstract class Entity implements ICommandListener { @@ -118,9 +118,17 @@ public abstract class Entity implements ICommandListener {
@ -32,7 +32,7 @@ index b0834dc..7fa5440 100644
public boolean impulse; public boolean impulse;
public int portalCooldown; public int portalCooldown;
diff --git a/src/main/java/org/spigotmc/ActivationRange.java b/src/main/java/org/spigotmc/ActivationRange.java diff --git a/src/main/java/org/spigotmc/ActivationRange.java b/src/main/java/org/spigotmc/ActivationRange.java
index 97fbd95..df2fce7 100644 index 731efb8..75941ec 100644
--- a/src/main/java/org/spigotmc/ActivationRange.java --- a/src/main/java/org/spigotmc/ActivationRange.java
+++ b/src/main/java/org/spigotmc/ActivationRange.java +++ b/src/main/java/org/spigotmc/ActivationRange.java
@@ -224,7 +224,7 @@ public class ActivationRange @@ -224,7 +224,7 @@ public class ActivationRange

Datei anzeigen

@ -1,4 +1,4 @@
From 07d4710b337e7a009b56999284d222c70132389f Mon Sep 17 00:00:00 2001 From 631ba7666d943d5531c62edc2d50cffb9d2da96b Mon Sep 17 00:00:00 2001
From: Steve Anton <anxuiz.nx@gmail.com> From: Steve Anton <anxuiz.nx@gmail.com>
Date: Thu, 3 Mar 2016 00:09:38 -0600 Date: Thu, 3 Mar 2016 00:09:38 -0600
Subject: [PATCH] Add PlayerInitialSpawnEvent Subject: [PATCH] Add PlayerInitialSpawnEvent

Datei anzeigen

@ -1,4 +1,4 @@
From 28b2d3c901c653dc89f87fc1d1c70547a9ba3bd4 Mon Sep 17 00:00:00 2001 From 84a31df3c679fddff1bacbb673751e2516e2ad23 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co> From: Aikar <aikar@aikar.co>
Date: Thu, 3 Mar 2016 00:12:23 -0600 Date: Thu, 3 Mar 2016 00:12:23 -0600
Subject: [PATCH] Process Entity Chunk Registration on Teleport Subject: [PATCH] Process Entity Chunk Registration on Teleport

Datei anzeigen

@ -1,4 +1,4 @@
From e24dd23649a658b70444d9a084da60a508c86cf7 Mon Sep 17 00:00:00 2001 From c12406ab06ef6c05d00b19c2111ac95171712e1d Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co> From: Aikar <aikar@aikar.co>
Date: Thu, 3 Mar 2016 04:00:11 -0600 Date: Thu, 3 Mar 2016 04:00:11 -0600
Subject: [PATCH] Timings v2 Subject: [PATCH] Timings v2

Datei anzeigen

@ -1,4 +1,4 @@
From 85d076e03a5d9c6f725fed6d4e519d826bc953cd Mon Sep 17 00:00:00 2001 From 42fb1b90f32ba15b2bc613d2002b3213de084d83 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co> From: Aikar <aikar@aikar.co>
Date: Thu, 3 Mar 2016 01:13:45 -0600 Date: Thu, 3 Mar 2016 01:13:45 -0600
Subject: [PATCH] Disable chest cat detection Subject: [PATCH] Disable chest cat detection

Datei anzeigen

@ -1,4 +1,4 @@
From 116d2d92f3664866cc5828523fd616bff930fc2e Mon Sep 17 00:00:00 2001 From adf94fa7dc3aeb23f2088f168332acbbe9474ba5 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co> From: Aikar <aikar@aikar.co>
Date: Thu, 3 Mar 2016 01:17:12 -0600 Date: Thu, 3 Mar 2016 01:17:12 -0600
Subject: [PATCH] Ensure commands are not ran async Subject: [PATCH] Ensure commands are not ran async

Datei anzeigen

@ -1,4 +1,4 @@
From b2383cbb3d8efca11ce977cc2d13cb8826279af1 Mon Sep 17 00:00:00 2001 From 2ccb13cae084aa30611c5c7a0398e4144217e129 Mon Sep 17 00:00:00 2001
From: vemacs <d@nkmem.es> From: vemacs <d@nkmem.es>
Date: Thu, 3 Mar 2016 01:19:22 -0600 Date: Thu, 3 Mar 2016 01:19:22 -0600
Subject: [PATCH] All chunks are slime spawn chunks toggle Subject: [PATCH] All chunks are slime spawn chunks toggle

Datei anzeigen

@ -1,4 +1,4 @@
From 4832c2374cfe6206c3684452864bb671a88d613e Mon Sep 17 00:00:00 2001 From 734508339ddb667db95298af5ae378926b99e2bc Mon Sep 17 00:00:00 2001
From: DemonWav <demonwav@gmail.com> From: DemonWav <demonwav@gmail.com>
Date: Thu, 3 Mar 2016 01:44:39 -0600 Date: Thu, 3 Mar 2016 01:44:39 -0600
Subject: [PATCH] Add Location support to tab completers (vanilla feature Subject: [PATCH] Add Location support to tab completers (vanilla feature

Datei anzeigen

@ -1,4 +1,4 @@
From 1bed4e4301f897bbbfe538ff9fe93aa1d183c175 Mon Sep 17 00:00:00 2001 From f86324be40eceb5194c1f58fafd0219fb538c8da Mon Sep 17 00:00:00 2001
From: Nik Gil <nikmanG@users.noreply.github.com> From: Nik Gil <nikmanG@users.noreply.github.com>
Date: Thu, 3 Mar 2016 04:04:19 -0600 Date: Thu, 3 Mar 2016 04:04:19 -0600
Subject: [PATCH] Made EntityDismountEvent Cancellable Subject: [PATCH] Made EntityDismountEvent Cancellable

Datei anzeigen

@ -1,4 +1,4 @@
From 256441becb43b3929f3c9eb8c4f74853e3540465 Mon Sep 17 00:00:00 2001 From f0c6ad6334511ad4bc91aea310e08c72501d62aa Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co> From: Aikar <aikar@aikar.co>
Date: Thu, 3 Mar 2016 02:02:07 -0600 Date: Thu, 3 Mar 2016 02:02:07 -0600
Subject: [PATCH] Optimize Pathfinding Subject: [PATCH] Optimize Pathfinding

Datei anzeigen

@ -1,4 +1,4 @@
From cb40c347cc1e86c85969dcb35f78a8a2e2787e24 Mon Sep 17 00:00:00 2001 From 4f257ef83902bca1da8e046c6873c9cef158fdeb Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co> From: Aikar <aikar@aikar.co>
Date: Thu, 3 Mar 2016 02:07:55 -0600 Date: Thu, 3 Mar 2016 02:07:55 -0600
Subject: [PATCH] Optimize getBlockData Subject: [PATCH] Optimize getBlockData

Datei anzeigen

@ -1,4 +1,4 @@
From cbecbf14837ed3904880ad65134d0e0563f8e0c8 Mon Sep 17 00:00:00 2001 From 845496e20e174f87fba207a48fe7b4993ad59dac Mon Sep 17 00:00:00 2001
From: CullanP <cullanpage@gmail.com> From: CullanP <cullanpage@gmail.com>
Date: Thu, 3 Mar 2016 02:13:38 -0600 Date: Thu, 3 Mar 2016 02:13:38 -0600
Subject: [PATCH] Avoid hopper searches if there are no items Subject: [PATCH] Avoid hopper searches if there are no items

Datei anzeigen

@ -1,4 +1,4 @@
From 8bd701f289231b752207b68ef72b9b48d4bfb57f Mon Sep 17 00:00:00 2001 From 871ec0828e63e11f2b69dfba6a1fb30c0591f7e5 Mon Sep 17 00:00:00 2001
From: kashike <kashike@vq.lc> From: kashike <kashike@vq.lc>
Date: Thu, 3 Mar 2016 02:15:57 -0600 Date: Thu, 3 Mar 2016 02:15:57 -0600
Subject: [PATCH] Expose server CommandMap Subject: [PATCH] Expose server CommandMap

Datei anzeigen

@ -1,4 +1,4 @@
From 3551594da49109bd71a1b0905276ad2adf38f443 Mon Sep 17 00:00:00 2001 From 919e7babbeed909d2b51a4e1764f673cd1132070 Mon Sep 17 00:00:00 2001
From: kashike <kashike@vq.lc> From: kashike <kashike@vq.lc>
Date: Thu, 3 Mar 2016 02:18:39 -0600 Date: Thu, 3 Mar 2016 02:18:39 -0600
Subject: [PATCH] Be a bit more informative in maxHealth exception Subject: [PATCH] Be a bit more informative in maxHealth exception

Datei anzeigen

@ -1,4 +1,4 @@
From 32bd67a83257d049363c34c5ab7bbf3ce08937f8 Mon Sep 17 00:00:00 2001 From 164d4efd8bef430906450337ea83a07ed3de97f2 Mon Sep 17 00:00:00 2001
From: Zach Brown <zach.brown@destroystokyo.com> From: Zach Brown <zach.brown@destroystokyo.com>
Date: Thu, 3 Mar 2016 02:21:58 -0600 Date: Thu, 3 Mar 2016 02:21:58 -0600
Subject: [PATCH] Graduate bungeecord chat API from spigot subclasses Subject: [PATCH] Graduate bungeecord chat API from spigot subclasses
@ -32,7 +32,7 @@ index 76f50ae..cb9906a 100644
@Deprecated @Deprecated
public OfflinePlayer getOfflinePlayer(String name) { public OfflinePlayer getOfflinePlayer(String name) {
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index a2f2b8e..c37ad0e 100644 index 582ab4c..10bf160 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -156,6 +156,22 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @@ -156,6 +156,22 @@ public class CraftPlayer extends CraftHumanEntity implements Player {

Datei anzeigen

@ -1,11 +1,11 @@
From dcc0b3337d42767dacea1910dd3b872e27cd2199 Mon Sep 17 00:00:00 2001 From f8f6d2cf300230c54f07ed0ff7d90fe6f6a96f3d Mon Sep 17 00:00:00 2001
From: Techcable <Techcable@outlook.com> From: Techcable <Techcable@outlook.com>
Date: Thu, 3 Mar 2016 02:32:10 -0600 Date: Thu, 3 Mar 2016 02:32:10 -0600
Subject: [PATCH] Player Tab List and Title APIs Subject: [PATCH] Player Tab List and Title APIs
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index e139217..3d5bccd 100644 index 10bf160..d9fab10 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -1,5 +1,6 @@ @@ -1,5 +1,6 @@

Datei anzeigen

@ -1,4 +1,4 @@
From 29ce8dbfe8bfe2f0a8c99ad9613ea903615f36cf Mon Sep 17 00:00:00 2001 From 0ece26ab85eb8ce79e3b55e84087294022848cd3 Mon Sep 17 00:00:00 2001
From: Joseph Hirschfeld <joe@ibj.io> From: Joseph Hirschfeld <joe@ibj.io>
Date: Thu, 3 Mar 2016 02:33:53 -0600 Date: Thu, 3 Mar 2016 02:33:53 -0600
Subject: [PATCH] Ensure inv drag is in bounds Subject: [PATCH] Ensure inv drag is in bounds

Datei anzeigen

@ -1,4 +1,4 @@
From d9842022cfac2ac27871dc3b363954d3492528cc Mon Sep 17 00:00:00 2001 From b7b272567560e4947474b209356f87aa194beab8 Mon Sep 17 00:00:00 2001
From: Joseph Hirschfeld <joe@ibj.io> From: Joseph Hirschfeld <joe@ibj.io>
Date: Thu, 3 Mar 2016 02:39:54 -0600 Date: Thu, 3 Mar 2016 02:39:54 -0600
Subject: [PATCH] Change implementation of (tile)entity removal list Subject: [PATCH] Change implementation of (tile)entity removal list

Datei anzeigen

@ -1,4 +1,4 @@
From 3c621cdd6f9b2d60e89eaa913d9463294df3af1e Mon Sep 17 00:00:00 2001 From e723a6c4e1cff0a81d30ef7bb0b17ff361b86520 Mon Sep 17 00:00:00 2001
From: Joseph Hirschfeld <joe@ibj.io> From: Joseph Hirschfeld <joe@ibj.io>
Date: Thu, 3 Mar 2016 02:46:17 -0600 Date: Thu, 3 Mar 2016 02:46:17 -0600
Subject: [PATCH] Add configurable portal search radius Subject: [PATCH] Add configurable portal search radius
@ -45,7 +45,7 @@ index 7c8df40..22c94d1 100644
blockposition1 = blockposition2.down(); blockposition1 = blockposition2.down();
if (this.world.getType(blockposition2).getBlock() == Blocks.PORTAL) { if (this.world.getType(blockposition2).getBlock() == Blocks.PORTAL) {
diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
index 3567133..9da5719 100644 index 66b7e77..1ef9987 100644
--- a/src/main/java/net/minecraft/server/WorldServer.java --- a/src/main/java/net/minecraft/server/WorldServer.java
+++ b/src/main/java/net/minecraft/server/WorldServer.java +++ b/src/main/java/net/minecraft/server/WorldServer.java
@@ -60,7 +60,7 @@ public class WorldServer extends World implements IAsyncTaskHandler { @@ -60,7 +60,7 @@ public class WorldServer extends World implements IAsyncTaskHandler {

Datei anzeigen

@ -1,4 +1,4 @@
From bce742ca6f95614f70210094ec75efaa1b49d13c Mon Sep 17 00:00:00 2001 From 9847b8d2a13d30029cee4553416c745d6a8b237c Mon Sep 17 00:00:00 2001
From: Joseph Hirschfeld <joe@ibj.io> From: Joseph Hirschfeld <joe@ibj.io>
Date: Thu, 3 Mar 2016 02:48:12 -0600 Date: Thu, 3 Mar 2016 02:48:12 -0600
Subject: [PATCH] Add velocity warnings Subject: [PATCH] Add velocity warnings

Datei anzeigen

@ -1,4 +1,4 @@
From 9434875bc68169f237fd9e2088bf99b0e0c2650f Mon Sep 17 00:00:00 2001 From c38bb352f98246e32fc34760d79cadf64a5eab1a Mon Sep 17 00:00:00 2001
From: Sudzzy <originmc@outlook.com> From: Sudzzy <originmc@outlook.com>
Date: Thu, 3 Mar 2016 02:50:31 -0600 Date: Thu, 3 Mar 2016 02:50:31 -0600
Subject: [PATCH] Fix inter-world teleportation glitches Subject: [PATCH] Fix inter-world teleportation glitches
@ -25,7 +25,7 @@ index f42efe7..c5c49bf 100644
+ } + }
} }
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index 3d5bccd..79f5352 100644 index d9fab10..51c971f 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -553,7 +553,8 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @@ -553,7 +553,8 @@ public class CraftPlayer extends CraftHumanEntity implements Player {

Datei anzeigen

@ -1,4 +1,4 @@
From 7437a350b5016312d44dd9cb22a39994063342ab Mon Sep 17 00:00:00 2001 From 64d63acdd2ab0ce767bffc9c1e7f683d21932ce0 Mon Sep 17 00:00:00 2001
From: Joseph Hirschfeld <joe@ibj.io> From: Joseph Hirschfeld <joe@ibj.io>
Date: Thu, 3 Mar 2016 03:15:41 -0600 Date: Thu, 3 Mar 2016 03:15:41 -0600
Subject: [PATCH] Add exception reporting event Subject: [PATCH] Add exception reporting event

Datei anzeigen

@ -1,4 +1,4 @@
From 1d5a9281412eb02af76aaa116280e5e02c987d6d Mon Sep 17 00:00:00 2001 From f0f541994c80d95ab31cb898ddb4debbae47b003 Mon Sep 17 00:00:00 2001
From: Zach Brown <zach.brown@destroystokyo.com> From: Zach Brown <zach.brown@destroystokyo.com>
Date: Thu, 3 Mar 2016 04:45:26 -0600 Date: Thu, 3 Mar 2016 04:45:26 -0600
Subject: [PATCH] Temp patch to nuke BeaconEffectEvent until we get some sleep Subject: [PATCH] Temp patch to nuke BeaconEffectEvent until we get some sleep

Datei anzeigen

@ -0,0 +1,169 @@
From 15f73df80f65604080b217caa144ce218bffc96f Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Fri, 4 Mar 2016 18:18:37 -0600
Subject: [PATCH] Chunk save queue improvements
For some unknown reason, Minecraft is sleeping 10ms between every single chunk being saved to disk.
Under high chunk load/unload activity (lots of movement / teleporting), this causes the chunk unload queue
to build up in size.
This has multiple impacts:
1) Performance of the unload queue itself - The save thread is pretty ineffecient for how it accesses it
By letting the queue get larger, checking and popping work off the queue can get less performant.
2) Performance of chunk loading - As with #1, chunk loads also have to check this queue when loading
chunk data so that it doesn't load stale data if new data is pending write to disk.
3) Memory Usage - The entire chunk has been serialized to NBT, and now sits in this queue. This leads to
elevated memory usage, and then the objects used in the serialization sit around longer than needed,
resulting in promotion to Old Generation instead of dying young.
If there is work to do, then the thread should be doing its work, and only sleep when it is done.
Additionally, optimize the ChunkRegionLoader queue to reduce lock contention (issue with 1.9)
diff --git a/src/main/java/com/destroystokyo/paper/PaperConfig.java b/src/main/java/com/destroystokyo/paper/PaperConfig.java
index 62f4631..ed49d83 100644
--- a/src/main/java/com/destroystokyo/paper/PaperConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java
@@ -164,4 +164,10 @@ public class PaperConfig {
}
return time;
}
+
+ public static boolean enableFileIOThreadSleep;
+ private static void enableFileIOThreadSleep() {
+ enableFileIOThreadSleep = getBoolean("settings.sleep-between-chunk-saves", false);
+ if (enableFileIOThreadSleep) Bukkit.getLogger().info("Enabled sleeping between chunk saves, beware of memory issues");
+ }
}
diff --git a/src/main/java/net/minecraft/server/ChunkRegionLoader.java b/src/main/java/net/minecraft/server/ChunkRegionLoader.java
index 5bd6ce0..336e780 100644
--- a/src/main/java/net/minecraft/server/ChunkRegionLoader.java
+++ b/src/main/java/net/minecraft/server/ChunkRegionLoader.java
@@ -11,14 +11,17 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentLinkedQueue; // Paper
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver {
+ private ConcurrentLinkedQueue<QueuedChunk> queue = new ConcurrentLinkedQueue<QueuedChunk>(); // Paper - Chunk queue improvements
+ private final Object lock = new Object(); // Paper - Chunk queue improvements
private static final Logger a = LogManager.getLogger();
private Map<ChunkCoordIntPair, NBTTagCompound> b = new ConcurrentHashMap();
- private Set<ChunkCoordIntPair> c = Collections.newSetFromMap(new ConcurrentHashMap());
+ //private Set<ChunkCoordIntPair> c = Collections.newSetFromMap(new ConcurrentHashMap()); // Paper - Chunk queue improvements
private final File d;
private final DataConverterManager e;
private boolean f = false;
@@ -32,11 +35,11 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver {
public boolean chunkExists(World world, int i, int j) {
ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(i, j);
- if (this.c.contains(chunkcoordintpair)) {
+ //if (this.c.contains(chunkcoordintpair)) { // Paper - Chunk queue improvements
if (this.b.containsKey(chunkcoordintpair)) {
return true;
}
- }
+ //} // Paper - Chunk queue improvements
// Paper start - Don't create region files when checking that they exist
final RegionFile region = RegionFileCache.a(this.d, i, j, false);
@@ -139,28 +142,32 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver {
}
protected void a(ChunkCoordIntPair chunkcoordintpair, NBTTagCompound nbttagcompound) {
- if (!this.c.contains(chunkcoordintpair)) {
+ synchronized (lock) { // Paper - Chunk queue improvements
this.b.put(chunkcoordintpair, nbttagcompound);
}
+ queue.add(new QueuedChunk(chunkcoordintpair, nbttagcompound)); // Paper - Chunk queue improvements
FileIOThread.a().a(this);
}
public boolean c() {
- if (this.b.isEmpty()) {
+ // Paper start - Chunk queue improvements
+ QueuedChunk chunk = queue.poll();
+ if (chunk == null) {
+ // Paper - end
if (this.f) {
ChunkRegionLoader.a.info("ThreadedAnvilChunkStorage ({}): All chunks are saved", new Object[] { this.d.getName()});
}
return false;
} else {
- ChunkCoordIntPair chunkcoordintpair = (ChunkCoordIntPair) this.b.keySet().iterator().next();
+ ChunkCoordIntPair chunkcoordintpair = chunk.coords; // Paper - Chunk queue improvements
boolean flag;
try {
- this.c.add(chunkcoordintpair);
- NBTTagCompound nbttagcompound = (NBTTagCompound) this.b.remove(chunkcoordintpair);
+ //this.c.add(chunkcoordintpair);
+ NBTTagCompound nbttagcompound = chunk.compound; // Paper - Chunk queue improvements
if (nbttagcompound != null) {
try {
@@ -169,10 +176,11 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver {
ChunkRegionLoader.a.error("Failed to save chunk", exception);
}
}
+ synchronized (lock) { if (this.b.get(chunkcoordintpair) == nbttagcompound) { this.b.remove(chunkcoordintpair); } }// Paper - This will not equal if a newer version is still pending
flag = true;
} finally {
- this.c.remove(chunkcoordintpair);
+ //this.c.remove(chunkcoordintpair); // Paper
}
return flag;
@@ -503,4 +511,16 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver {
return entity;
}
}
+
+ // Paper start - Chunk queue improvements
+ private static class QueuedChunk {
+ public ChunkCoordIntPair coords;
+ public NBTTagCompound compound;
+
+ public QueuedChunk(ChunkCoordIntPair coords, NBTTagCompound compound) {
+ this.coords = coords;
+ this.compound = compound;
+ }
+ }
+ // Paper end
}
diff --git a/src/main/java/net/minecraft/server/FileIOThread.java b/src/main/java/net/minecraft/server/FileIOThread.java
index 198b00f..d997dd4 100644
--- a/src/main/java/net/minecraft/server/FileIOThread.java
+++ b/src/main/java/net/minecraft/server/FileIOThread.java
@@ -39,11 +39,15 @@ public class FileIOThread implements Runnable {
++this.d;
}
- try {
- Thread.sleep(this.e ? 0L : 10L);
- } catch (InterruptedException interruptedexception) {
- interruptedexception.printStackTrace();
+ // Paper start - Add toggle
+ if (com.destroystokyo.paper.PaperConfig.enableFileIOThreadSleep) {
+ try {
+ Thread.sleep(this.e ? 0L : 10L);
+ } catch (InterruptedException interruptedexception) {
+ interruptedexception.printStackTrace();
+ }
}
+ // Paper end
}
if (this.b.isEmpty()) {
--
2.7.2