diff --git a/gradle.properties b/gradle.properties index 475ca26..040a5f1 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,7 +1,7 @@ group = space.bxteam.divinemc version = 1.20.6-R0.1-SNAPSHOT -purpurRef = be47af0884f583ac90968d4f1e90275cc383bd9d +purpurRef = da953af857486ad7888802152901c407cf53a95e org.gradle.caching = true org.gradle.parallel = true diff --git a/patches/server/0041-C2ME-reduce_allocs.patch b/patches/server/0041-C2ME-reduce_allocs.patch new file mode 100644 index 0000000..e756c1b --- /dev/null +++ b/patches/server/0041-C2ME-reduce_allocs.patch @@ -0,0 +1,45 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com> +Date: Mon, 13 May 2024 17:40:02 +0300 +Subject: [PATCH] C2ME: reduce_allocs + + +diff --git a/src/main/java/net/minecraft/world/level/levelgen/feature/OreFeature.java b/src/main/java/net/minecraft/world/level/levelgen/feature/OreFeature.java +index 506b2afd099c9b7e9ac3f6f2fcea8e523fae396b..2394f6f2c031b25a6cbeb79918a04b5710548d98 100644 +--- a/src/main/java/net/minecraft/world/level/levelgen/feature/OreFeature.java ++++ b/src/main/java/net/minecraft/world/level/levelgen/feature/OreFeature.java +@@ -69,7 +69,7 @@ public class OreFeature extends Feature { + int verticalSize + ) { + int i = 0; +- BitSet bitSet = new BitSet(horizontalSize * verticalSize * horizontalSize); ++ BitSet bitSet = space.bxteam.divinemc.util.c2me.ObjectCachingUtils.getCachedOrNewBitSet(horizontalSize * verticalSize * horizontalSize); // DivineMC - C2ME: reduce_allocs + BlockPos.MutableBlockPos mutableBlockPos = new BlockPos.MutableBlockPos(); + int j = config.size; + double[] ds = new double[j * 4]; +diff --git a/src/main/java/space/bxteam/divinemc/util/c2me/ObjectCachingUtils.java b/src/main/java/space/bxteam/divinemc/util/c2me/ObjectCachingUtils.java +new file mode 100644 +index 0000000000000000000000000000000000000000..828b9cb2f6506b9775dfccc934e9a64d5ddfaeff +--- /dev/null ++++ b/src/main/java/space/bxteam/divinemc/util/c2me/ObjectCachingUtils.java +@@ -0,0 +1,20 @@ ++package space.bxteam.divinemc.util.c2me; ++ ++import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; ++ ++import java.util.BitSet; ++import java.util.function.IntFunction; ++ ++public class ObjectCachingUtils { ++ private static final IntFunction bitSetConstructor = BitSet::new; ++ ++ public static ThreadLocal> BITSETS = ThreadLocal.withInitial(Int2ObjectOpenHashMap::new); ++ ++ private ObjectCachingUtils() {} ++ ++ public static BitSet getCachedOrNewBitSet(int bits) { ++ final BitSet bitSet = BITSETS.get().computeIfAbsent(bits, bitSetConstructor); ++ bitSet.clear(); ++ return bitSet; ++ } ++}