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
This commit is contained in:
Aikar 2018-03-04 20:20:27 -05:00
parent 1e870d319b
commit 709d95ae00
No known key found for this signature in database
GPG key ID: 401ADFC9891FAAFE
6 changed files with 39 additions and 31 deletions

View file

@ -1,4 +1,4 @@
From 17ca76593dd05a5c7ce88279f57a00b498bac4db Mon Sep 17 00:00:00 2001
From 7c51a79d0c5b06020ba93772ff3f3c558e7133b9 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Mon, 19 Sep 2016 23:16:39 -0400
Subject: [PATCH] Auto Save Improvements
@ -12,17 +12,23 @@ 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
@@ -251,4 +251,9 @@ public class PaperConfig {
@@ -251,4 +251,15 @@ public class PaperConfig {
flyingKickPlayerMessage = getString("messages.kick.flying-player", flyingKickPlayerMessage);
flyingKickVehicleMessage = getString("messages.kick.flying-vehicle", flyingKickVehicleMessage);
}
+
+ 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
@@ -343,6 +343,7 @@ public abstract class PlayerList {
@ -166,7 +172,7 @@ index ed5852ef4..0e82c16b7 100644
this.playerFileData.save(entityplayer);
ServerStatisticManager serverstatisticmanager = (ServerStatisticManager) entityplayer.getStatisticManager(); // CraftBukkit
@@ -1242,13 +1243,23 @@ public abstract class PlayerList {
@@ -1242,13 +1243,25 @@ 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
@ -215,5 +223,5 @@ index f2ddc22dd..8493dccee 100644
timings.worldSaveChunks.startTiming(); // Paper
chunkproviderserver.a(flag);
--
2.16.1
2.16.2

View file

@ -1,16 +1,16 @@
From 9645473bc0f79de0b3d578f53afb4c1bc42a8094 Mon Sep 17 00:00:00 2001
From eb0e0d138fb18e6ecb794916ee2a251cd0a63fb9 Mon Sep 17 00:00:00 2001
From: Zach Brown <zach.brown@destroystokyo.com>
Date: Tue, 20 Dec 2016 23:09:21 -0600
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
@@ -256,4 +256,13 @@ public class PaperConfig {
private static void playerAutoSaveRate() {
playerAutoSaveRate = getInt("settings.player-auto-save-rate", -1);
@@ -262,4 +262,13 @@ public class PaperConfig {
maxPlayerAutoSavePerTick = (playerAutoSaveRate == -1 || playerAutoSaveRate > 100) ? 10 : 20;
}
}
+
+ public static boolean removeInvalidStatistics = false;
@ -53,5 +53,5 @@ index 14af226f3..e3d2c0ff7 100644
}
}
--
2.16.1
2.16.2

View file

@ -1,4 +1,4 @@
From 343eb898d9c46caa258cda53eaf90c5c17495256 Mon Sep 17 00:00:00 2001
From 174bd0c894d7197b386a677450d20b15d1b7d0e5 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Sat, 7 Jan 2017 15:41:58 -0500
Subject: [PATCH] Enforce Sync Player Saves
@ -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
@@ -1249,6 +1249,7 @@ public abstract class PlayerList {
@ -17,8 +17,8 @@ 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) {
@@ -1258,6 +1259,7 @@ public abstract class PlayerList {
int numSaved = 0; // Paper
@@ -1260,6 +1261,7 @@ public abstract class PlayerList {
}
}
MinecraftTimings.savePlayers.stopTiming(); // Paper
@ -27,5 +27,5 @@ index 0e82c16b7..4080ed26c 100644
// Paper end
--
2.16.1
2.16.2

View file

@ -1,4 +1,4 @@
From ff7f3e57d17fc5b364048efaa4541921c101d43c Mon Sep 17 00:00:00 2001
From cad241a6391082af16b0a6472617360477d07168 Mon Sep 17 00:00:00 2001
From: Zach Brown <zach.brown@destroystokyo.com>
Date: Fri, 12 May 2017 23:34:11 -0500
Subject: [PATCH] Properly handle async calls to restart the server
@ -78,10 +78,10 @@ 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
@@ -1373,10 +1373,15 @@ public abstract class PlayerList {
@@ -1375,10 +1375,15 @@ public abstract class PlayerList {
entityplayer.playerInteractManager.b(world.getWorldData().getGameType());
}
@ -98,7 +98,7 @@ index 4080ed26c..ff01bbff5 100644
}
// CraftBukkit end
// Paper start - Remove collideRule team if it exists
@@ -1387,6 +1392,7 @@ public abstract class PlayerList {
@@ -1389,6 +1394,7 @@ public abstract class PlayerList {
}
// Paper end
}
@ -306,5 +306,5 @@ index 947c43a5d..f15fd9f37 100644
}
}
--
2.16.1
2.16.2

View file

@ -1,4 +1,4 @@
From a5c6c730527c0d813e4f3095153a41b1f114e4ef Mon Sep 17 00:00:00 2001
From 92072faa8f876e43559b99eb36df6767dae5369e Mon Sep 17 00:00:00 2001
From: kashike <kashike@vq.lc>
Date: Fri, 9 Jun 2017 07:24:34 -0700
Subject: [PATCH] Add configuration option to prevent player names from being
@ -6,10 +6,10 @@ 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
@@ -265,4 +265,9 @@ public class PaperConfig {
@@ -271,4 +271,9 @@ public class PaperConfig {
}
removeInvalidStatistics = getBoolean("settings.remove-invalid-statistics", false);
}
@ -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
@@ -1908,5 +1908,10 @@ public final class CraftServer implements Server {
@ -35,5 +35,5 @@ index 701c90679..50341ae6e 100644
// Paper end
}
--
2.16.1
2.16.2

View file

@ -1,4 +1,4 @@
From bbb692b7756b3d884e75521c79edcda46e5ae5cc Mon Sep 17 00:00:00 2001
From e0ee9656360c7d8bd856a2eb60321b04d83241e7 Mon Sep 17 00:00:00 2001
From: kashike <kashike@vq.lc>
Date: Thu, 17 Aug 2017 16:08:20 -0700
Subject: [PATCH] Allow specifying a custom "authentication servers down" kick
@ -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
@@ -1,5 +1,6 @@
@ -16,7 +16,7 @@ index f4b237034..f5cb9799b 100644
import com.google.common.base.Throwables;
import java.io.File;
@@ -270,4 +271,9 @@ public class PaperConfig {
@@ -276,4 +277,9 @@ public class PaperConfig {
private static void suggestPlayersWhenNull() {
suggestPlayersWhenNullTabCompletions = getBoolean("settings.suggest-player-names-when-null-tab-completions", suggestPlayersWhenNullTabCompletions);
}
@ -42,5 +42,5 @@ index c5434e6ba..75df92836 100644
LoginListener.c.error("Couldn\'t verify username because servers are unavailable");
}
--
2.16.1
2.16.2