Neruina - Ticking Entity Fixer

Neruina - Ticking Entity Fixer

19M Downloads

Consider storing errored blockstates a different way

embeddedt opened this issue ยท 3 comments

commented

BlockStateMixin currently adds an extra field to every block state, and initializes it with a unique Object2BooleanOpenHashMap object.

private final Object2BooleanMap<BlockPos> neruina$errored = new Object2BooleanOpenHashMap<>();

This will add up to quite a bit of additional memory usage in larger modpacks; it's not uncommon for there to be over 400,000 blockstates in total. Since most blockstates will not be errored, the maps are rarely going to be used and thus will just waste memory.

As an alternative, I would suggest storing this data using either a global map of BlockState/BlockPos pairs, or just a Map<BlockState, Object2BooleanOpenHashMap<BlockPos>>. Both solutions avoid baseline memory usage scaling with the number of blockstates.

commented

Yup, makes sense. This was an oversight, I'll bundle this change into the next release which should follow shortly after arch merges their forge 1.20.6+ fix.. or if that takes too long I'll just drop lex forge.

commented

Looks like in the pack I am using for testing the maps consume about 100MB of memory by themselves.

image

commented

Fixed in 2.1.0