Skip to content

Structurify

BonsUnleashed edited this page Oct 7, 2026 · 3 revisions

Structurify

Minecraft 1.20.1 / Forge: this page documents that build and its measurements. For the separate 170-control Minecraft 1.21.1 port, see Minecraft 1.21.1 NeoForge.

Three controls for Structurify 2.0.34+mc1.20.1 (mod id structurify): its height cache no longer keeps unloaded chunks in memory, structure-set settings are looked up with one map walk, and each checked structure start is remembered once instead of four times. Every switch checks the code it would change against the tested build; another build is left untouched with one WARN line (see How the patches are applied).

Key Target Side Since Kind
structurify_check_memo_slim Structurify 2.0.34+mc1.20.1 BOTH 1.0.30 opt
structurify_height_cache Structurify 2.0.34+mc1.20.1 BOTH 1.0.2 opt
structurify_set_data_single_lookup Structurify 2.0.34+mc1.20.1 BOTH 1.0.23 opt

structurify_height_cache

Target: Structurify 2.0.34+mc1.20.1 · Side: BOTH · Since: 1.0.2 · Kind: optimization Patched: com.faboslav.structurify.common.world.level.chunk.ChunkGeneratorHeightCache and ChunkGeneratorHeightCacheKey — 1.0.19 scripts bons_and_furious-ChunkGeneratorHeightCache.js, …HeightCacheKey.js, …HeightCache_1.js Mixins (since 1.0.20): ChunkGeneratorHeightCacheKeyMixin, ChunkGeneratorHeightCacheMixin

What upstream did. Structurify caches chunk-generator height lookups in a per-thread LRU cache. Each key held a strong reference to the LevelHeightAccessor, which during generation is the chunk being generated. A finished chunk therefore stayed reachable from the cache until the LRU happened to evict its keys, keeping otherwise dead chunk objects (and everything they reference) alive.

What the patch does. The key's accessor reference becomes a WeakReference with identity semantics, and a ReferenceQueue drains keys whose chunk has been collected. Live keys keep returning cached results; dead chunks become collectable.

What stays the same. The per-thread LRU limit, the results for live keys, and key equality for live accessors.

Measured. This is a retention fix, not a throughput change: 30,114 test assertions including 60,000 deterministic cache operations compared with the original, plus an actual garbage collection removing 512 stale keys. How many gigabytes the original reference path retained in real sessions was not established.


structurify_set_data_single_lookup

Since: 1.0.23 · Side: BOTH · Mixin: StructureSetDataLookupMixin · Helper: bons.furious.patch.structurify.SetDataLookup Patched: the two map calls inside Structurify's RandomSpreadUtil.getStructureSetData (redirected; no Structurify code is in our source, its licence is CC BY-NC-ND 4.0)

What upstream did. Every structure placement check asks Structurify for the set's spacing, separation, salt and frequency, and each answer walked Structurify's structure-set TreeMap twice (containsKey, then get).

What the patch does. The first walk reads the value and hands it to the second; a missing key returns nothing exactly as before, and a different map (a config reload in between) is read for real.

What stays the same. Every answer: in game all 1,073 structure sets answered identically with the switch on and off; 203,467 offline lookups identical.

Measured. One map walk instead of two; the lookups were 1.3 % of worker time in review 8.


structurify_check_memo_slim

Since: 1.0.30 · Target: Structurify 2.0.34+mc1.20.1 · Side: BOTH · Kind: opt

Mixin: StructureCheckMemoMixin

Structurify: each checked structure start is remembered once instead of four times. Structurify remembers, per structure and chunk, whether a structure start passed its overlap, biome and flatness checks, and never forgets it during a session. Besides the overall answer it also stored each of the three partial answers in a map of its own, and nothing ever reads those three maps: they are only written inside the overall computation, which runs once per start. The three checks now run exactly as before, in the same order and with the same results, but their partial answers are no longer stored, so every structure start checked during a session (new ones and every start loaded from disk) keeps one entry instead of four for as long as the server runs. Whether Structurify's checks are switched on or off does not matter.

Measured: on Structurify's own class, 333 instead of 83 bytes kept per checked structure start (100,000 starts; a long pregeneration checks hundreds of thousands), and 1,272 instead of 564 bytes allocated for each first check; 60,004 checks against the untransformed class with identical answers and maps, 8 threads, and 920,940 shadow comparisons.

Bons and Furious

Minecraft 1.20.1 / Forge 1.0.34

Compatibility

Controls by mod

Links

Clone this wiki locally