Make mixin.perf.thread_priorities limit background thread count as well

This commit is contained in:
embeddedt 2025-07-27 14:55:34 -04:00
parent 87c977a3e6
commit ee6489fb69
No known key found for this signature in database
GPG Key ID: A69433EC199B5613

View File

@ -87,9 +87,21 @@ public class ModernFixMixinPlugin implements IMixinConfigPlugin {
t.setDaemon(true);
t.start();
}
if (ModernFixPlatformHooks.INSTANCE.isClient() && ModernFixMixinPlugin.instance.isOptionEnabled("perf.thread_priorities.AdjustThreadCount")) {
computeBetterThreadCount();
}
}
}
private void computeBetterThreadCount() {
// Server thread + client thread + GC thread
int reservedCores = 3;
int availableBackgroundCores = Math.max(1, Runtime.getRuntime().availableProcessors() - reservedCores);
logger.info("Configuring Minecraft's max.bg.threads option with {} threads", availableBackgroundCores);
System.setProperty("max.bg.threads", String.valueOf(availableBackgroundCores));
}
@Override
public void onLoad(String mixinPackage) {