From 768b46ed638a64e9700195179acd172030b43d47 Mon Sep 17 00:00:00 2001 From: Spottedleaf Date: Sat, 22 Jun 2019 13:17:40 -0700 Subject: [PATCH] Optimize protochunk saving (#2218) Use a chunk status cache to check if we could potentially overwrite a levelchunk. The check could be entirely elided at the risk of overwriting chunk data, however most protochunks should have their corresponding regionfile loaded with their chunk status. --- ...Status-cache-when-saving-protochunks.patch | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 Spigot-Server-Patches/0407-Use-ChunkStatus-cache-when-saving-protochunks.patch diff --git a/Spigot-Server-Patches/0407-Use-ChunkStatus-cache-when-saving-protochunks.patch b/Spigot-Server-Patches/0407-Use-ChunkStatus-cache-when-saving-protochunks.patch new file mode 100644 index 0000000000..61b07a0f75 --- /dev/null +++ b/Spigot-Server-Patches/0407-Use-ChunkStatus-cache-when-saving-protochunks.patch @@ -0,0 +1,28 @@ +From 567cbbf93b099dd1731db47de6ccafdfe60bf142 Mon Sep 17 00:00:00 2001 +From: Spottedleaf +Date: Sat, 22 Jun 2019 04:20:47 -0700 +Subject: [PATCH] Use ChunkStatus cache when saving protochunks + +The cache should contain the chunk status when saving. If not it +will load it. + +diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java +index e89738a08d..89649e73e5 100644 +--- a/src/main/java/net/minecraft/server/PlayerChunkMap.java ++++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java +@@ -720,8 +720,10 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { + NBTTagCompound nbttagcompound; + + if (chunkstatus.getType() != ChunkStatus.Type.LEVELCHUNK) { +- nbttagcompound = this.readChunkData(chunkcoordintpair); +- if (nbttagcompound != null && ChunkRegionLoader.a(nbttagcompound) == ChunkStatus.Type.LEVELCHUNK) { ++ // Paper start - Optimize save by using status cache ++ ChunkStatus statusOnDisk = this.getRegionFile(ichunkaccess.getPos(), false).getStatus(ichunkaccess.getPos().x, ichunkaccess.getPos().z, this); ++ if (statusOnDisk != null && statusOnDisk.getType() == ChunkStatus.Type.LEVELCHUNK) { ++ // Paper end + return false; + } + +-- +2.21.0 +