Files
Shiroha/shiroha-server/minecraft-patches/features/0040-Add-config-for-cpu-affinity.patch
T

34 lines
2.5 KiB
Diff
Raw Normal View History

2026-07-09 00:03:09 +08:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: MrHua269 <mrhua269@gmail.com>
Date: Fri, 17 Apr 2026 22:47:34 +0800
Subject: [PATCH] Add config for cpu affinity
diff --git a/io/papermc/paper/threadedregions/TickRegionScheduler.java b/io/papermc/paper/threadedregions/TickRegionScheduler.java
2026-07-14 15:09:17 +08:00
index 5a72fa0d72bfdb927293abe921c57f6ae964a6ec..e9d22c4b5f30284ca8e026533c24dca2bdb3001d 100644
2026-07-09 00:03:09 +08:00
--- a/io/papermc/paper/threadedregions/TickRegionScheduler.java
+++ b/io/papermc/paper/threadedregions/TickRegionScheduler.java
@@ -66,7 +66,7 @@ public final class TickRegionScheduler {
@Override
public Thread newThread(final Runnable run) {
- final Thread ret = new TickThreadRunner(this.threadGroup, run, "Folia Region Scheduler Thread #" + this.idGenerator.getAndIncrement());
2026-07-14 12:22:17 +08:00
+ final Thread ret = new TickThreadRunner(this.threadGroup, io.nanachiyo0721.shiroha.config.modules.optimizations.CpuAffinityConfig.wrapForTickRegion(run), "Folia Region Scheduler Thread #" + this.idGenerator.getAndIncrement()); // Shiroha - Add config for cpu affinity
2026-07-09 00:03:09 +08:00
ret.setUncaughtExceptionHandler(TickRegionScheduler.this::uncaughtException);
return ret;
}
2026-07-10 21:51:55 +08:00
diff --git a/net/minecraft/server/network/EventLoopGroupHolder.java b/net/minecraft/server/network/EventLoopGroupHolder.java
2026-07-14 15:09:17 +08:00
index 9544eaee7e02d00226d957ea0b79cd1a1fb0c4d0..bb49dd45c6fcb752640b07c49698c0ee28f81dcc 100644
2026-07-10 21:51:55 +08:00
--- a/net/minecraft/server/network/EventLoopGroupHolder.java
+++ b/net/minecraft/server/network/EventLoopGroupHolder.java
@@ -98,7 +98,8 @@ public abstract class EventLoopGroupHolder {
}
private ThreadFactory createThreadFactory() {
- return new ThreadFactoryBuilder().setNameFormat("Netty " + this.type + " IO #%d").setDaemon(true).setUncaughtExceptionHandler(new net.minecraft.DefaultUncaughtExceptionHandlerWithName(net.minecraft.server.MinecraftServer.LOGGER)).build(); // Paper
2026-07-14 11:32:51 +08:00
+ var origin = new ThreadFactoryBuilder().setNameFormat("Netty " + this.type + " IO #%d").setDaemon(true).setUncaughtExceptionHandler(new net.minecraft.DefaultUncaughtExceptionHandlerWithName(net.minecraft.server.MinecraftServer.LOGGER)).build(); // Paper // Shiroha - Add config for cpu affinity
2026-07-14 12:22:17 +08:00
+ return run -> origin.newThread(io.nanachiyo0721.shiroha.config.modules.optimizations.CpuAffinityConfig.wrapForNettyIo(run)); // Shiroha - Add config for cpu affinity
2026-07-10 21:51:55 +08:00
}
protected abstract IoHandlerFactory ioHandlerFactory();