spigot/CraftBukkit-Patches/0032-Configurable-Amount-of-Netty-Threads.patch
2023-06-08 01:30:00 +10:00

48 lines
2.4 KiB
Diff

From 969e0eb154d7481c89cd93925b362bfc1c7aaf95 Mon Sep 17 00:00:00 2001
From: md_5 <git@md-5.net>
Date: Fri, 13 Dec 2013 11:58:58 +1100
Subject: [PATCH] Configurable Amount of Netty Threads
This brings back the option that the Spigot version of netty saw. By default Netty will try and use cores*2 threads, however if running multiple servers on the same machine, this can be too many threads. Additionally some people have 16 core servers. If 32 Netty threads are allowed in this setup, then the lock contention, and thus blocking between threads becomes much greater, leading to decreased performance.
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index d954adfac..01179bc91 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -343,7 +343,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
services.profileCache().setExecutor(this);
}
- this.connection = new ServerConnection(this);
+ // this.connection = new ServerConnection(this); // Spigot
this.progressListenerFactory = worldloadlistenerfactory;
this.storageSource = convertable_conversionsession;
this.playerDataStorage = convertable_conversionsession.createPlayerStorage();
@@ -1598,7 +1598,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
@Nullable
public ServerConnection getConnection() {
- return this.connection;
+ return this.connection == null ? this.connection = new ServerConnection(this) : this.connection; // Spigot
}
public boolean isReady() {
diff --git a/src/main/java/org/spigotmc/SpigotConfig.java b/src/main/java/org/spigotmc/SpigotConfig.java
index 3bb51f452..c5989e8e9 100644
--- a/src/main/java/org/spigotmc/SpigotConfig.java
+++ b/src/main/java/org/spigotmc/SpigotConfig.java
@@ -224,4 +224,11 @@ public class SpigotConfig
}
bungee = getBoolean( "settings.bungeecord", false );
}
+
+ private static void nettyThreads()
+ {
+ int count = getInt( "settings.netty-threads", 4 );
+ System.setProperty( "io.netty.eventLoopThreads", Integer.toString( count ) );
+ Bukkit.getLogger().log( Level.INFO, "Using {0} threads for Netty based IO", count );
+ }
}
--
2.40.1