FerriteCore Documentation

repository·26.1·Indexed 18 days ago

https://github.com/malte0811/ferritecore

A 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.

Tokens
917
Snippets
0
Records
8
Agent score
15%

What's inside FerriteCore

  1. How FerriteCore optimizes BlockState neighbors

    26.1

    FerriteCore reduces memory usage for BlockState#with (finding neighbor states) by replacing vanilla's Table<Property<?>, Comparable<?>, S> implementation with a FastMap.

    In vanilla, memory usage scales as O((number of states) * sum(number of values per property)). FerriteCore's FastMap (implemented as an ArrayList used as a multi-dimensional array or via bitmasks) reduces this to O(number of states).

    Key Details:

    • Memory Savings: Approximately 600 MB.
    • Side: Both client and server.
    • Implementation: Uses the fastmap Mixin subpackage.
  2. How FerriteCore optimizes BlockState property storage

    26.1

    To reduce the memory footprint of ImmutableMap<Property<?>, Comparable<?>> used by each blockstate, FerriteCore replaces it with a custom implementation based on the FastMap logic. This removes the overhead of standard immutable maps.

    Key Details:

    • Memory Savings: Approximately 170 MB.
    • Side: Both client and server.
    • Implementation: Integrated within the fastmap code.
  3. How FerriteCore optimizes Multipart model predicate caching

    26.1

    Multipart 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 predicates Mixin subpackage.
  4. How FerriteCore optimizes Multipart model instances

    26.1

    By 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 dedupmultipart Mixin subpackage.
  5. How FerriteCore optimizes ThreadingDetector in PalettedContainer

    26.1

    In Minecraft 1.18+, PalettedContainer uses a ThreadingDetector to prevent multi-threaded access, which consumes memory for every loaded chunk section. FerriteCore proposes replacing this with a single byte field and using the PalettedContainer itself 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 threaddetec Mixin subpackage.
  6. How FerriteCore optimizes Blockstate cache deduplication

    26.1

    Blockstates 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 blockstatecache Mixin subpackage.
  7. How FerriteCore optimizes Quad deduplication

    26.1

    FerriteCore reduces memory used by baked quads (specifically their int[] vertex data) by using the same int[] instance for quads with identical data. This optimization is currently applied only to quads used in SimpleBakedModels to maintain safety.

    Key Details:

    • Memory Savings: Around 150 MB.
    • Side: Client.
    • Implementation: Uses the bakedquad Mixin subpackage.