Tom's Simple Storage performance optimization

Fixed performance issues with Tom's Simple Storage

Tom's Simple Storage performance optimization

Minecraft 1.20.1 · Forge · requires Tom's Simple Storage 1.7.1+

This mod adds no content of its own. It is two hooks into Tom's Simple Storage's own classes, and it does nothing without it. Both changes remove repeated work and leave every result identical.

Opening a storage terminal rescans the whole network every server tick. The menu's broadcastChanges() runs once per tick while a screen is open, and getStacks() sets the "items changed" flag every time it is called. updateServer() then clears the item index and re-reads every slot of every connected container. The flag is set by a reader, so "rescan when dirty" becomes "rescan every tick while the screen is open". It is now set once every 10 ticks by default (configurable), which makes the list on screen up to half a second stale — a display refresh, not a transaction, so nothing can be duplicated or lost. Loading and linking an inventory are untouched and still rescan immediately.

The flat slot number is found with a linear scan. Every linked container shares one flat numbering, but only their sizes are kept, so getStackInSlot(slot) subtracts those sizes one at a time — O(containers) per lookup. The terminal walks every slot to rebuild its list, which makes one rebuild O(containers²): roughly 11,000 steps with 20 containers, 270,000 with 100. A prefix-sum array and a binary search now locate the container instead — the same method Forge's own CombinedInvWrapper uses — taking a rebuild to O(containers × log containers). The container and the local slot handed to it are identical to what the scan produced, so the item list is unchanged. Networks of 8 containers or fewer keep the original code path.

Config — config/tomsstorageperformanceoptimization-common.toml: enabled, throttleRescan, rescanIntervalTicks, fastSlotLookup. Setting enabled = false restores stock behaviour completely; each switch also works on its own.

Tom's Simple Storage performance optimization Team

profile avatar
  • 1
    Followers
  • 9
    Projects
  • 711
    Downloads

More from anderlyerView all