FerriteCore Documentation
repository·26.1·Indexed 18 days ago
https://github.com/malte0811/ferritecoreA performance-oriented coremod for Minecraft focused on reducing RAM consumption. It implements internal optimizations including BlockState neighbor and property storage improvements via FastMap, multipart model predicate caching and instance deduplication, blockstate cache deduplication, and baked quad vertex data deduplication.
What's inside FerriteCore
- FerriteCore is a coremod designed to optimize memory usage in Minecraft. It implements various improvements to reduce the RAM footprint of the game, acting as a modern equivalent to memory-saving optimizations.
How FerriteCore optimizes BlockState neighbors
26.1FerriteCore reduces memory usage for
BlockState#with(finding neighbor states) by replacing vanilla'sTable<Property<?>, Comparable<?>, S>implementation with aFastMap.In vanilla, memory usage scales as
O((number of states) * sum(number of values per property)). FerriteCore'sFastMap(implemented as anArrayListused as a multi-dimensional array or via bitmasks) reduces this toO(number of states).Key Details:
- Memory Savings: Approximately 600 MB.
- Side: Both client and server.
- Implementation: Uses the
fastmapMixin subpackage.
How FerriteCore optimizes BlockState property storage
26.1To reduce the memory footprint of
ImmutableMap<Property<?>, Comparable<?>>used by each blockstate, FerriteCore replaces it with a custom implementation based on theFastMaplogic. This removes the overhead of standard immutable maps.Key Details:
- Memory Savings: Approximately 170 MB.
- Side: Both client and server.
- Implementation: Integrated within the
fastmapcode.
How FerriteCore optimizes Multipart model predicate caching
26.1Multipart models use predicates to determine which parts to show. FerriteCore caches these predicates to avoid redundant allocations.
- KeyValueCondition: Cached using the property and its value as a key.
- And/OrCondition: Cached using a list of input predicates sorted by hash value.
This is highly effective for blocks like pipes that use many boolean properties (e.g.,
north,south).Key Details:
- Memory Savings: 300-400 MB.
- Side: Client.
- Implementation: Uses the
predicatesMixin subpackage.
How FerriteCore optimizes Multipart model instances
26.1By default, every blockstate using a multipart model gets its own instance. FerriteCore deduplicates these instances by reusing the same instance for equivalent lists of
Pair<Predicate<BlockState>, IBakedModel>.Key Details:
- Memory Savings: Close to 200 MB.
- Side: Client.
- Implementation: Uses the
dedupmultipartMixin subpackage.
How FerriteCore optimizes ThreadingDetector in PalettedContainer
26.1In Minecraft 1.18+,
PalettedContaineruses aThreadingDetectorto prevent multi-threaded access, which consumes memory for every loaded chunk section. FerriteCore proposes replacing this with a singlebytefield and using thePalettedContaineritself as a monitor.Note: This optimization is disabled by default due to rare race conditions observed under unknown circumstances.
Key Details:
- Memory Savings: 10-15 MB per player (scales with loaded chunks).
- Side: Both client and server.
- Implementation: Uses the
threaddetecMixin subpackage.
How FerriteCore optimizes Blockstate cache deduplication
26.1Blockstates that are not marked as "variable opacity" cache their collision and render shapes. FerriteCore deduplicates these by reusing existing shape instances for blocks that share the same shapes.
To handle mods that cache their own shapes internally, FerriteCore replaces the "internals" of the voxel shape returned by the block with the internals of the "canonical" instance. This is safe because vanilla assumes shapes are immutable once created.
Key Details:
- Memory Savings: Around 200 MB.
- Side: Both client and server.
- Implementation: Uses the
blockstatecacheMixin subpackage.
How FerriteCore optimizes Quad deduplication
26.1FerriteCore reduces memory used by baked quads (specifically their
int[]vertex data) by using the sameint[]instance for quads with identical data. This optimization is currently applied only to quads used inSimpleBakedModels to maintain safety.Key Details:
- Memory Savings: Around 150 MB.
- Side: Client.
- Implementation: Uses the
bakedquadMixin subpackage.