Bawnorton/Neruina

Consider storing errored blockstates a different way

Closed this issue · 3 comments

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.

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

image

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.

Fixed in 2.1.0