From 9da9b3a9d011ab9b6e91bb63c8138d20e6bfde26 Mon Sep 17 00:00:00 2001 From: Aikar Date: Fri, 18 Mar 2016 13:40:46 -0400 Subject: [PATCH] reduce sleep rate if file io thread sleep is enabled so we will still give it time to sleep to avoid the issue, but reduce the known negative effects of that sleeping. --- .../Chunk-save-queue-improvements.patch | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Spigot-Server-Patches/Chunk-save-queue-improvements.patch b/Spigot-Server-Patches/Chunk-save-queue-improvements.patch index 5897bf95cd..d2ae6dfca6 100644 --- a/Spigot-Server-Patches/Chunk-save-queue-improvements.patch +++ b/Spigot-Server-Patches/Chunk-save-queue-improvements.patch @@ -16,9 +16,14 @@ This has multiple impacts: 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. +To optimize this, we change the entire unload queue to be a proper queue. This improves the behavior of popping +the first queued chunk off, instead of abusing iterators like Mojang was doing. -Additionally, optimize the ChunkRegionLoader queue to reduce lock contention (issue with 1.9) +This also improves reliability of chunk saving, as the previous hack job had a race condition that could +fail to save some chunks. + +Then finally, Sleeping will by default be removed, but due to known issues with 1.9, a config option was added. +But if sleeps are to remain enabled, we at least lower the sleep interval so it doesn't have as much negative impact. diff --git a/src/main/java/com/destroystokyo/paper/PaperConfig.java b/src/main/java/com/destroystokyo/paper/PaperConfig.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 @@ -155,7 +160,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper start - Add toggle + if (com.destroystokyo.paper.PaperConfig.enableFileIOThreadSleep) { + try { -+ Thread.sleep(this.e ? 0L : 10L); ++ Thread.sleep(this.e ? 0L : 2L); + } catch (InterruptedException interruptedexception) { + interruptedexception.printStackTrace(); + }