From d816beaced2136f3a899962d52da793545a5f58c Mon Sep 17 00:00:00 2001 From: Aikar Date: Sat, 9 May 2020 12:13:29 -0400 Subject: [PATCH] MC-183249: Don't generate Carving Masks BitSet unless needed This was using SIGNIFICANT amounts of memory allocating many long[]'s for BitSets for every ProtoChunk in the cache that had been unloaded and reloaded. This will result in a nice memory reduction. --- ...generate-Carving-Masks-BitSet-unless.patch | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 Spigot-Server-Patches/MC-183249-Don-t-generate-Carving-Masks-BitSet-unless.patch diff --git a/Spigot-Server-Patches/MC-183249-Don-t-generate-Carving-Masks-BitSet-unless.patch b/Spigot-Server-Patches/MC-183249-Don-t-generate-Carving-Masks-BitSet-unless.patch new file mode 100644 index 000000000..8b6545fd6 --- /dev/null +++ b/Spigot-Server-Patches/MC-183249-Don-t-generate-Carving-Masks-BitSet-unless.patch @@ -0,0 +1,43 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Aikar +Date: Sat, 9 May 2020 12:11:47 -0400 +Subject: [PATCH] MC-183249: Don't generate Carving Masks BitSet unless needed + +This was using SIGNIFICANT amounts of memory allocating many +long[]'s for BitSets for every ProtoChunk in the cache that had +been unloaded and reloaded. + +This will result in a nice memory reduction. + +diff --git a/src/main/java/net/minecraft/server/ChunkRegionLoader.java b/src/main/java/net/minecraft/server/ChunkRegionLoader.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/server/ChunkRegionLoader.java ++++ b/src/main/java/net/minecraft/server/ChunkRegionLoader.java +@@ -0,0 +0,0 @@ public class ChunkRegionLoader { + for (int l = 0; l < k; ++l) { + WorldGenStage.Features worldgenstage_features = aworldgenstage_features[l]; + +- nbttagcompound3.setByteArray(worldgenstage_features.toString(), ichunkaccess.a(worldgenstage_features).toByteArray()); ++ // Paper start - don't create carving mask bitsets if not even at that chunk status yet ++ BitSet mask = protochunk.getCarvingMaskIfSet(worldgenstage_features); ++ if (mask != null) { ++ nbttagcompound3.setByteArray(worldgenstage_features.toString(), mask.toByteArray()); ++ } ++ // Paper end + } + + nbttagcompound1.set("CarvingMasks", nbttagcompound3); +diff --git a/src/main/java/net/minecraft/server/ProtoChunk.java b/src/main/java/net/minecraft/server/ProtoChunk.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/server/ProtoChunk.java ++++ b/src/main/java/net/minecraft/server/ProtoChunk.java +@@ -0,0 +0,0 @@ public class ProtoChunk implements IChunkAccess { + private final ProtoChunkTickList q; + private final ProtoChunkTickList r; + private long s; +- private final Map t; ++ private final Map t;public BitSet getCarvingMaskIfSet(WorldGenStage.Features worldgenstage_features) { return this.t.get(worldgenstage_features); } // Paper ++ // Paper end + private volatile boolean u; + private final World world; // Paper - Anti-Xray - Add world +