Load the LOD world engine off the render thread on level reload (fix join freeze)#574
Open
Kishku7 wants to merge 1 commit into
Open
Load the LOD world engine off the render thread on level reload (fix join freeze)#574Kishku7 wants to merge 1 commit into
Kishku7 wants to merge 1 commit into
Conversation
LevelRenderer.allChanged opened and indexed the per-world LOD store (RocksDB open + Mapper load) synchronously on the render thread, freezing the client for several seconds on join for large stores. Build the engine on a background thread and create the GL VoxyRenderSystem back on the render thread once ready, guarded by a generation counter so level changes/disconnects mid-load are handled safely.
Cortex has a discord server, that's probably where this should be discussed: https://discord.gg/teErFatQv9 |
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.
Summary
LevelRenderer.allChangedbuilds the Voxy renderer synchronously, which opens and indexes the per-world LOD store (RocksDB open +Mapper/palette load) on the render thread. For a large store this freezes the client for several seconds on every join / dimension change.Fix
Build the
WorldEngineon a background thread, then create the GL-boundVoxyRenderSystemback on the render thread once it's ready. A generation counter (bumped on every shutdown/create, all on the render thread) lets an in-flight load detect that it has been superseded by a level change / disconnect / reload and discard itself safely. The GL object is still created on the render thread; only the disk I/O moves off it.Scope / testing
One file (
MixinLevelRenderer). Tested on MC 26.1.2 with a large LOD store (alongside VoxyServer): the join freeze is eliminated; LODs fill in a moment later as the engine finishes loading.Note for maintainer
VoxyInstance.getOrCreatestill holds itsStampedLockwrite lock across the build - now off the render thread, so it no longer freezes rendering, but it can briefly block othergetOrCreatecallers (e.g. ingest) during the first load. Relaxing that lock is a deeper change left out of scope here.Happy to discuss any of this - you can reach me on my Discord: https://discord.gg/2ZxzbCzAHe