testserver/Spigot-Server-Patches/0054-Don-t-sleep-between-ch...

42 lines
1.9 KiB
Diff

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