Waterfall icon indicating copy to clipboard operation
Waterfall copied to clipboard

Use ByteBuf#copy only when entity rewrite is actually used

Open BoomEaro opened this issue 1 year ago • 8 comments

This pull request returns the ability to slice ByteBuf when decoding a packet in the MinecraftDecoder class as it did before, but only if entity rewrite was never used. If I understand correctly, the original reason for using copy is that entity rewrite can write more bytes than is possible in the slice itself. Therefore, most likely there is no point in constantly copying bytes even when we are not going to change them.

I would like to know your opinion on this, what it could possibly break and whether it makes any sense at all, since I have not had much experience with netty yet.

BoomEaro avatar Apr 03 '23 10:04 BoomEaro

This was long on the list of stuff that I wanted to look into, given that we're not rewriting this stuff, I did wanna look into adding a mechanism to literally just skip packets and let the proxy not care about them, even if registered

electronicboy avatar Apr 03 '23 10:04 electronicboy

There's no such thing as skipping packets, you always have to check packet id. And slicing instead of copying is already a big progress. Not sure what else can be done here to optimize performance.

Janmm14 avatar Apr 03 '23 15:04 Janmm14

I mean skip the decode + handle + encode chain for unneeded packets in certain configs; if we're not rewriting entity metadata, then we can skip a bunch of work

electronicboy avatar Apr 03 '23 15:04 electronicboy

I mean skip the decode + handle + encode chain for unneeded packets in certain configs; if we're not rewriting entity metadata, then we can skip a bunch of work

Bungee doesn't use decoding into object fields for most entity rewriting stuff.

Janmm14 avatar Apr 03 '23 15:04 Janmm14

True, but part of it was for other stuff like scoreboards, etc; it's probably not a big deal, and probs not something I'm ever going to care to get to considering the state of this project

electronicboy avatar Apr 03 '23 15:04 electronicboy

This commit would likely break several plugins like ViaVersion that are expecting a grow-able, copied buffer. If anything, it should be made into a configurable option for the user to decide.

bob7l avatar Apr 21 '23 09:04 bob7l

This commit would likely break several plugins like ViaVersion that are expecting a grow-able, copied buffer. If anything, it should be made into a configurable option for the user to decide.

Statement from someone knowing viaverson-bungee is needed. Don't want some useless config option or startup flag.

Janmm14 avatar Apr 22 '23 00:04 Janmm14

This would only theoretically occur if the option were disabled

xism4 avatar Jun 18 '23 14:06 xism4