Skip empty random-tick sections - #193
Open
HabsW wants to merge 3 commits into
Open
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 throughgetSections()(WorldEdit/FAWE).Benchmarks (
optimiseRandomTickisolated)Note: These metrics measure duration inside
optimiseRandomTickonly, not overall server MSPT.Measured across 1,024 forceloaded chunks (
random_tick_speed=3) on a Ryzen 9 9950X3D / JDK 25:Reproduction & Reference
docs/TEST.md.0001-Skip-empty-random-tick-sections.patch.