Open
Conversation
For a while now chunks were only put into the map when they were confirmed to be 100% in loaded state and the held reference is quite a big memory hog. Requires testing
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.
This PR optimizes the Chunk Lifecycle by doing the following:
Back in my 1.21.4 (or 1.21.3?) changes, I moved the chunk registration in the SlimeInMemoryWorld to when the chunk is actually finalized and loaded instead of when the chunk was requested. This technically made SlimeChunks always safe, as they are added when they are loaded, removed when they are unloaded. To avoid any issues, I kept the old safe wrapper. However, this basically kept potentially huge old slime chunks in memory without any proper use. So this basically cuts the memory usage of each loaded chunk in slime worlds in half.
During my (and some user's) testing, we could not find any immediate issues, but that might not include very difficult edge cases. (However, if the safe slime reference was actually used before, we'd probably have had complains about slime chunks not properly saving?)
(Edit: The safe slime reference still exists in this codebase just in case we need it again, but we could just delete it idk)