diff --git a/core/src/main/java/com/seibel/distanthorizons/core/config/Config.java b/core/src/main/java/com/seibel/distanthorizons/core/config/Config.java index 29738afb1..6b7e8d58d 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/config/Config.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/config/Config.java @@ -1456,6 +1456,7 @@ public class Config + "How many threads should be used by Distant Horizons? \n" + "") .build(); + public static final ConfigEntry threadRunTimeRatio = new ConfigEntry.Builder() .setChatCommandName("threading.threadRunTimeRatio") .setMinDefaultMax(0.01, ThreadPresetConfigEventHandler.getDefaultRunTimeRatio(), 1.0) @@ -1469,6 +1470,19 @@ public class Config "") .build(); + public static final ConfigEntry threadPriority = new ConfigEntry.Builder() + .setAppearance(EConfigEntryAppearance.ONLY_IN_FILE) // only in file since this requires a MC reboot to change + .setMinDefaultMax(Thread.MIN_PRIORITY, // 1 + Thread.NORM_PRIORITY, // 5 (1 higher than C2ME's default priority of 4 which can help reduce issues with Chunky) + Thread.MAX_PRIORITY) // 10 + .comment("" + + "What Java thread priority should DH's primary thread pools run with? \n" + + "\n" + + "You probably don't need to change this unless you are also \n" + + "running C2ME and are seeing thread starvation in either C2ME or DH. \n" + + "") + .build(); + } diff --git a/core/src/main/java/com/seibel/distanthorizons/core/util/threading/PriorityTaskPicker.java b/core/src/main/java/com/seibel/distanthorizons/core/util/threading/PriorityTaskPicker.java index 48b02bfaf..0b1b42619 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/util/threading/PriorityTaskPicker.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/util/threading/PriorityTaskPicker.java @@ -190,7 +190,7 @@ public class PriorityTaskPicker { return new RateLimitedThreadPoolExecutor( Config.Common.MultiThreading.numberOfThreads.get(), - new DhThreadFactory(this.name, 5, false), // TODO add config, just needs to be a couple higher than C2ME (default 4) for chunky to be mostly usable + new DhThreadFactory(this.name, Config.Common.MultiThreading.threadPriority.get(), false), new ArrayBlockingQueue<>(Runtime.getRuntime().availableProcessors()) ); } diff --git a/core/src/main/resources/assets/distanthorizons/lang/en_us.json b/core/src/main/resources/assets/distanthorizons/lang/en_us.json index f08afcf12..b8e5012cd 100644 --- a/core/src/main/resources/assets/distanthorizons/lang/en_us.json +++ b/core/src/main/resources/assets/distanthorizons/lang/en_us.json @@ -678,6 +678,10 @@ "How many threads DH will use.", "distanthorizons.config.common.multiThreading.threadRunTimeRatio": "Runtime % for threads", + "distanthorizons.config.common.multiThreading.threadPriority": + "Thread Priority", + "distanthorizons.config.common.multiThreading.threadPriority.@tooltip": + "What Java thread priority should DH's primary thread pools run with?\n\nYou probably don't need to change this unless you are also \nrunning C2ME and are seeing thread starvation in either C2ME or DH.",