Questions about TileSpreader use of ItemStacks
gabizou opened this issue ยท 3 comments
So, in profiling SpongeForge lately to fix performance degradation with mods and mod packs, I've done some profiling and found some things that are rather odd. Notably that the TileSpreader
is deserializing ItemStack
s rather frequently, which is expensive to do almost always.
I've narrowed it down to this bit of code here where a new entity is being created to spread some mana I'm guessing, which calls some composite lenses that deconstruct an item stack from compound, here.
Now, I from what I can understand after briefly looking over this code, I believe it's deserializing an ItemStack
from the compound of the ItemStack
within the spreader. Would it not make sense to store the internal ItemStack
onto the TileSpreader
to avoid having to constantly deserialize the ItemStack
from the composite lens? Just speaking plainly about it here because I do care about compatibility, but seeing a single persons base set up in such a way where this sort of performance issue can arise on larger setups would become worrisome for not just us as developers, but server administrators and users alike.
Last thing I want to do is point fingers and delegate blame for anything (not blaming you, just want to open some dialogue) about how this can potentially be improved to reduce it's processing footprint.
The apply method needs to be universal in the lens class because it's called in other cases that create bursts.
^ also there was a bug that was always causing a stack to be deserialized even if a compound wasn't present. Fixed now, which should bring big gains in the common case where no composite lens is present.