[Enhancement] Serialize custom packet in networking thread instead of the client/server thread #3335
Labels
enhancement
New feature or request
fabric-networking
Pull requests and issues related to the networking api
Currently, for the new object-based networking API, when creating the packet, it serializes the packet in the clinet/server main thread. Vanilla packets are serialized on networking thread. If the packet is large, moving the serialization to networking thread could improve performance. What's more, in singleplayer, the packet objects are passed by object reference, not serialized or deserialized, to improve performance, so it could also improve performance for singleplayer case.
https://github.com/FabricMC/fabric/blob/1.20.2/fabric-networking-api-v1/src/main/java/net/fabricmc/fabric/impl/networking/server/ServerNetworkingImpl.java#L66C21-L66C21
The payload object carries
PacketByteBuf
. It's possible to make it to carry the packet object instead of buffer. https://github.com/FabricMC/fabric/blob/1.20.2/fabric-networking-api-v1/src/main/java/net/fabricmc/fabric/impl/networking/payload/PacketByteBufPayload.javaThis cannot be done to the old networking API because it accepts the
PacketByteBuf
as argument.The text was updated successfully, but these errors were encountered: