diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json index 0d7bd14..e8a144c 100644 --- a/fabric/src/main/resources/fabric.mod.json +++ b/fabric/src/main/resources/fabric.mod.json @@ -3,7 +3,7 @@ "id": "moonrise", "version": "${version}", "name": "Moonrise", - "description": "Optimisation mod for dedicated and integrated server.", + "description": "Optimisation mod for the dedicated and integrated server.", "authors": [ "Spottedleaf" ], diff --git a/neoforge/src/main/resources/META-INF/neoforge.mods.toml b/neoforge/src/main/resources/META-INF/neoforge.mods.toml index 4e6c96b..ca7a608 100644 --- a/neoforge/src/main/resources/META-INF/neoforge.mods.toml +++ b/neoforge/src/main/resources/META-INF/neoforge.mods.toml @@ -11,7 +11,7 @@ version = "${version}" displayName = "Moonrise" displayURL = "https://github.com/Tuinity/Moonrise" authors = "Spottedleaf" -description = "Moonrise NeoForge" +description = "Optimisation mod for the dedicated and integrated server." displayTest = "IGNORE_ALL_VERSION" [[dependencies.moonrise]] diff --git a/src/main/java/ca/spottedleaf/moonrise/common/config/config/YamlConfig.java b/src/main/java/ca/spottedleaf/moonrise/common/config/config/YamlConfig.java index a699aa4..4178579 100644 --- a/src/main/java/ca/spottedleaf/moonrise/common/config/config/YamlConfig.java +++ b/src/main/java/ca/spottedleaf/moonrise/common/config/config/YamlConfig.java @@ -84,7 +84,12 @@ public final class YamlConfig { throw new IOException("File is a directory"); } - final File tmp = new File(file.getParentFile(), file.getName() + ".tmp"); + final File parent = file.getParentFile(); + if (parent != null) { + parent.mkdirs(); + } + + final File tmp = new File(parent, file.getName() + ".tmp"); tmp.delete(); tmp.createNewFile(); try { diff --git a/src/main/java/ca/spottedleaf/moonrise/common/config/moonrise/MoonriseConfig.java b/src/main/java/ca/spottedleaf/moonrise/common/config/moonrise/MoonriseConfig.java index 795a950..c8fdeb4 100644 --- a/src/main/java/ca/spottedleaf/moonrise/common/config/moonrise/MoonriseConfig.java +++ b/src/main/java/ca/spottedleaf/moonrise/common/config/moonrise/MoonriseConfig.java @@ -162,6 +162,21 @@ public final class MoonriseConfig { ) public int workerThreads = -1; + @Serializable( + comment = """ + Set the number of threads dedicated to RegionFile I/O operations. + If the value is <= 0, then the number of threads used is 1. Configuring + a higher value than 1 is only recommended on SSDs (HDDs scale negatively) + and when you have determined that I/O is the bottleneck for chunk loading/saving. + """ + ) + @ClothConfig( + tooltip = "tooltip.moonrise.iothreads", + fieldKeyName = "option.moonrise.iothreads", + section = CHUNK_SYSTEM_SECTION + ) + public int ioThreads = -1; + @Override public void initialise() { MoonriseCommon.adjustWorkerThreads(this); @@ -174,21 +189,6 @@ public final class MoonriseConfig { @Adaptable public static final class ChunkSystem implements InitialiseHook { - @Serializable( - comment = """ - Set the number of threads dedicated to RegionFile I/O operations. - If the value is <= 0, then the number of threads used is 1. Configuring - a higher value than 1 is only recommended on SSDs (HDDs scale negatively) - and when you have determined that I/O is the bottleneck for chunk loading/saving. - """ - ) - @ClothConfig( - tooltip = "tooltip.moonrise.iothreads", - fieldKeyName = "option.moonrise.iothreads", - section = CHUNK_SYSTEM_SECTION - ) - public int ioThreads = -1; - @Serializable( comment = """ Whether to run generation population in parallel. By default this is set to false, diff --git a/src/main/java/ca/spottedleaf/moonrise/common/util/MoonriseCommon.java b/src/main/java/ca/spottedleaf/moonrise/common/util/MoonriseCommon.java index 93b93a2..2d4a0be 100644 --- a/src/main/java/ca/spottedleaf/moonrise/common/util/MoonriseCommon.java +++ b/src/main/java/ca/spottedleaf/moonrise/common/util/MoonriseCommon.java @@ -57,7 +57,12 @@ public final class MoonriseCommon { workerThreads = defaultWorkerThreads; } + final int ioThreads = Math.max(1, config.ioThreads); + WORKER_POOL.adjustThreadCount(workerThreads); + IO_POOL.adjustThreadCount(ioThreads); + + LOGGER.info("Moonrise is using " + workerThreads + " worker threads, " + ioThreads + " I/O threads"); } public static final PrioritisedThreadPool IO_POOL = new PrioritisedThreadPool( @@ -80,7 +85,7 @@ public final class MoonriseCommon { public static final long IO_QUEUE_HOLD_TIME = (long)(100.0e6); // 100ms public static final PrioritisedThreadPool.ExecutorGroup SERVER_REGION_IO_GROUP = IO_POOL.createExecutorGroup(SERVER_DIVISION, 0); - private static final File CONFIG_FILE = new File(System.getProperty("Moonrise.ConfigFile", "moonrise.yml")); + private static final File CONFIG_FILE = new File(System.getProperty("Moonrise.ConfigFile", "config/moonrise.yml")); private static final TypeAdapterRegistry CONFIG_ADAPTERS = new TypeAdapterRegistry(); private static final YamlConfig CONFIG; static { diff --git a/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ChunkTaskScheduler.java b/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ChunkTaskScheduler.java index c79f29a..cba47e1 100644 --- a/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ChunkTaskScheduler.java +++ b/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ChunkTaskScheduler.java @@ -67,17 +67,13 @@ public final class ChunkTaskScheduler { private static final Logger LOGGER = LoggerFactory.getLogger(ChunkTaskScheduler.class); public static void init(final MoonriseConfig.ChunkSystem config) { - final int newChunkSystemIOThreads = Math.max(1, config.ioThreads); - final boolean useParallelGen = config.populationGenParallelism; - MoonriseCommon.IO_POOL.adjustThreadCount(newChunkSystemIOThreads); - for (final PrioritisedThreadPool.ExecutorGroup.ThreadPoolExecutor executor : MoonriseCommon.RADIUS_AWARE_GROUP.getAllExecutors()) { executor.setMaxParallelism(useParallelGen ? -1 : 1); } - LOGGER.info("Chunk system is using " + newChunkSystemIOThreads + " I/O threads, " + MoonriseCommon.WORKER_POOL.getCoreThreads().length + " worker threads, population gen parallelism: " + useParallelGen); + LOGGER.info("Chunk system is using population gen parallelism: " + useParallelGen); } public static final TicketType CHUNK_LOAD = TicketType.create("chunk_system:chunk_load", Long::compareTo); @@ -1035,4 +1031,4 @@ public final class ChunkTaskScheduler { } } } -} \ No newline at end of file +} diff --git a/src/main/java/ca/spottedleaf/moonrise/patches/command/MoonriseCommand.java b/src/main/java/ca/spottedleaf/moonrise/patches/command/MoonriseCommand.java index c2abacf..feb843f 100644 --- a/src/main/java/ca/spottedleaf/moonrise/patches/command/MoonriseCommand.java +++ b/src/main/java/ca/spottedleaf/moonrise/patches/command/MoonriseCommand.java @@ -5,7 +5,6 @@ import ca.spottedleaf.moonrise.common.util.JsonUtil; import ca.spottedleaf.moonrise.common.util.MoonriseCommon; import ca.spottedleaf.moonrise.common.util.MoonriseConstants; import ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemServerLevel; -import ca.spottedleaf.moonrise.patches.chunk_system.player.ChunkSystemServerPlayer; import ca.spottedleaf.moonrise.patches.chunk_system.scheduling.ChunkTaskScheduler; import ca.spottedleaf.moonrise.patches.chunk_system.scheduling.NewChunkHolder; import ca.spottedleaf.moonrise.patches.starlight.light.StarLightLightingProvider; @@ -19,7 +18,6 @@ import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.Commands; import net.minecraft.network.chat.MutableComponent; import net.minecraft.network.chat.contents.PlainTextContents; -import net.minecraft.server.level.ServerPlayer; import net.minecraft.util.Mth; import net.minecraft.world.level.ChunkPos; import net.minecraft.world.level.chunk.ChunkAccess; @@ -29,8 +27,6 @@ import net.minecraft.world.level.chunk.ProtoChunk; import net.minecraft.world.phys.Vec3; import org.slf4j.Logger; import java.io.File; -import java.time.LocalDateTime; -import java.time.format.DateTimeFormatter; import java.util.ArrayList; import java.util.List;