Skip to content

Replace streams with loops in the chunk upload path - #575

Open
BonsUnleashed wants to merge 1 commit into
FiniteReality:20.1/forgefrom
BonsUnleashed:bons-furious/embeddium
Open

BonsUnleashed wants to merge 1 commit into
FiniteReality:20.1/forgefrom
BonsUnleashed:bons-furious/embeddium

Conversation

@BonsUnleashed

@BonsUnleashed BonsUnleashed commented Sep 29, 2026 •

Copy link
Copy Markdown

Proposed Changes

Removes stream and list allocations from the chunk mesh upload path:

  • RenderRegionManager: the mesh / index-only split and the vertex and index upload lists are built with plain loops instead of streams. An empty group uses the shared empty list. PendingResortUpload.indexUpload is always set, so the resort path no longer filters nulls.
  • RenderSectionManager.collectChunkBuildResults: returns an empty list when no build has finished, instead of allocating one every frame.
  • GlBufferArena.upload: takes a Collection<PendingUpload> instead of a Stream (RenderRegionManager is its only caller) and sums the remaining bytes in a loop.

Upload order and uploaded data are unchanged. With the same change applied to 0.3.31, classifying eight outputs went from about 151 ns and 504 bytes to 62 ns and 160 bytes, and frames with no finished builds no longer allocate here. It's not a measurable FPS change on its own.

Compiles on 20.1/forge (compileJava). Not tested in game on this branch.

Bons and Furious currently ships a patch for this: CurseForge · Modrinth (page still in review) · GitHub release

…kkeeping

Before drawing newly built chunks, the renderer organizes data and
creates temporary lists, even when some lists will be empty. These
changes reduce that preparation and create fewer temporary objects. The
same drawing data still reaches the graphics card; an overall frame-rate
gain has not been established.

Source port of a change shipped in Bons and Furious 1.0.15.
@github-actions

github-actions Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

DCO Assistant Lite bot All contributors have read and affirmed the entire contents of the Developer Certificate of Origin.

@BonsUnleashed BonsUnleashed changed the title Reduce allocation in upload classification, preparation and queue bookkeeping Replace streams with loops in the chunk upload path Sep 29, 2026
@BonsUnleashed

Copy link
Copy Markdown
Author

I have read and hereby affirm the entire contents of the Developer Certificate of Origin.

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.

1 participant