diff --git a/CraftBukkit-Patches/0158-Optimize-Chunk-Saving-Memory-Allocation-and-Compress.patch b/CraftBukkit-Patches/0158-Optimize-Chunk-Saving-Memory-Allocation-and-Compress.patch new file mode 100644 index 000000000..827a4b950 --- /dev/null +++ b/CraftBukkit-Patches/0158-Optimize-Chunk-Saving-Memory-Allocation-and-Compress.patch @@ -0,0 +1,31 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Aikar +Date: Sat, 29 Aug 2015 13:59:25 -0400 +Subject: [PATCH] Optimize Chunk Saving Memory Allocation and Compression + +Minecraft ineffeciently uses OutputStreams by calling .write(int) on the stream. +For Chunks, this is a DeflaterOutputStream, which allocates a single byte EVERY write. + +This is causing the server to allocate tons of new byte[1] objects. +Additionally, this is very ineffecient for the Deflate process. + +By Buffering Writes the same way it already is Buffering Reads, we will +write to the stream much more effeciently. + +diff --git a/src/main/java/net/minecraft/server/RegionFile.java b/src/main/java/net/minecraft/server/RegionFile.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/server/RegionFile.java ++++ b/src/main/java/net/minecraft/server/RegionFile.java +@@ -0,0 +0,0 @@ public class RegionFile { + } + } + +- public DataOutputStream b(int i, int j) { +- return this.d(i, j) ? null : new DataOutputStream(new DeflaterOutputStream(new RegionFile.ChunkBuffer(i, j))); ++ public DataOutputStream b(int i, int j) { // PAIL: getChunkOutputStream ++ // PAIL: isInvalidRegion ++ return this.d(i, j) ? null : new DataOutputStream(new java.io.BufferedOutputStream(new DeflaterOutputStream(new RegionFile.ChunkBuffer(i, j)))); // Spigot - use a BufferedOutputStream to greatly improve file write performance + } + + protected synchronized void a(int i, int j, byte[] abyte, int k) { +-- \ No newline at end of file diff --git a/CraftBukkit-Patches/0159-More-effecient-RegionFile-zero-ing.patch b/CraftBukkit-Patches/0159-More-effecient-RegionFile-zero-ing.patch new file mode 100644 index 000000000..a64e98802 --- /dev/null +++ b/CraftBukkit-Patches/0159-More-effecient-RegionFile-zero-ing.patch @@ -0,0 +1,39 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Aikar +Date: Sat, 29 Aug 2015 17:48:20 -0400 +Subject: [PATCH] More effecient RegionFile zero'ing + +Speeds up new Chunk Generation by using 2 4k block writes vs 2048 4 byte writes +more effecient than going in and out of native calls repeatedly. + +diff --git a/src/main/java/net/minecraft/server/RegionFile.java b/src/main/java/net/minecraft/server/RegionFile.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/server/RegionFile.java ++++ b/src/main/java/net/minecraft/server/RegionFile.java +@@ -0,0 +0,0 @@ import java.util.zip.InflaterInputStream; + + public class RegionFile { + +- private static final byte[] a = new byte[4096]; ++ private static final byte[] a = new byte[4096]; // Spigot - note: if this ever changes to not be 4096 bytes, update constructor! // PAIL: empty 4k block + private final File b; + private RandomAccessFile c; + private final int[] d = new int[1024]; +@@ -0,0 +0,0 @@ public class RegionFile { + int i; + + if (this.c.length() < 4096L) { +- for (i = 0; i < 1024; ++i) { +- this.c.writeInt(0); +- } +- +- for (i = 0; i < 1024; ++i) { +- this.c.writeInt(0); +- } ++ // Spigot - more effecient chunk zero'ing ++ this.c.write(RegionFile.a); // Spigot ++ this.c.write(RegionFile.a); // Spigot + + this.g += 8192; + } +-- \ No newline at end of file