Skip to content

Add biome uniform-section fast-path#6312

Merged
onebeastchris merged 1 commit intoGeyserMC:masterfrom
iwmedia:feature/biome-uniform-section-fast-path
Apr 21, 2026
Merged

Add biome uniform-section fast-path#6312
onebeastchris merged 1 commit intoGeyserMC:masterfrom
iwmedia:feature/biome-uniform-section-fast-path

Conversation

@ByteExceptionM
Copy link
Copy Markdown
Contributor

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.

Copilot AI review requested due to automatic review settings April 19, 2026 18:56
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 BlockStorage using SingletonBitArray with a single-entry Bedrock biome palette.
  • Preserve existing behavior for non-uniform sections by building the full BitArray and translated palette.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@valaphee
Copy link
Copy Markdown
Member

valaphee commented Apr 20, 2026

allSame should never occur, as this would indicate a SingletonPalette.

@ByteExceptionM
Copy link
Copy Markdown
Contributor Author

allSame should never occur, as this would indicate a SingletonPalette.

Tested this on a proxy - added a debug log on the fast-path. Under normal player load it hits hundreds of times per second.

Logs: image

Code used for the test: image

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.

@valaphee
Copy link
Copy Markdown
Member

valaphee commented Apr 20, 2026 via email

Copy link
Copy Markdown
Member

@valaphee valaphee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

code-wise LGTM

Copy link
Copy Markdown
Member

@onebeastchris onebeastchris left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@onebeastchris onebeastchris merged commit 79aab69 into GeyserMC:master Apr 21, 2026
5 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants