Implement performance improvements from the EMC-CraftBukkit fork
See the individual patch files for more details
This commit is contained in:
61
Spigot-Server-Patches/Improve-autosave-mechanism.patch
Normal file
61
Spigot-Server-Patches/Improve-autosave-mechanism.patch
Normal file
@@ -0,0 +1,61 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Sun, 19 Oct 2014 16:30:48 -0500
|
||||
Subject: [PATCH] Improve autosave mechanism
|
||||
|
||||
Only save modified chunks, or chunks with entities after 4 auto save passes
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/server/Chunk.java
|
||||
+++ b/src/main/java/net/minecraft/server/Chunk.java
|
||||
@@ -0,0 +0,0 @@ public class Chunk {
|
||||
if (this.o && this.world.getTime() != this.lastSaved || this.n) {
|
||||
return true;
|
||||
}
|
||||
- } else if (this.o && this.world.getTime() >= this.lastSaved + 600L) {
|
||||
+ } else if (this.o && this.world.getTime() >= this.lastSaved + MinecraftServer.getServer().autosavePeriod * 4) { // PaperSpigot - Only save if we've passed 2 auto save intervals without modification
|
||||
return true;
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
@@ -0,0 +0,0 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
|
||||
// Spigot Start
|
||||
// We replace this with saving each individual world as this.saveChunks(...) is broken,
|
||||
// and causes the main thread to sleep for random amounts of time depending on chunk activity
|
||||
+ // Also pass flag to only save modified chunks -- PaperSpigot
|
||||
server.playerCommandState = true;
|
||||
for (World world : worlds) {
|
||||
- world.getWorld().save();
|
||||
+ world.getWorld().save(true);
|
||||
}
|
||||
server.playerCommandState = false;
|
||||
// this.saveChunks(true);
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
@@ -0,0 +0,0 @@ public class CraftWorld implements World {
|
||||
}
|
||||
|
||||
public void save() {
|
||||
+ // PaperSpigot start - Improved autosave
|
||||
+ save(true);
|
||||
+ }
|
||||
+
|
||||
+ public void save(boolean forceSave) {
|
||||
+ // PaperSpigot end
|
||||
this.server.checkSaveState();
|
||||
try {
|
||||
boolean oldSave = world.savingDisabled;
|
||||
|
||||
world.savingDisabled = false;
|
||||
- world.save(true, null);
|
||||
+ world.save(forceSave, null); // PaperSpigot
|
||||
|
||||
world.savingDisabled = oldSave;
|
||||
} catch (ExceptionWorldConflict ex) {
|
||||
--
|
||||
Reference in New Issue
Block a user