f37381ea8a
Removes synchronization from sending packets Makes normal packet sends no longer need to be wrapped and queued like it use to work. Adds more packet queue immunities on top of keep alive to let the following scenarios go out without delay: - Keep Alive - Chat - Kick - All of the packets during the Player Joined World event Hoping that latter one helps join timeout issues more too for slow connections. Removes processing packet queue off of main thread - for the few cases where it is allowed, order is not necessary nor should it even be happening concurrently in first place (handshaking/login/status) Ensures packets sent asynchronously are dispatched on main thread This helps ensure safety for ProtocolLib as packet listeners are commonly accessing world state. This will allow you to schedule a packet to be sent async, but itll be dispatched sync for packet listeners to process. This should solve some deadlock risks This may provide a decent performance improvement because thread synchronization incurs a cache reset so by avoiding ever entering a synchronized block, we get to avoid that, and packet sending is a really hot activity.
58 Zeilen
2.4 KiB
Diff
58 Zeilen
2.4 KiB
Diff
From 46d39faab3128c9e0784d79f684421cfd0633385 Mon Sep 17 00:00:00 2001
|
|
From: Aikar <aikar@aikar.co>
|
|
Date: Wed, 6 May 2020 05:00:57 -0400
|
|
Subject: [PATCH] Handle Oversized Tile Entities in chunks
|
|
|
|
Splits out Extra Packets if too many TE's are encountered to prevent
|
|
creating too large of a packet to sed.
|
|
|
|
Co authored by Spottedleaf
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/PacketPlayOutMapChunk.java b/src/main/java/net/minecraft/server/PacketPlayOutMapChunk.java
|
|
index a0b87f89df7..23223f3f452 100644
|
|
--- a/src/main/java/net/minecraft/server/PacketPlayOutMapChunk.java
|
|
+++ b/src/main/java/net/minecraft/server/PacketPlayOutMapChunk.java
|
|
@@ -23,6 +23,15 @@ public class PacketPlayOutMapChunk implements Packet<PacketListenerPlayOut> {
|
|
|
|
public PacketPlayOutMapChunk() {}
|
|
|
|
+ // Paper start
|
|
+ private final java.util.List<Packet> extraPackets = new java.util.ArrayList<>();
|
|
+ private static final int TE_LIMIT = Integer.getInteger("Paper.excessiveTELimit", 750);
|
|
+
|
|
+ @Override
|
|
+ public java.util.List<Packet> getExtraPackets() {
|
|
+ return extraPackets;
|
|
+ }
|
|
+ // Paper end
|
|
public PacketPlayOutMapChunk(Chunk chunk, int i) {
|
|
ChunkCoordIntPair chunkcoordintpair = chunk.getPos();
|
|
|
|
@@ -49,6 +58,7 @@ public class PacketPlayOutMapChunk implements Packet<PacketListenerPlayOut> {
|
|
this.c = this.a(new PacketDataSerializer(this.j()), chunk, i);
|
|
this.g = Lists.newArrayList();
|
|
iterator = chunk.getTileEntities().entrySet().iterator();
|
|
+ int totalTileEntities = 0; // Paper
|
|
|
|
while (iterator.hasNext()) {
|
|
entry = (Entry) iterator.next();
|
|
@@ -57,6 +67,15 @@ public class PacketPlayOutMapChunk implements Packet<PacketListenerPlayOut> {
|
|
int j = blockposition.getY() >> 4;
|
|
|
|
if (this.f() || (i & 1 << j) != 0) {
|
|
+ // Paper start - improve oversized chunk data packet handling
|
|
+ if (++totalTileEntities > TE_LIMIT) {
|
|
+ PacketPlayOutTileEntityData updatePacket = tileentity.getUpdatePacket();
|
|
+ if (updatePacket != null) {
|
|
+ this.extraPackets.add(updatePacket);
|
|
+ continue;
|
|
+ }
|
|
+ }
|
|
+ // Paper end
|
|
NBTTagCompound nbttagcompound = tileentity.b();
|
|
if (tileentity instanceof TileEntitySkull) { TileEntitySkull.sanitizeTileEntityUUID(nbttagcompound); } // Paper
|
|
|
|
--
|
|
2.26.2
|
|
|