[GH-ISSUE #6823] Worldgen: the rotation table clones every block state six times (~45 ms of a world's open) #2230

Closed
opened 2026-11-02 15:53:12 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @Vaspyyy on GitHub (Nov 2, 2026).
Original GitHub issue: https://github.com/horizon-rust/horizon/issues/6823

Originally assigned to: @Vaspyyy on GitHub.

🤖 Filed by Vaspyyy's AI agent (Claude Code), not by Vaspyyy personally.

A CPU profile (samply) of a warm --world T --seed 1234 launch shows the "World data preload" thread spending a large share of its time in StateProviderBindings::rotations's one-time table (rotation_table). The coral features' decode builds it while prepare_decoration runs, and the world's open waits for that (world.make_streaming ends right after preload.decoration).

rotation_table clones every one of the registry's ~30k block states once per direction (six times) and looks each clone up by hash. Most states have neither a full axis nor a full or horizontal facing family, so every one of their rotations is the state itself. The pass first builds a BTreeMap keyed by cloned block names. In the profile, most of the time is allocation and freeing (BlockState::clone, mimalloc page frees, madvise). preload.decoration drops from ~165 ms to ~120 ms once it's skipped.

Proposal: rotate only the states that have one of the families, skip a rotation that sets the value the state already has, and borrow the map's keys. The table stays the same.

Originally created by @Vaspyyy on GitHub (Nov 2, 2026). Original GitHub issue: https://github.com/horizon-rust/horizon/issues/6823 Originally assigned to: @Vaspyyy on GitHub. > 🤖 Filed by Vaspyyy's AI agent (Claude Code), not by Vaspyyy personally. A CPU profile (samply) of a warm `--world T --seed 1234` launch shows the "World data preload" thread spending a large share of its time in `StateProviderBindings::rotations`'s one-time table (`rotation_table`). The coral features' decode builds it while `prepare_decoration` runs, and the world's open waits for that (`world.make_streaming` ends right after `preload.decoration`). `rotation_table` clones every one of the registry's ~30k block states once per direction (six times) and looks each clone up by hash. Most states have neither a full `axis` nor a full or horizontal `facing` family, so every one of their rotations is the state itself. The pass first builds a `BTreeMap` keyed by cloned block names. In the profile, most of the time is allocation and freeing (`BlockState::clone`, mimalloc page frees, `madvise`). `preload.decoration` drops from ~165 ms to ~120 ms once it's skipped. Proposal: rotate only the states that have one of the families, skip a rotation that sets the value the state already has, and borrow the map's keys. The table stays the same.
Author
Owner

@Vaspyyy commented on GitHub (Nov 2, 2026):

🤖 Agent: /claim

<!-- gh-comment-id:6570793877 --> @Vaspyyy commented on GitHub (Nov 2, 2026): 🤖 Agent: /claim
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#2230
No description provided.