From 66dd61702a91ff051b257a3e4de54ac27cd6f434 Mon Sep 17 00:00:00 2001 From: Aikar Date: Sun, 4 Mar 2018 20:20:27 -0500 Subject: [PATCH] Add max-player-auto-save-per-tick setting to spread out saves more This will force the saves to spread over multiple ticks even when many players auto save interval is aligned, avoiding spikes on large servers. Closes #1021 --- ...guration-option-to-prevent-player-names-fro.patch | 4 ++-- .../Add-option-to-remove-invalid-statistics.patch | 6 +++--- ...cifying-a-custom-authentication-servers-dow.patch | 2 +- Spigot-Server-Patches/Auto-Save-Improvements.patch | 12 ++++++++++-- .../Enforce-Sync-Player-Saves.patch | 4 ++-- ...ly-handle-async-calls-to-restart-the-server.patch | 2 +- 6 files changed, 19 insertions(+), 11 deletions(-) diff --git a/Spigot-Server-Patches/Add-configuration-option-to-prevent-player-names-fro.patch b/Spigot-Server-Patches/Add-configuration-option-to-prevent-player-names-fro.patch index a074fc82c8..9d2e9061ac 100644 --- a/Spigot-Server-Patches/Add-configuration-option-to-prevent-player-names-fro.patch +++ b/Spigot-Server-Patches/Add-configuration-option-to-prevent-player-names-fro.patch @@ -6,7 +6,7 @@ Subject: [PATCH] Add configuration option to prevent player names from being diff --git a/src/main/java/com/destroystokyo/paper/PaperConfig.java b/src/main/java/com/destroystokyo/paper/PaperConfig.java -index 28917f63d..f4b237034 100644 +index ea6fcb39f..dbafef023 100644 --- a/src/main/java/com/destroystokyo/paper/PaperConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java @@ -0,0 +0,0 @@ public class PaperConfig { @@ -20,7 +20,7 @@ index 28917f63d..f4b237034 100644 + } } diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index 701c90679..50341ae6e 100644 +index 41357cb0e..27c6caddc 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -0,0 +0,0 @@ public final class CraftServer implements Server { diff --git a/Spigot-Server-Patches/Add-option-to-remove-invalid-statistics.patch b/Spigot-Server-Patches/Add-option-to-remove-invalid-statistics.patch index 5f8a928a44..78c63cc3d0 100644 --- a/Spigot-Server-Patches/Add-option-to-remove-invalid-statistics.patch +++ b/Spigot-Server-Patches/Add-option-to-remove-invalid-statistics.patch @@ -5,12 +5,12 @@ Subject: [PATCH] Add option to remove invalid statistics diff --git a/src/main/java/com/destroystokyo/paper/PaperConfig.java b/src/main/java/com/destroystokyo/paper/PaperConfig.java -index da0984a35..28917f63d 100644 +index 459c86bce..ea6fcb39f 100644 --- a/src/main/java/com/destroystokyo/paper/PaperConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java @@ -0,0 +0,0 @@ public class PaperConfig { - private static void playerAutoSaveRate() { - playerAutoSaveRate = getInt("settings.player-auto-save-rate", -1); + maxPlayerAutoSavePerTick = (playerAutoSaveRate == -1 || playerAutoSaveRate > 100) ? 10 : 20; + } } + + public static boolean removeInvalidStatistics = false; diff --git a/Spigot-Server-Patches/Allow-specifying-a-custom-authentication-servers-dow.patch b/Spigot-Server-Patches/Allow-specifying-a-custom-authentication-servers-dow.patch index 904d295039..c18af0d441 100644 --- a/Spigot-Server-Patches/Allow-specifying-a-custom-authentication-servers-dow.patch +++ b/Spigot-Server-Patches/Allow-specifying-a-custom-authentication-servers-dow.patch @@ -6,7 +6,7 @@ Subject: [PATCH] Allow specifying a custom "authentication servers down" kick diff --git a/src/main/java/com/destroystokyo/paper/PaperConfig.java b/src/main/java/com/destroystokyo/paper/PaperConfig.java -index f4b237034..f5cb9799b 100644 +index dbafef023..ec89ecfca 100644 --- a/src/main/java/com/destroystokyo/paper/PaperConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java @@ -0,0 +0,0 @@ diff --git a/Spigot-Server-Patches/Auto-Save-Improvements.patch b/Spigot-Server-Patches/Auto-Save-Improvements.patch index 7fd22d18c9..af6db350dd 100644 --- a/Spigot-Server-Patches/Auto-Save-Improvements.patch +++ b/Spigot-Server-Patches/Auto-Save-Improvements.patch @@ -12,7 +12,7 @@ Re-introduce a cap per tick for auto save (Spigot disabled the vanilla cap) and Adds incremental player auto saving too diff --git a/src/main/java/com/destroystokyo/paper/PaperConfig.java b/src/main/java/com/destroystokyo/paper/PaperConfig.java -index 621c585e7..da0984a35 100644 +index 621c585e7..459c86bce 100644 --- a/src/main/java/com/destroystokyo/paper/PaperConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java @@ -0,0 +0,0 @@ public class PaperConfig { @@ -21,8 +21,14 @@ index 621c585e7..da0984a35 100644 } + + public static int playerAutoSaveRate = -1; ++ public static int maxPlayerAutoSavePerTick = 10; + private static void playerAutoSaveRate() { + playerAutoSaveRate = getInt("settings.player-auto-save-rate", -1); ++ maxPlayerAutoSavePerTick = getInt("settings.max-player-auto-save-per-tick", -1); ++ if (maxPlayerAutoSavePerTick == -1) { // -1 Automatic / "Recommended" ++ // 10 should be safe for everyone unless your mass spamming player auto save ++ maxPlayerAutoSavePerTick = (playerAutoSaveRate == -1 || playerAutoSaveRate > 100) ? 10 : 20; ++ } + } } diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java @@ -155,7 +161,7 @@ index ab7933079..5c09c6ff7 100644 this.methodProfiler.a("tallying"); // Spigot start diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java -index ed5852ef4..0e82c16b7 100644 +index ed5852ef4..efea22c92 100644 --- a/src/main/java/net/minecraft/server/PlayerList.java +++ b/src/main/java/net/minecraft/server/PlayerList.java @@ -0,0 +0,0 @@ public abstract class PlayerList { @@ -178,11 +184,13 @@ index ed5852ef4..0e82c16b7 100644 + public void savePlayers(Integer interval) { + long now = MinecraftServer.currentTick; MinecraftTimings.savePlayers.startTiming(); // Paper ++ int numSaved = 0; // Paper for (int i = 0; i < this.players.size(); ++i) { - this.savePlayerFile((EntityPlayer) this.players.get(i)); + EntityPlayer entityplayer = this.players.get(i); + if (interval == null || now - entityplayer.lastSave >= interval) { + this.savePlayerFile(entityplayer); ++ if (interval != null && ++numSaved <= com.destroystokyo.paper.PaperConfig.maxPlayerAutoSavePerTick) { break; } // Paper + } } MinecraftTimings.savePlayers.stopTiming(); // Paper diff --git a/Spigot-Server-Patches/Enforce-Sync-Player-Saves.patch b/Spigot-Server-Patches/Enforce-Sync-Player-Saves.patch index 5f18eeed0c..d68517ecda 100644 --- a/Spigot-Server-Patches/Enforce-Sync-Player-Saves.patch +++ b/Spigot-Server-Patches/Enforce-Sync-Player-Saves.patch @@ -7,7 +7,7 @@ Saving players async is extremely dangerous. This will force it to main the same way we handle async chunk loads. diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java -index 0e82c16b7..4080ed26c 100644 +index efea22c92..91136a8d8 100644 --- a/src/main/java/net/minecraft/server/PlayerList.java +++ b/src/main/java/net/minecraft/server/PlayerList.java @@ -0,0 +0,0 @@ public abstract class PlayerList { @@ -17,7 +17,7 @@ index 0e82c16b7..4080ed26c 100644 + MCUtil.ensureMain("Save Players", () -> { // Paper - ensure main long now = MinecraftServer.currentTick; MinecraftTimings.savePlayers.startTiming(); // Paper - for (int i = 0; i < this.players.size(); ++i) { + int numSaved = 0; // Paper @@ -0,0 +0,0 @@ public abstract class PlayerList { } } diff --git a/Spigot-Server-Patches/Properly-handle-async-calls-to-restart-the-server.patch b/Spigot-Server-Patches/Properly-handle-async-calls-to-restart-the-server.patch index 94c496854f..6bb86cd58d 100644 --- a/Spigot-Server-Patches/Properly-handle-async-calls-to-restart-the-server.patch +++ b/Spigot-Server-Patches/Properly-handle-async-calls-to-restart-the-server.patch @@ -78,7 +78,7 @@ index 13c6b5ccd..908a5d273 100644 return this.serverThread; } diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java -index 4080ed26c..ff01bbff5 100644 +index 91136a8d8..cc6a209ea 100644 --- a/src/main/java/net/minecraft/server/PlayerList.java +++ b/src/main/java/net/minecraft/server/PlayerList.java @@ -0,0 +0,0 @@ public abstract class PlayerList {