dmulloy2 / ProtocolLib

Provides read and write access to the Minecraft protocol with Bukkit.
GNU General Public License v2.0
982 stars 259 forks source link

1.20.6 PacketFilterManager.createPacket Performance #3024

Closed Dinos3396 closed 3 days ago

Dinos3396 commented 1 week ago

The performance for creating a new packet on 1.20.6 is terrible, on 1.20.4 it was so much better.

https://spark.lucko.me/wrwZuZrCCM https://mclo.gs/jZ9e6QF

Just to confirm, on 1.20.4 the performance is perfect. I dont understand why the performance is so bad on 1.20.6, the plugin that spikes at 80% was never above 1% back on 1.20.4 and nothing else changed, basically almost all plugins that were using protocolib that had excellent performance, now its terrible.

Ingrim4 commented 1 week ago

The issue is likely that we don't store a non-null value in the FAST_MAP_CONSTRUCTORS cache, causing it to be continuously looked up because null doesn't count as a "valid" value for computeIfAbsent.

https://github.com/dmulloy2/ProtocolLib/blob/47bcd53fd02041b77800910bcabd4382075bed06/src/main/java/com/comphenix/protocol/reflect/instances/MinecraftGenerator.java#L57C66-L57C81