From a63d6e9ea819bb12d6eb08ada773aa9fd3a903a8 Mon Sep 17 00:00:00 2001 From: Aikar Date: Mon, 19 Sep 2016 23:31:42 -0400 Subject: [PATCH] Incremental Auto Saving Process auto save every tick instead of once per auto tick interval, so that chunk saves will distribute over many ticks instead of all at once. --- .../0172-Incremental-Auto-Saving.patch | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 Spigot-Server-Patches/0172-Incremental-Auto-Saving.patch diff --git a/Spigot-Server-Patches/0172-Incremental-Auto-Saving.patch b/Spigot-Server-Patches/0172-Incremental-Auto-Saving.patch new file mode 100644 index 0000000000..fc12e37233 --- /dev/null +++ b/Spigot-Server-Patches/0172-Incremental-Auto-Saving.patch @@ -0,0 +1,62 @@ +From af0ca0d1f3a9bba5938e9880f823ad71953d8d71 Mon Sep 17 00:00:00 2001 +From: Aikar +Date: Mon, 19 Sep 2016 23:16:39 -0400 +Subject: [PATCH] Incremental Auto Saving + +Process auto save every tick instead of once per auto tick interval, so that chunk saves will distribute over many ticks instead of all at once. + +diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java +index 683a6dd..4a51eff 100644 +--- a/src/main/java/net/minecraft/server/Chunk.java ++++ b/src/main/java/net/minecraft/server/Chunk.java +@@ -960,7 +960,7 @@ public class Chunk { + if (this.t && this.world.getTime() != this.lastSaved || this.s) { + return true; + } +- } else if (this.t && this.world.getTime() >= this.lastSaved + MinecraftServer.getServer().autosavePeriod * 4) { // Spigot - Only save if we've passed 2 auto save intervals without modification ++ } else if (this.t && this.world.getTime() >= this.lastSaved + MinecraftServer.getServer().autosavePeriod) { // Spigot // Paper - Remove broken change + return true; + } + +diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java +index 1ba02f1..0410bf2 100644 +--- a/src/main/java/net/minecraft/server/ChunkProviderServer.java ++++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java +@@ -265,7 +265,7 @@ public class ChunkProviderServer implements IChunkProvider { + this.saveChunk(chunk); + chunk.f(false); + ++i; +- if (i == 24 && !flag && false) { // Spigot ++ if (i == 24 && !flag) { // Spigot - // Paper - Incremental Auto Save - cap to 24 per tick + return false; + } + } +diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java +index 8ca8fbf..897bb5f 100644 +--- a/src/main/java/net/minecraft/server/MinecraftServer.java ++++ b/src/main/java/net/minecraft/server/MinecraftServer.java +@@ -745,7 +745,7 @@ public abstract class MinecraftServer implements Runnable, ICommandListener, IAs + this.q.b().a(agameprofile); + } + +- if (autosavePeriod > 0 && this.ticks % autosavePeriod == 0) { // CraftBukkit ++ if (autosavePeriod > 0 /*&& this.ticks % autosavePeriod == 0*/) { // CraftBukkit // Paper - Incremental Auto Saving + MinecraftTimings.worldSaveTimer.startTiming(); // Spigot + this.methodProfiler.a("save"); + this.v.savePlayers(); +diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java +index 5ed6d3e..a47bfee 100644 +--- a/src/main/java/net/minecraft/server/WorldServer.java ++++ b/src/main/java/net/minecraft/server/WorldServer.java +@@ -1024,7 +1024,7 @@ public class WorldServer extends World implements IAsyncTaskHandler { + ChunkProviderServer chunkproviderserver = this.getChunkProviderServer(); + + if (chunkproviderserver.e()) { +- org.bukkit.Bukkit.getPluginManager().callEvent(new org.bukkit.event.world.WorldSaveEvent(getWorld())); // CraftBukkit ++ if (flag) org.bukkit.Bukkit.getPluginManager().callEvent(new org.bukkit.event.world.WorldSaveEvent(getWorld())); // CraftBukkit // Paper - Incremental Auto Saving - Only fire event on full save + if (iprogressupdate != null) { + iprogressupdate.a("Saving level"); + } +-- +2.9.3 +