geforkt von Mirrors/Paper
b3b04f2ca1
Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: 9a4de097 SPIGOT-7171: Ability to get the IP/hostname players are requesting status of CraftBukkit Changes: f43634ae4 SPIGOT-7170: Cannot set slots in custom smithing inventory 48f3a2258 SPIGOT-7171: Ability to get the IP/hostname players are requesting status of 30e31b4d1 SPIGOT-7177: Certain blocks don't call BlockCanBuildEvent 982364797 SPIGOT-7174: Avoid adding air to CraftMetaBundle Spigot Changes: 6198b5ae PR-122: Add missing parentheses to pumpkin and melon growth modifier 1aec3fc1 Rebuild patches
56 Zeilen
2.7 KiB
Diff
56 Zeilen
2.7 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
|
|
Date: Tue, 22 Sep 2020 01:49:19 -0700
|
|
Subject: [PATCH] Optimise non-flush packet sending
|
|
|
|
Places like entity tracking make heavy use of packet sending,
|
|
and internally netty will use some very expensive thread wakeup
|
|
calls when scheduling.
|
|
|
|
Thanks to various hacks in ProtocolLib as well as other
|
|
plugins, we cannot simply use a queue of packets to group
|
|
send on execute. We have to call execute for each packet.
|
|
|
|
Tux's suggestion here is exactly what was needed - tag
|
|
the Runnable indicating it should not make a wakeup call.
|
|
|
|
Big thanks to Tux for making this possible as I had given
|
|
up on this optimisation before he came along.
|
|
|
|
Locally this patch drops the entity tracker tick by a full 1.5x.
|
|
|
|
diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java
|
|
index 28e91d015cf0034cd7ca952440fd4f915c34d489..08b74302e99e596a99f142856ae33ee29a9b1b77 100644
|
|
--- a/src/main/java/net/minecraft/network/Connection.java
|
|
+++ b/src/main/java/net/minecraft/network/Connection.java
|
|
@@ -46,6 +46,8 @@ import org.slf4j.Logger;
|
|
import org.slf4j.Marker;
|
|
import org.slf4j.MarkerFactory;
|
|
|
|
+
|
|
+import io.netty.util.concurrent.AbstractEventExecutor; // Paper
|
|
public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
|
|
|
|
private static final float AVERAGE_PACKETS_SMOOTHING = 0.75F;
|
|
@@ -419,9 +421,19 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
|
|
if (this.channel.eventLoop().inEventLoop()) {
|
|
this.doSendPacket(packet, callbacks, enumprotocol, enumprotocol1, flush); // Paper
|
|
} else {
|
|
+ // Paper start - optimise packets that are not flushed
|
|
+ // note: since the type is not dynamic here, we need to actually copy the old executor code
|
|
+ // into two branches. On conflict, just re-copy - no changes were made inside the executor code.
|
|
+ if (!flush) {
|
|
+ AbstractEventExecutor.LazyRunnable run = () -> {
|
|
+ this.doSendPacket(packet, callbacks, enumprotocol, enumprotocol1, flush); // Paper - add flush parameter
|
|
+ };
|
|
+ this.channel.eventLoop().execute(run);
|
|
+ } else { // Paper end - optimise packets that are not flushed
|
|
this.channel.eventLoop().execute(() -> {
|
|
- this.doSendPacket(packet, callbacks, enumprotocol, enumprotocol1, flush); // Paper
|
|
+ this.doSendPacket(packet, callbacks, enumprotocol, enumprotocol1, flush); // Paper - add flush parameter // Paper - diff on change
|
|
});
|
|
+ } // Paper
|
|
}
|
|
|
|
}
|