Skip to content

Memory improvements for chunks #197

Open
davidmayr wants to merge 3 commits intodevelopfrom
dev/performance-improvements-nbt
Open

Memory improvements for chunks #197
davidmayr wants to merge 3 commits intodevelopfrom
dev/performance-improvements-nbt

Conversation

@davidmayr
Copy link
Copy Markdown
Member

@davidmayr davidmayr commented May 10, 2026

This PR optimizes the Chunk Lifecycle by doing the following:

  • Optimize NBT Converter by allocating Lists with the proper sizes
  • Avoid streams in hot paths
  • Remove the safe slime reference (elaborted below)

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)

davidmayr added 3 commits May 1, 2026 23:55
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
@davidmayr davidmayr added the enhancement New feature or request label May 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant