Skip to content

Commit ee6489f

Browse files
committed
Make mixin.perf.thread_priorities limit background thread count as well
1 parent 87c977a commit ee6489f

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

common/src/main/java/org/embeddedt/modernfix/core/ModernFixMixinPlugin.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,21 @@ public void run() {
8787
t.setDaemon(true);
8888
t.start();
8989
}
90+
91+
if (ModernFixPlatformHooks.INSTANCE.isClient() && ModernFixMixinPlugin.instance.isOptionEnabled("perf.thread_priorities.AdjustThreadCount")) {
92+
computeBetterThreadCount();
93+
}
9094
}
9195
}
9296

97+
private void computeBetterThreadCount() {
98+
// Server thread + client thread + GC thread
99+
int reservedCores = 3;
100+
int availableBackgroundCores = Math.max(1, Runtime.getRuntime().availableProcessors() - reservedCores);
101+
logger.info("Configuring Minecraft's max.bg.threads option with {} threads", availableBackgroundCores);
102+
System.setProperty("max.bg.threads", String.valueOf(availableBackgroundCores));
103+
}
104+
93105

94106
@Override
95107
public void onLoad(String mixinPackage) {

0 commit comments

Comments
 (0)