mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-28 07:20:24 +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:
parent
0abc9c4cd1
commit
cbf16b353d
2 changed files with 39 additions and 21 deletions
|
@ -169,7 +169,8 @@
|
|||
+ 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.progressListenerFactory = worldGenerationProgressListenerFactory;
|
||||
- this.storageSource = session;
|
||||
|
@ -620,11 +621,10 @@
|
|||
if (flush) {
|
||||
Iterator iterator1 = this.getAllLevels().iterator();
|
||||
|
||||
@@ -627,19 +891,41 @@
|
||||
public void close() {
|
||||
@@ -628,18 +892,40 @@
|
||||
this.stopServer();
|
||||
}
|
||||
+
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ private boolean hasStopped = false;
|
||||
+ private final Object stopLock = new Object();
|
||||
|
@ -634,7 +634,7 @@
|
|||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
||||
+
|
||||
public void stopServer() {
|
||||
+ // CraftBukkit start - prevent double stopping on multiple threads
|
||||
+ synchronized(this.stopLock) {
|
||||
|
@ -804,7 +804,7 @@
|
|||
+ SpigotTimings.commandFunctionsTimer.stopTiming(); // Spigot
|
||||
gameprofilerfiller.popPush("levels");
|
||||
Iterator iterator = this.getAllLevels().iterator();
|
||||
+
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ // Run tasks that are waiting on processing
|
||||
+ SpigotTimings.processQueueTimer.startTiming(); // Spigot
|
||||
|
@ -812,7 +812,7 @@
|
|||
+ this.processQueue.remove().run();
|
||||
+ }
|
||||
+ SpigotTimings.processQueueTimer.stopTiming(); // Spigot
|
||||
|
||||
+
|
||||
+ SpigotTimings.timeUpdateTimer.startTiming(); // Spigot
|
||||
+ // Send time updates to everyone, it will get the right time from the world the player is in.
|
||||
+ if (this.tickCount % 20 == 0) {
|
||||
|
@ -872,12 +872,10 @@
|
|||
|
||||
gameprofilerfiller.popPush("send chunks");
|
||||
iterator = this.playerList.getPlayers().iterator();
|
||||
@@ -1265,7 +1607,23 @@
|
||||
@Nullable
|
||||
public ServerLevel getLevel(ResourceKey<Level> key) {
|
||||
@@ -1267,6 +1609,22 @@
|
||||
return (ServerLevel) this.levels.get(key);
|
||||
+ }
|
||||
+
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ public void addLevel(ServerLevel level) {
|
||||
+ Map<ResourceKey<Level>, ServerLevel> oldLevels = this.levels;
|
||||
|
@ -891,11 +889,12 @@
|
|||
+ Map<ResourceKey<Level>, ServerLevel> newLevels = Maps.newLinkedHashMap(oldLevels);
|
||||
+ newLevels.remove(level.dimension());
|
||||
+ this.levels = Collections.unmodifiableMap(newLevels);
|
||||
}
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
||||
+
|
||||
public Set<ResourceKey<Level>> levelKeys() {
|
||||
return this.levels.keySet();
|
||||
}
|
||||
@@ -1296,7 +1654,7 @@
|
||||
|
||||
@DontObfuscate
|
||||
|
@ -905,6 +904,15 @@
|
|||
}
|
||||
|
||||
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 @@
|
||||
|
||||
public CompletableFuture<Void> reloadResources(Collection<String> dataPacks) {
|
||||
|
@ -945,20 +953,23 @@
|
|||
|
||||
try {
|
||||
arraylist = Lists.newArrayList(NativeModuleLister.listModules());
|
||||
@@ -2108,6 +2467,22 @@
|
||||
|
||||
}
|
||||
|
||||
@@ -2105,9 +2464,25 @@
|
||||
if (bufferedwriter != null) {
|
||||
bufferedwriter.close();
|
||||
}
|
||||
+
|
||||
+ }
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ public boolean isDebugging() {
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
|
||||
+ @Deprecated
|
||||
+ public static MinecraftServer getServer() {
|
||||
+ return (Bukkit.getServer() instanceof CraftServer) ? ((CraftServer) Bukkit.getServer()).getServer() : null;
|
||||
+ }
|
||||
+
|
||||
}
|
||||
|
||||
+ @Deprecated
|
||||
+ public static RegistryAccess getDefaultRegistryAccess() {
|
||||
+ return CraftRegistry.getMinecraftRegistry();
|
||||
|
|
|
@ -224,4 +224,11 @@ public class SpigotConfig
|
|||
}
|
||||
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 );
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue