Skip to content

Commit

Permalink
move from SingleThreadEventLoop to AbstractThreadEventLoop
Browse files Browse the repository at this point in the history
  • Loading branch information
wuangg committed Jan 17, 2024
1 parent f31d759 commit 178960d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions patches/server/1048-Optimise-non-flush-packet-sending.patch
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,22 @@ Locally this patch drops the entity tracker tick by a full 1.5x.
Co-authored-by: Quang Tran <[email protected]>

diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java
index 2ae08b21c63490bbf8cd870f9585d82ed131f815..435df4a71e19b84706d318d73cb11c1f82955251 100644
index 2ae08b21c63490bbf8cd870f9585d82ed131f815..a437257a7178fb5a272fc8d0941948c1fc72682f 100644
--- a/src/main/java/net/minecraft/network/Connection.java
+++ b/src/main/java/net/minecraft/network/Connection.java
@@ -148,6 +148,7 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
this.stopReadingPackets = true;
}
// Paper end - packet limiter
+ private io.netty.channel.SingleThreadEventLoop executor; // Paper - optimise packets that are not flushed
+ private io.netty.channel.AbstractEventLoop eventLoop; // Paper - optimise packets that are not flushed

public Connection(PacketFlow side) {
this.receiving = side;
@@ -156,6 +157,7 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
public void channelActive(ChannelHandlerContext channelhandlercontext) throws Exception {
super.channelActive(channelhandlercontext);
this.channel = channelhandlercontext.channel();
+ this.executor = (io.netty.channel.SingleThreadEventLoop) this.channel.eventLoop(); // Paper - optimise packets that are not flushed
+ this.eventLoop = (io.netty.channel.AbstractEventLoop) this.channel.eventLoop(); // Paper - optimise packets that are not flushed
this.address = this.channel.remoteAddress();
// Spigot Start
this.preparing = false;
Expand All @@ -47,7 +47,7 @@ index 2ae08b21c63490bbf8cd870f9585d82ed131f815..435df4a71e19b84706d318d73cb11c1f
} else {
+ // Paper start - optimise packets that are not flushed
+ if (!flush) {
+ this.executor.lazyExecute(() -> this.doSendPacket(packet, callbacks, flush));
+ this.eventLoop.lazyExecute(() -> this.doSendPacket(packet, callbacks, flush));
+ } else
+ // Paper end - optimise packets that are not flushed
this.channel.eventLoop().execute(() -> {
Expand Down

0 comments on commit 178960d

Please sign in to comment.