Skip to content

Skip empty random-tick sections - #193

Open
HabsW wants to merge 3 commits into
Tuinity:mc/26.2from
HabsW:feature/skip-empty-random-tick-sections
Open

Skip empty random-tick sections#193
HabsW wants to merge 3 commits into
Tuinity:mc/26.2from
HabsW:feature/skip-empty-random-tick-sections

Conversation

@HabsW

@HabsW HabsW commented Aug 15, 2026

Copy link
Copy Markdown

Moonrise already skips the inner random-tick work when a section has no ticking blocks, but the outer loop still walks every section sequentially.

This change keeps a lightweight per-chunk bitset of sections with tickingBlockCount > 0. Sparse chunks only visit sections with active ticking blocks (in the exact same section index order as before), while dense chunks retain the original linear scan. Because empty sections never consumed random-tick RNG, skipping them maintains identical game timing and behavior. The mask is built on load, updated on 0/non-zero transitions, and rebound on the next random tick if a plugin replaces a section object through getSections() (WorldEdit/FAWE).

Benchmarks (optimiseRandomTick isolated)

Note: These metrics measure duration inside optimiseRandomTick only, not overall server MSPT.

Measured across 1,024 forceloaded chunks (random_tick_speed=3) on a Ryzen 9 9950X3D / JDK 25:

  • Normal Overworld: No change (613 µs → 614 µs)
  • Superflat World: 422 µs → 387 µs (1.09x)
  • Skyblock (Void + Grass): 231 µs → 121 µs (1.90x)
  • The End (Main Island): 234 µs → 115 µs (2.04x)

Reproduction & Reference

HabsW added 3 commits August 15, 2026 23:44
Moonrise already skips the inner random-tick loop when a section has no ticking blocks, but the outer loop still visits every section. Keep a live per-chunk bitset and skip empty sections when sparse.
Vanilla has no setSection hook. Detect getSections() identity changes at the start of optimiseRandomTick, unbind detached sections, and rebuild from tickingBlockCount. Also rebind after runPostLoad.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant