Add biome uniform-section fast-path#6312
Conversation
There was a problem hiding this comment.
Pull request overview
This PR optimizes biome section serialization by detecting uniform biome sections (all 64 biome cells use the same palette index) and emitting a singleton-backed BlockStorage instead of expanding into a full 4096-entry BitArray, reducing work for the common case.
Changes:
- Add a uniform-section detection loop over the 64 biome cells in a section.
- When uniform, construct
BlockStorageusingSingletonBitArraywith a single-entry Bedrock biome palette. - Preserve existing behavior for non-uniform sections by building the full
BitArrayand translated palette.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
Tested this on a proxy - added a debug log on the fast-path. Under normal player load it hits hundreds of times per second. So there are real cases where a non-Singleton palette is sent but all 64 cells point to the same index. I didn't look into the exact server-side reason, but it happens a lot in practice and the fast-path skips the full 4096-entry BitArray expansion for it. |
|
Which server software are you using and whats the content of the palette?
If the palette contains an entry multiple times or unreferenced ones then
it should be considered a bug by the server implementation.
|


Most biome sections in a world are uniform (same biome across all 64 cells). Instead of always computing a full 4096-entry BitArray, we now check if all entries are the same first and use a SingletonBitArray in that case. Skips a lot of unnecessary work for the common case.