Profiling the encoding of CraftingDataPacket showed that significant performance losses are made due to the use of multiple closures for every ItemStack encoded.
Two closures are used:
To read/write the ItemStackNetId in the middle of the structure (used for all cases except creative and crafting data) - thanks for the awkward design Mojang
To scope-isolate the encoding/decoding of ItemStack extradata
Local experimentation showed ~20% performance improvements from replacing these closures with regular functions.
I'm not super clear why closures have such a large performance impact in this case, but we might want to investigate other usages too (e.g. optionals, first-class callables).
Profiling the encoding of CraftingDataPacket showed that significant performance losses are made due to the use of multiple closures for every ItemStack encoded.
Two closures are used:
Local experimentation showed ~20% performance improvements from replacing these closures with regular functions. I'm not super clear why closures have such a large performance impact in this case, but we might want to investigate other usages too (e.g. optionals, first-class callables).