ProtocolLib

3M Downloads

Async packet listener significantly slower than sync listener

Ingrim4 opened this issue ยท 0 comments

commented
  • This issue is not solved in a development build

Describe the bug
I'm in the middle of updating my plugin (Orebfuscator) to 1.20.2. I noticed that the desired chunks per tick reported by the client (inside the CHUNK_BATCH_RECEIVED packet) was abysmally small compared to not using ProtocolLib/Orebfuscator when using an async packet listener for client-bound chunk related packets. So I did some research and found out that even a no-op async packet listener has the same problem. As far as I can tell this does not happen with a sync listener which reaches about the same chunks per tick as a clean spigot server.

That's why I created a test plugin to check the chunks per tick report by client if a sync or async listener is used with the following packets registered: MAP_CHUNK, CHUNK_BATCH_START, CHUNK_BATCH_FINISHED, CHUNK_BATCH_RECEIVED. The plugin switches between sync and async listener per command /throughput and I added some optional code to the listener that has to be uncommented to work. On replaces the chunks with empty chunks to eliminate the packet transfer size out of the equation (which didn't change the ratio of sync vs async). The other cancels the packet and sends it using the default packet stream (ProtocolFilterManager). What I have observed with the second uncommented is that the async packet listener reaches the same speed as the sync one. So my conclusion so far is that the packet reaches both listeners (onPacketSending) at roughly the same time but for some unknown reason the sending inside the async packet listener takes significantly longer. (If you need more info or want to talk to me about this issue please feel free to contact me on discord: ingrim4)

To Reproduce
Steps to reproduce the behavior:

  1. clone https://github.com/Imprex-Development/protocol-throughput
  2. mvn clean package (uses the latest ProtocolLib commit install in maven local, because the new PacketTypes are needed)
  3. put plugin and latest ProtocolLib dev build on server
  4. join server, fly some distance and observe chunks per tick in chat
  5. use the /throughput to switch to async listener
  6. repeat step 4 and compare significantly smaller numbers

Expected behavior
Async packet listeners should have roughly the same performance as sync listeners.

Version Info
Provide your ProtocolLib install info with /protocol dump through pastebin.
https://gist.github.com/Ingrim4/c860dc6473fb1a56827207a60e2aaa70