mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-26 17:17:13 +01:00
33 lines
1.6 KiB
Diff
33 lines
1.6 KiB
Diff
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
|
|
index b6f0c0b..1cd8be8 100644
|
|
--- a/src/main/java/net/minecraft/server/RegionFile.java
|
|
+++ b/src/main/java/net/minecraft/server/RegionFile.java
|
|
@@ -171,8 +171,9 @@ 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) {
|
|
--
|
|
2.5.0
|
|
|