1
0
Fork 0
mirror of https://github.com/PaperMC/Paper.git synced 2025-01-30 03:28:00 +01:00

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.

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot 2013-12-13 11:58:58 +11:00
parent 0abc9c4cd1
commit cbf16b353d
2 changed files with 39 additions and 21 deletions
paper-server
patches/sources/net/minecraft/server
src/main/java/org/spigotmc

View file

@ -169,7 +169,8 @@
+ services.profileCache().setExecutor(this); + services.profileCache().setExecutor(this);
} }
this.connection = new ServerConnectionListener(this); - this.connection = new ServerConnectionListener(this);
+ // this.connection = new ServerConnection(this); // Spigot
this.tickRateManager = new ServerTickRateManager(this); this.tickRateManager = new ServerTickRateManager(this);
- this.progressListenerFactory = worldGenerationProgressListenerFactory; - this.progressListenerFactory = worldGenerationProgressListenerFactory;
- this.storageSource = session; - this.storageSource = session;
@ -620,11 +621,10 @@
if (flush) { if (flush) {
Iterator iterator1 = this.getAllLevels().iterator(); Iterator iterator1 = this.getAllLevels().iterator();
@@ -627,19 +891,41 @@ @@ -628,18 +892,40 @@
public void close() {
this.stopServer(); this.stopServer();
} }
+
+ // CraftBukkit start + // CraftBukkit start
+ private boolean hasStopped = false; + private boolean hasStopped = false;
+ private final Object stopLock = new Object(); + private final Object stopLock = new Object();
@ -634,7 +634,7 @@
+ } + }
+ } + }
+ // CraftBukkit end + // CraftBukkit end
+
public void stopServer() { public void stopServer() {
+ // CraftBukkit start - prevent double stopping on multiple threads + // CraftBukkit start - prevent double stopping on multiple threads
+ synchronized(this.stopLock) { + synchronized(this.stopLock) {
@ -804,7 +804,7 @@
+ SpigotTimings.commandFunctionsTimer.stopTiming(); // Spigot + SpigotTimings.commandFunctionsTimer.stopTiming(); // Spigot
gameprofilerfiller.popPush("levels"); gameprofilerfiller.popPush("levels");
Iterator iterator = this.getAllLevels().iterator(); Iterator iterator = this.getAllLevels().iterator();
+
+ // CraftBukkit start + // CraftBukkit start
+ // Run tasks that are waiting on processing + // Run tasks that are waiting on processing
+ SpigotTimings.processQueueTimer.startTiming(); // Spigot + SpigotTimings.processQueueTimer.startTiming(); // Spigot
@ -812,7 +812,7 @@
+ this.processQueue.remove().run(); + this.processQueue.remove().run();
+ } + }
+ SpigotTimings.processQueueTimer.stopTiming(); // Spigot + SpigotTimings.processQueueTimer.stopTiming(); // Spigot
+
+ SpigotTimings.timeUpdateTimer.startTiming(); // Spigot + SpigotTimings.timeUpdateTimer.startTiming(); // Spigot
+ // Send time updates to everyone, it will get the right time from the world the player is in. + // Send time updates to everyone, it will get the right time from the world the player is in.
+ if (this.tickCount % 20 == 0) { + if (this.tickCount % 20 == 0) {
@ -872,12 +872,10 @@
gameprofilerfiller.popPush("send chunks"); gameprofilerfiller.popPush("send chunks");
iterator = this.playerList.getPlayers().iterator(); iterator = this.playerList.getPlayers().iterator();
@@ -1265,7 +1607,23 @@ @@ -1267,6 +1609,22 @@
@Nullable
public ServerLevel getLevel(ResourceKey<Level> key) {
return (ServerLevel) this.levels.get(key); return (ServerLevel) this.levels.get(key);
+ } }
+
+ // CraftBukkit start + // CraftBukkit start
+ public void addLevel(ServerLevel level) { + public void addLevel(ServerLevel level) {
+ Map<ResourceKey<Level>, ServerLevel> oldLevels = this.levels; + Map<ResourceKey<Level>, ServerLevel> oldLevels = this.levels;
@ -891,11 +889,12 @@
+ Map<ResourceKey<Level>, ServerLevel> newLevels = Maps.newLinkedHashMap(oldLevels); + Map<ResourceKey<Level>, ServerLevel> newLevels = Maps.newLinkedHashMap(oldLevels);
+ newLevels.remove(level.dimension()); + newLevels.remove(level.dimension());
+ this.levels = Collections.unmodifiableMap(newLevels); + this.levels = Collections.unmodifiableMap(newLevels);
} + }
+ // CraftBukkit end + // CraftBukkit end
+
public Set<ResourceKey<Level>> levelKeys() { public Set<ResourceKey<Level>> levelKeys() {
return this.levels.keySet(); return this.levels.keySet();
}
@@ -1296,7 +1654,7 @@ @@ -1296,7 +1654,7 @@
@DontObfuscate @DontObfuscate
@ -905,6 +904,15 @@
} }
public SystemReport fillSystemReport(SystemReport details) { public SystemReport fillSystemReport(SystemReport details) {
@@ -1507,7 +1865,7 @@
}
public ServerConnectionListener getConnection() {
- return this.connection;
+ return this.connection == null ? this.connection = new ServerConnectionListener(this) : this.connection; // Spigot
}
public boolean isReady() {
@@ -1634,11 +1992,11 @@ @@ -1634,11 +1992,11 @@
public CompletableFuture<Void> reloadResources(Collection<String> dataPacks) { public CompletableFuture<Void> reloadResources(Collection<String> dataPacks) {
@ -945,20 +953,23 @@
try { try {
arraylist = Lists.newArrayList(NativeModuleLister.listModules()); arraylist = Lists.newArrayList(NativeModuleLister.listModules());
@@ -2108,6 +2467,22 @@ @@ -2105,9 +2464,25 @@
if (bufferedwriter != null) {
} bufferedwriter.close();
}
+
+ }
+
+ // CraftBukkit start + // CraftBukkit start
+ public boolean isDebugging() { + public boolean isDebugging() {
+ return false; + return false;
+ } + }
+
+ @Deprecated + @Deprecated
+ public static MinecraftServer getServer() { + public static MinecraftServer getServer() {
+ return (Bukkit.getServer() instanceof CraftServer) ? ((CraftServer) Bukkit.getServer()).getServer() : null; + return (Bukkit.getServer() instanceof CraftServer) ? ((CraftServer) Bukkit.getServer()).getServer() : null;
+ } }
+
+ @Deprecated + @Deprecated
+ public static RegistryAccess getDefaultRegistryAccess() { + public static RegistryAccess getDefaultRegistryAccess() {
+ return CraftRegistry.getMinecraftRegistry(); + return CraftRegistry.getMinecraftRegistry();

View file

@ -224,4 +224,11 @@ public class SpigotConfig
} }
SpigotConfig.bungee = SpigotConfig.getBoolean( "settings.bungeecord", false ); SpigotConfig.bungee = SpigotConfig.getBoolean( "settings.bungeecord", false );
} }
private static void nettyThreads()
{
int count = SpigotConfig.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 );
}
} }