Skip to content

[Feature Request: <NeoForge/Fabric/NeoForge & Fabric>]: Sleeping Block Entities #183

Description

@Biquaternions

Minecraft Version

26.1+

Mod Loader

Both (NeoForge and Fabric)

Description

Summary

Lithium has this nice feature called Sleeping Block Entities, which to summarize, is a vanilla-friendly optimization that prevents block entities from being ticked at all, unless they receive an update.
See:
https://github.com/CaffeineMC/lithium/blob/develop/lithium-fabric-mixin-config.md#mixinworldblock_entity_tickingsleeping

This feature also has some improvements dedicated to hoppers.
See:
https://github.com/CaffeineMC/lithium/blob/develop/lithium-fabric-mixin-config.md#mixinblockhopper

Most of the logic for sleeping block entities can be found here, and so far looks relatively simple to implement, not sure if there are further improvements over the logic they already have:
https://github.com/CaffeineMC/lithium/tree/8b706c5c1bc27db217e548b6410ea23492fad896/common/src/main/java/net/caffeinemc/mods/lithium/mixin/world/block_entity_ticking/sleeping

Advantages

Moonrise at the moment seems to struggle quite a lot compared to Lithium when it comes to hoppers, and this feature, or a variation/improvement over its concept, will very much provide good performance gains for redstone builds, which tend to use a lot of block entities.

It is possible to run a very dumb and simple performance test to see the difference.
In this case, I created this world which contains a massive cube of hoppers facing north, all hoppers will push items into another hopper, and will get items pulled by the hopper below them.

Results on Lithium (~4m):
https://spark.lucko.me/NvH5jeFBPB

Results on Moonrise (~4m):
https://spark.lucko.me/2tTSkE7oAs

Results on Moonrise (~8m):
https://spark.lucko.me/RevNHWmWO6

World download:
hopper_world.gz

While this experiment is very artificial, as mentioned before, it will get massive improvements on servers with a lot of redstone builds, which do use similar amounts of block entities (notice the jump from 5mspt in lithium to 20mspt in moonrise).
Notice that most of the time spent on Lithium is only to check if any block entity (hopper) is sleeping (0.26%), or if it needs to tick, the actual ticking is even smaller.

Other advantages

Implementing this feature will also allow Paper to drop the hopper optimization patch, which apparently breaks some vanilla farms. Paper will only need to worry about triggering the events properly.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions