Paper/CraftBukkit-Patches/0147-Optimize-Chunk-Saving-Memory-Allocation-and-Compress.patch

34 Zeilen
1.6 KiB
Diff

2016-03-01 01:23:45 +01:00
From 8d76759534a15987f4f6a35afe74c7f64f61437f 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
2016-02-29 22:33:06 +01:00
index b6f0c0b..1cd8be8 100644
--- a/src/main/java/net/minecraft/server/RegionFile.java
+++ b/src/main/java/net/minecraft/server/RegionFile.java
2016-02-29 22:33:06 +01:00
@@ -171,8 +171,9 @@ public class RegionFile {
}
}
- public DataOutputStream b(int i, int j) {
2016-02-29 22:33:06 +01:00
- 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) {
--
2016-02-29 22:33:06 +01:00
2.5.0