Adjust default config location

Place the config in config/
This commit is contained in:
Spottedleaf
2024-08-08 16:22:52 -07:00
parent bbe9c0c041
commit 09d9292f90
7 changed files with 31 additions and 29 deletions

View File

@@ -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"
],

View File

@@ -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]]

View File

@@ -84,7 +84,12 @@ public final class YamlConfig<T> {
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 {

View File

@@ -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,

View File

@@ -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<MoonriseConfig> CONFIG;
static {

View File

@@ -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<Long> CHUNK_LOAD = TicketType.create("chunk_system:chunk_load", Long::compareTo);

View File

@@ -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;