[PR #3253] [MERGED] perf: storage primitives (dirty sections, packed index, palette scan, Fx maps) #4867

Closed
opened 2026-11-03 05:08:30 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/3253
Author: @hectoreccles
Created: 10/28/2026
Status: ✅ Merged
Merged: 10/29/2026
Merged by: @levzzz5154

Base: main ← Head: perf/opt-01-storage


📝 Commits (6)

  • ee351ca perf: mark only the distinct sections a block write dirties
  • 1e5cc90 perf: share the multiply-shift index between paletted storage and PackedStorage
  • 9b9d045 perf: find section palette ids with a scan and a last-state cache
  • d46bed5 perf: hash the world's integer bookkeeping maps with Fx
  • e41443c fix: address review findings
  • c784e57 Merge remote-tracking branch 'origin/main' into pt3/3253

📊 Changes

5 files changed (+263 additions, -117 deletions)

View changed files

📝 crates/horizon-client-render/src/world.rs (+91 -25)
📝 crates/horizon-client/src/save.rs (+2 -2)
📝 crates/horizon-core/src/paletted.rs (+2 -31)
📝 crates/horizon-core/src/storage.rs (+93 -9)
📝 crates/horizon-world/src/chunk.rs (+75 -50)

📄 Description

🤖 Opened by hectoreccles's AI agent (OpenCode, DeepSeek V4.1 Flash), not by hectoreccles himself.

What

Storage/memory primitives from optimization-notes/04-storage-memory.md:

  • 04 #1 — a block write marked the same dirty section up to 27 times. Mark only the distinct sections: 3 for an interior block, one extra column on a face, one diagonal at a corner (still the full 3×3×3 set the mesher needs).
  • 04 #3 — share one multiply-shift locate between paletted.rs and PackedStorage instead of a hardware divide per access. Measured on this arm64 machine, division is faster; the table is therefore gated to x86/x86_64 only. The dedup is unconditional; arm64 behaviour is unchanged.
  • 04 #5 — replace BlockSection.local_ids (one hash map + allocation per section) with a palette scan and a one-entry last-state cache.
  • 04 #9 — use the existing fast_hash Fx maps for World.modified/inhabited/chest_openers/block_names. BlockEntities::map is unchanged because lan::chunks::body takes the std HashMap type explicitly.

Validation

finding verdict evidence
04 #1 implemented Static: 27 map inserts → 1 interior / ≤8 at a corner; test compares against the old 27-cell set
04 #3 implemented, platform-gated Measured arm64: 65k reads 1.5 ms divide vs 2.5 ms table → gate; x86 keeps the table
04 #5 implemented Measured benchmark_section_get_set: set median 370.1 → 258.1 ns/op (1.43×)
04 #9 implemented Static: SipHash → Fx on per-block/per-container maps; no iteration-order dependence

Tests

cargo test -p horizon-core --lib (107), -p horizon-world --lib (178), -p horizon-world --test world_io (9), -p horizon-client --lib save:: (34), world:: (2); benchmark_section_get_set --ignored.

Full caveats (including the arm64 measurement and the untouched BlockEntities::map) are in the commit messages.

Stack

1 of 18. Target base: main (upstream). Next in stack: perf/opt-02-region.

🤖 Generated with OpenCode (DeepSeek V4.1 Flash).


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon/pull/3253 **Author:** [@hectoreccles](https://github.com/hectoreccles) **Created:** 10/28/2026 **Status:** ✅ Merged **Merged:** 10/29/2026 **Merged by:** [@levzzz5154](https://github.com/levzzz5154) **Base:** `main` ← **Head:** `perf/opt-01-storage` --- ### 📝 Commits (6) - [`ee351ca`](https://github.com/horizon-rust/horizon/commit/ee351caed8effedf821c3549d6ce1e135f573f20) perf: mark only the distinct sections a block write dirties - [`1e5cc90`](https://github.com/horizon-rust/horizon/commit/1e5cc9031f842bba7cadc94a14399ecaecd232d7) perf: share the multiply-shift index between paletted storage and PackedStorage - [`9b9d045`](https://github.com/horizon-rust/horizon/commit/9b9d0451502d8bf761756d71807b078483707cf8) perf: find section palette ids with a scan and a last-state cache - [`d46bed5`](https://github.com/horizon-rust/horizon/commit/d46bed5c36acecde5bd7771525ac143143885920) perf: hash the world's integer bookkeeping maps with Fx - [`e41443c`](https://github.com/horizon-rust/horizon/commit/e41443c64cb25212512b8f7800bbbf07b58326a1) fix: address review findings - [`c784e57`](https://github.com/horizon-rust/horizon/commit/c784e572d78ccd46e125e0a919a39660d309c201) Merge remote-tracking branch 'origin/main' into pt3/3253 ### 📊 Changes **5 files changed** (+263 additions, -117 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client-render/src/world.rs` (+91 -25) 📝 `crates/horizon-client/src/save.rs` (+2 -2) 📝 `crates/horizon-core/src/paletted.rs` (+2 -31) 📝 `crates/horizon-core/src/storage.rs` (+93 -9) 📝 `crates/horizon-world/src/chunk.rs` (+75 -50) </details> ### 📄 Description > 🤖 Opened by hectoreccles's AI agent (OpenCode, DeepSeek V4.1 Flash), not by hectoreccles himself. ## What Storage/memory primitives from `optimization-notes/04-storage-memory.md`: - **04 #1** — a block write marked the same dirty section up to 27 times. Mark only the distinct sections: 3 for an interior block, one extra column on a face, one diagonal at a corner (still the full 3×3×3 set the mesher needs). - **04 #3** — share one multiply-shift `locate` between `paletted.rs` and `PackedStorage` instead of a hardware divide per access. **Measured on this arm64 machine, division is faster; the table is therefore gated to x86/x86_64 only.** The dedup is unconditional; arm64 behaviour is unchanged. - **04 #5** — replace `BlockSection.local_ids` (one hash map + allocation per section) with a palette scan and a one-entry last-state cache. - **04 #9** — use the existing `fast_hash` Fx maps for `World.modified`/`inhabited`/`chest_openers`/`block_names`. `BlockEntities::map` is unchanged because `lan::chunks::body` takes the std `HashMap` type explicitly. ## Validation | finding | verdict | evidence | |---|---|---| | 04 #1 | implemented | Static: 27 map inserts → 1 interior / ≤8 at a corner; test compares against the old 27-cell set | | 04 #3 | implemented, platform-gated | Measured arm64: 65k reads 1.5 ms divide vs 2.5 ms table → gate; x86 keeps the table | | 04 #5 | implemented | Measured `benchmark_section_get_set`: set median 370.1 → 258.1 ns/op (1.43×) | | 04 #9 | implemented | Static: SipHash → Fx on per-block/per-container maps; no iteration-order dependence | ## Tests `cargo test -p horizon-core --lib` (107), `-p horizon-world --lib` (178), `-p horizon-world --test world_io` (9), `-p horizon-client --lib save::` (34), `world::` (2); `benchmark_section_get_set --ignored`. Full caveats (including the arm64 measurement and the untouched `BlockEntities::map`) are in the commit messages. ## Stack 1 of 18. Target base: `main` (upstream). Next in stack: `perf/opt-02-region`. 🤖 Generated with [OpenCode](https://opencode.ai) (DeepSeek V4.1 Flash). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 05:08:30 +07:00
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#4867
No description provided.