PaperMC/CraftBukkit-Patches/0147-Optimize-Chunk-Saving-Memory-Allocation-and-Compress.patch
2016-03-01 08:33:06 +11:00

31 lines
No EOL
1.6 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
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 BufferedOutputStream(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) {
--