Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-15 19:10:09 +01:00
c95273f973
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. Also a more effecient RegionFile zero'ing for new chunks to speed up new chunk generation.
34 Zeilen
1.5 KiB
Diff
34 Zeilen
1.5 KiB
Diff
From bec646b094570475d33dac9381e03b8ce6ba4286 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 3e31f4b..fe3fbb0 100644
|
|
--- a/src/main/java/net/minecraft/server/RegionFile.java
|
|
+++ b/src/main/java/net/minecraft/server/RegionFile.java
|
|
@@ -176,8 +176,9 @@ 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) {
|
|
--
|
|
1.9.1
|
|
|