Add thread pool priority setting
Setting this to 1 higher than C2ME can reduce issues with Chunky overwhelming DH.
This commit is contained in:
@@ -1456,6 +1456,7 @@ public class Config
|
||||
+ "How many threads should be used by Distant Horizons? \n"
|
||||
+ "")
|
||||
.build();
|
||||
|
||||
public static final ConfigEntry<Double> threadRunTimeRatio = new ConfigEntry.Builder<Double>()
|
||||
.setChatCommandName("threading.threadRunTimeRatio")
|
||||
.setMinDefaultMax(0.01, ThreadPresetConfigEventHandler.getDefaultRunTimeRatio(), 1.0)
|
||||
@@ -1469,6 +1470,19 @@ public class Config
|
||||
"")
|
||||
.build();
|
||||
|
||||
public static final ConfigEntry<Integer> threadPriority = new ConfigEntry.Builder<Integer>()
|
||||
.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();
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
+1
-1
@@ -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())
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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.",
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user