[PR #3259] [CLOSED] perf: resource loading (parallel recipes, manifest key, three lanes) #4870

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/3259
Author: @hectoreccles
Created: 10/28/2026
Status: ❌ Closed

Base: main ← Head: perf/opt-07-resource-loading


📝 Commits (10+)

  • 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
  • cd4b744 perf: write a region batch with one header write and an allocation cursor
  • e2a2cf4 perf: read region chunks with positioned I/O and a read lock
  • 50bf909 perf: bound the region cache and close idle region files
  • d26c7b4 perf: reuse one zlib stream and scratch buffer per thread
  • eac87c1 fix: pass the region sector bitmap as a slice to free_in
  • b2d7ec6 fix: avoid an explicit deref in the region cache test

📊 Changes

22 files changed (+2076 additions, -444 deletions)

View changed files

📝 crates/horizon-client/examples/probe/light_parity.rs (+1 -1)
📝 crates/horizon-client/src/audio.rs (+27 -1)
📝 crates/horizon-client/src/crafting.rs (+170 -36)
📝 crates/horizon-client/src/game.rs (+240 -46)
📝 crates/horizon-client/src/game/integrated.rs (+1 -9)
📝 crates/horizon-client/src/game/startup_menu.rs (+1 -0)
📝 crates/horizon-client/src/light.rs (+174 -23)
📝 crates/horizon-client/src/save.rs (+103 -27)
📝 crates/horizon-client/src/streaming.rs (+265 -53)
📝 crates/horizon-client/src/vanillagen.rs (+74 -24)
📝 crates/horizon-client/src/world.rs (+91 -25)
📝 crates/horizon-client/tests/generation_saves.rs (+1 -1)
📝 crates/horizon-core/src/paletted.rs (+64 -31)
📝 crates/horizon-core/src/storage.rs (+93 -9)
📝 crates/horizon-prepare/src/lib.rs (+33 -0)
📝 crates/horizon-world/src/chunk.rs (+83 -50)
📝 crates/horizon-world/src/compression.rs (+83 -23)
📝 crates/horizon-world/src/datafix/files.rs (+1 -1)
📝 crates/horizon-world/src/level/data/cache.rs (+172 -5)
📝 crates/horizon-world/src/main.rs (+1 -1)

...and 2 more files

📄 Description

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

What

Resource loading (optimization-notes/06-startup-runtime.md #2, #3, #7, #8):

  • 06 #2 — parse the 2,042 recipe files in contiguous ranges with std::thread::scope, concatenating in file order and printing warnings in the same order. Serial path when only one thread is available.
  • 06 #3 — key the behaviour snapshot with the hashes horizon-prepare already records (gameplay_facts_sha256, behaviour_sha256, per-file fluid-tag hashes) instead of SHA-256ing ~70 MB every launch. A newer file, an unlisted file, or a missing manifest falls back to hashing.
  • 06 #7 — the resource tail runs in three lanes joined in the existing order; Progress::set is fetch_max so the bar cannot go backwards; the first error (lane A, B, C) wins.
  • 06 #8 — a server's Audio::silent builds an empty SoundRegistry; music/ambience tables are also skipped on a server now that the loader's visuals flag is in scope. A client with HORIZON_NO_AUDIO still loads them for subtitles.

Validation

finding verdict evidence
06 #2 implemented Measured 2,042 files: warm serial 41.9–42.3 ms → 4 ranges 21.4–23.3 ms; cold serial 144.9 ms
06 #3 implemented Measured on 70 MB: release 143 ms → <1 ms with the manifest; debug 1,788 ms → 0 ms
06 #7 implemented (static) Three independent lanes, ordered merge, monotonic progress; end-to-end startup gain not measured
06 #8 implemented Test proves a server does not read sounds.json; role gate, not audio-output gate
06 #6 rejected Measured gameplay_decode_profile: validate 84–87 ms, typed 68–71 ms. The typed pass does not dominate, and dropping validation removes a trust-boundary check
06 #9/#11 rejected Architectural snapshot-all-tables / shared streaming pool; high risk, not a drive-by patch

Tests

cargo test -p horizon-client --lib -- crafting|logging|clock|audio|levels, --bin horizon-client -- loading_progress_never_goes_backwards, -p horizon-world --lib cache (8), -p horizon-threads --lib, -p horizon-prepare --all-targets check.

Stack

7 of 18. Stacked on perf/opt-06-server-loader; target base is upstream main, so until the predecessor merges its commits also appear here. Next: perf/opt-08-runtime.

🤖 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/3259 **Author:** [@hectoreccles](https://github.com/hectoreccles) **Created:** 10/28/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `perf/opt-07-resource-loading` --- ### 📝 Commits (10+) - [`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 - [`cd4b744`](https://github.com/horizon-rust/horizon/commit/cd4b744abcceb4fe6e524d97049ae89d3b439187) perf: write a region batch with one header write and an allocation cursor - [`e2a2cf4`](https://github.com/horizon-rust/horizon/commit/e2a2cf43871f3cfdb786787a0a74d6b836c351a1) perf: read region chunks with positioned I/O and a read lock - [`50bf909`](https://github.com/horizon-rust/horizon/commit/50bf909d7b29df9ec6d6e3fde7c66fe7e494b25a) perf: bound the region cache and close idle region files - [`d26c7b4`](https://github.com/horizon-rust/horizon/commit/d26c7b42c2534302c5b96b95f835c9e6a79624d7) perf: reuse one zlib stream and scratch buffer per thread - [`eac87c1`](https://github.com/horizon-rust/horizon/commit/eac87c1a0ba6dc08d0ec8ef898fdbf74e00fe7ab) fix: pass the region sector bitmap as a slice to free_in - [`b2d7ec6`](https://github.com/horizon-rust/horizon/commit/b2d7ec6b1bc8427fa2eaab1e25d338dcff2944df) fix: avoid an explicit deref in the region cache test ### 📊 Changes **22 files changed** (+2076 additions, -444 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/examples/probe/light_parity.rs` (+1 -1) 📝 `crates/horizon-client/src/audio.rs` (+27 -1) 📝 `crates/horizon-client/src/crafting.rs` (+170 -36) 📝 `crates/horizon-client/src/game.rs` (+240 -46) 📝 `crates/horizon-client/src/game/integrated.rs` (+1 -9) 📝 `crates/horizon-client/src/game/startup_menu.rs` (+1 -0) 📝 `crates/horizon-client/src/light.rs` (+174 -23) 📝 `crates/horizon-client/src/save.rs` (+103 -27) 📝 `crates/horizon-client/src/streaming.rs` (+265 -53) 📝 `crates/horizon-client/src/vanillagen.rs` (+74 -24) 📝 `crates/horizon-client/src/world.rs` (+91 -25) 📝 `crates/horizon-client/tests/generation_saves.rs` (+1 -1) 📝 `crates/horizon-core/src/paletted.rs` (+64 -31) 📝 `crates/horizon-core/src/storage.rs` (+93 -9) 📝 `crates/horizon-prepare/src/lib.rs` (+33 -0) 📝 `crates/horizon-world/src/chunk.rs` (+83 -50) 📝 `crates/horizon-world/src/compression.rs` (+83 -23) 📝 `crates/horizon-world/src/datafix/files.rs` (+1 -1) 📝 `crates/horizon-world/src/level/data/cache.rs` (+172 -5) 📝 `crates/horizon-world/src/main.rs` (+1 -1) _...and 2 more files_ </details> ### 📄 Description > 🤖 Opened by hectoreccles's AI agent (OpenCode, DeepSeek V4.1 Flash), not by hectoreccles himself. ## What Resource loading (`optimization-notes/06-startup-runtime.md` #2, #3, #7, #8): - **06 #2** — parse the 2,042 recipe files in contiguous ranges with `std::thread::scope`, concatenating in file order and printing warnings in the same order. Serial path when only one thread is available. - **06 #3** — key the behaviour snapshot with the hashes `horizon-prepare` already records (`gameplay_facts_sha256`, `behaviour_sha256`, per-file fluid-tag hashes) instead of SHA-256ing ~70 MB every launch. A newer file, an unlisted file, or a missing manifest falls back to hashing. - **06 #7** — the resource tail runs in three lanes joined in the existing order; `Progress::set` is `fetch_max` so the bar cannot go backwards; the first error (lane A, B, C) wins. - **06 #8** — a server's `Audio::silent` builds an empty `SoundRegistry`; music/ambience tables are also skipped on a server now that the loader's `visuals` flag is in scope. A client with `HORIZON_NO_AUDIO` still loads them for subtitles. ## Validation | finding | verdict | evidence | |---|---|---| | 06 #2 | implemented | Measured 2,042 files: warm serial 41.9–42.3 ms → 4 ranges 21.4–23.3 ms; cold serial 144.9 ms | | 06 #3 | implemented | Measured on 70 MB: release 143 ms → <1 ms with the manifest; debug 1,788 ms → 0 ms | | 06 #7 | implemented (static) | Three independent lanes, ordered merge, monotonic progress; end-to-end startup gain not measured | | 06 #8 | implemented | Test proves a server does not read `sounds.json`; role gate, not audio-output gate | | 06 #6 | rejected | Measured `gameplay_decode_profile`: validate 84–87 ms, typed 68–71 ms. The typed pass does not dominate, and dropping validation removes a trust-boundary check | | 06 #9/#11 | rejected | Architectural snapshot-all-tables / shared streaming pool; high risk, not a drive-by patch | ## Tests `cargo test -p horizon-client --lib -- crafting|logging|clock|audio|levels`, `--bin horizon-client -- loading_progress_never_goes_backwards`, `-p horizon-world --lib cache` (8), `-p horizon-threads --lib`, `-p horizon-prepare --all-targets` check. ## Stack 7 of 18. Stacked on `perf/opt-06-server-loader`; target base is upstream `main`, so until the predecessor merges its commits also appear here. Next: `perf/opt-08-runtime`. 🤖 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:32 +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#4870
No description provided.