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.
This commit is contained in:
Aikar 2016-09-19 23:31:42 -04:00
parent c55c93cb44
commit a63d6e9ea8

View file

@ -0,0 +1,62 @@
From af0ca0d1f3a9bba5938e9880f823ad71953d8d71 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
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