From 4ca7ea3911a9b4de676fc74a374ac5fef5c886ba Mon Sep 17 00:00:00 2001 From: Julian Krings Date: Sat, 1 Nov 2025 22:36:25 +0100 Subject: [PATCH] minor speed improvements --- build.gradle.kts | 6 ++++-- .../java/com/volmit/iris/engine/mantle/MantleWriter.java | 9 +++++++-- .../com/volmit/iris/engine/mantle/MatterGenerator.kt | 5 ++--- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index dab32c3ac..2cdb4b811 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -58,8 +58,9 @@ registerCustomOutputTaskUnix("PixelMac", "/Users/test/Desktop/mcserver/plugins") registerCustomOutputTaskUnix("CrazyDev22LT", "/home/julian/Desktop/server/plugins") // ============================================================== -val serverMinHeap = "2G" -val serverMaxHeap = "8G" +val serverMinHeap = "10G" +val serverMaxHeap = "10G" +val additionalFlags = "-XX:+AlwaysPreTouch" //Valid values are: none, truecolor, indexed256, indexed16, indexed8 val color = "truecolor" val errorReporting = findProperty("errorReporting") as Boolean? ?: false @@ -106,6 +107,7 @@ nmsBindings.forEach { key, value -> systemProperty("com.mojang.eula.agree", true) systemProperty("iris.suppressReporting", !errorReporting) jvmArgs("-javaagent:${project(":core:agent").tasks.jar.flatMap { it.archiveFile }.get().asFile.absolutePath}") + jvmArgs(additionalFlags.split(' ')) } } diff --git a/core/src/main/java/com/volmit/iris/engine/mantle/MantleWriter.java b/core/src/main/java/com/volmit/iris/engine/mantle/MantleWriter.java index 021ccb67c..f8d00a2dc 100644 --- a/core/src/main/java/com/volmit/iris/engine/mantle/MantleWriter.java +++ b/core/src/main/java/com/volmit/iris/engine/mantle/MantleWriter.java @@ -183,8 +183,13 @@ public class MantleWriter implements IObjectPlacer, AutoCloseable { Iris.error("Mantle Writer Accessed chunk out of bounds" + cx + "," + cz); return null; } - MantleChunk chunk = cachedChunks.computeIfAbsent(Cache.key(cx, cz), k -> mantle.getChunk(cx, cz).use()); - if (chunk == null) Iris.error("Mantle Writer Accessed " + cx + "," + cz + " and came up null (and yet within bounds!)"); + final Long key = Cache.key(cx, cz); + MantleChunk chunk = cachedChunks.get(key); + if (chunk == null) { + chunk = mantle.getChunk(cx, cz).use(); + var old = cachedChunks.put(key, chunk); + if (old != null) old.release(); + } return chunk; } diff --git a/core/src/main/kotlin/com/volmit/iris/engine/mantle/MatterGenerator.kt b/core/src/main/kotlin/com/volmit/iris/engine/mantle/MatterGenerator.kt index 98340fd43..658c89cff 100644 --- a/core/src/main/kotlin/com/volmit/iris/engine/mantle/MatterGenerator.kt +++ b/core/src/main/kotlin/com/volmit/iris/engine/mantle/MatterGenerator.kt @@ -7,13 +7,12 @@ import com.volmit.iris.util.context.ChunkContext import com.volmit.iris.util.documentation.ChunkCoordinates import com.volmit.iris.util.mantle.Mantle import com.volmit.iris.util.mantle.flag.MantleFlag +import com.volmit.iris.util.parallel.MultiBurst import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.asCoroutineDispatcher import kotlinx.coroutines.flow.FlowCollector import kotlinx.coroutines.flow.flow import kotlinx.coroutines.launch import kotlinx.coroutines.runBlocking -import java.util.concurrent.Executors import kotlin.coroutines.EmptyCoroutineContext interface MatterGenerator { @@ -61,7 +60,7 @@ interface MatterGenerator { } companion object { - private val dispatcher = Executors.newVirtualThreadPerTaskExecutor().asCoroutineDispatcher() + private val dispatcher = MultiBurst.burst.dispatcher private fun CoroutineScope.launch(block: suspend CoroutineScope.() -> Unit) = launch(if (IrisSettings.get().generator.isUseMulticoreMantle) dispatcher else EmptyCoroutineContext, block = block) }