PaperMC/Spigot-Server-Patches/Improve-Network-Manager-packet-handling.patch
Aikar d1cbf1b137 Implement performance improvements from the EMC-CraftBukkit fork
See the individual patch files for more details
2014-10-19 17:58:49 -05:00

57 lines
No EOL
2.8 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Sun, 19 Oct 2014 16:01:51 -0500
Subject: [PATCH] Improve Network Manager packet handling
Removes an unnecessary "peek at head of queue", and also makes the number of packets
processed per player per tick configurable, so larger servers can slow down incoming processing.
diff --git a/src/main/java/net/minecraft/server/NetworkManager.java b/src/main/java/net/minecraft/server/NetworkManager.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/server/NetworkManager.java
+++ b/src/main/java/net/minecraft/server/NetworkManager.java
@@ -0,0 +0,0 @@ public class NetworkManager extends SimpleChannelInboundHandler {
private void i() {
if (this.m != null && this.m.isOpen()) {
- while (!this.l.isEmpty()) {
- QueuedPacket queuedpacket = (QueuedPacket) this.l.poll();
-
+ // PaperSpigot start - Improve Network Manager packet handling
+ QueuedPacket queuedpacket;
+ while ((queuedpacket = (QueuedPacket) this.l.poll()) != null) {
this.b(QueuedPacket.a(queuedpacket), QueuedPacket.b(queuedpacket));
}
+ // PaperSpigot end
}
}
@@ -0,0 +0,0 @@ public class NetworkManager extends SimpleChannelInboundHandler {
}
if (this.o != null) {
- for (int i = 1000; !this.k.isEmpty() && i >= 0; --i) {
- Packet packet = (Packet) this.k.poll();
+ // PaperSpigot start - Improve Network Manager packet handling - Configurable packets per player per tick processing
+ Packet packet;
+ for (int i = org.github.paperspigot.PaperSpigotConfig.maxPacketsPerPlayer; (packet = (Packet) this.k.poll()) != null && i >= 0; --i) {
+ // PaperSpigot end
// CraftBukkit start
if (!this.isConnected() || !this.m.config().isAutoRead()) {
diff --git a/src/main/java/org/github/paperspigot/PaperSpigotConfig.java b/src/main/java/org/github/paperspigot/PaperSpigotConfig.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/github/paperspigot/PaperSpigotConfig.java
+++ b/src/main/java/org/github/paperspigot/PaperSpigotConfig.java
@@ -0,0 +0,0 @@ public class PaperSpigotConfig
strengthEffectModifier = getDouble( "effect-modifiers.strength", 1.3D );
weaknessEffectModifier = getDouble( "effect-modifiers.weakness", -0.5D );
}
+
+ public static int maxPacketsPerPlayer;
+ private static void maxPacketsPerPlayer()
+ {
+ maxPacketsPerPlayer = getInt( "max-packets-per-player", 1000 );
+ }
}
--