[PR #4008] [MERGED] Resource packs: native overlay junctions and parallel staging on Windows (7 s → 2.3 s) #5350

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/4008
Author: @Joansitoh
Created: 10/29/2026
Status: ✅ Merged
Merged: 10/31/2026
Merged by: @rdbtCVS

Base: main ← Head: fix/windows-pack-reload-speed


📝 Commits (3)

  • acce84e Resource packs: create overlay junctions natively and load models and GUI atlas side by side
  • 8ae79aa Merge upstream/main into fix/windows-pack-reload-speed
  • e10efca horizon-threads: check the junction reparse buffer's length sums

📊 Changes

4 files changed (+115 additions, -28 deletions)

View changed files

📝 crates/horizon-client-render/src/packs.rs (+3 -23)
📝 crates/horizon-client/src/game/packs.rs (+11 -3)
📝 crates/horizon-threads/Cargo.toml (+2 -2)
📝 crates/horizon-threads/src/lib.rs (+99 -0)

📄 Description

🤖 Opened by Joansitoh's AI agent (Claude Code), not by Joansitoh.

What and why

Accepting a server resource pack still took ~7 s on Windows after #3438 (vanilla: ~1 s). Timed each phase of stage_pack while joining a real server that pushes a small pack (44 files, 841 KB), on Windows 11, --profile fast, overlay cache empty:

phase before after
overlay (packs::resource_root) 4.31 s 0.31 s
models + sprites (Assets::reload) 0.92 s 1.09 s (in parallel with the GUI atlas and panorama)
GUI atlas (HudAtlas::build_over) + panorama 0.94 s
PackResources::load + texture prep 0.58 s 0.53 s
GPU apply (render thread) 0.37 s 0.38 s
total ~7.1 s ~2.3 s

Two changes:

  1. Native junctions. Each untouched directory in the overlay was linked with a cmd /C mklink /J process, ~100 ms each on Windows (34 of them measured at 3.4 s). junction now sets the mount point reparse point directly (FSCTL_SET_REPARSE_POINT), the same thing mklink /J does, without a process. It lives in horizon-threads, the crate for the OS calls the crates that forbid(unsafe_code) can't make; horizon-client-render just calls it. If it fails, the directory is removed and the overlay falls back to mirroring, as before. The existing overlay_layers_packs_over_vanilla test checks the untouched directory is a link and reads through it, under a path with &.
  2. Parallel staging. Assets::reload, HudAtlas::build_over and the panorama read the same root and nothing of each other, so stage_pack runs them on three scoped threads (already on the pack-reload worker).

Not in this PR: most of the remaining ~1 s rebuilds every vanilla sprite and model even when a pack changes a few files; reusing them across reloads would be a follow-up.

Vanilla reference

None: how the overlay is built on Windows and how the reload is scheduled. Resources loaded are the same.

Self-check

tools/pr_ready.py --quick on Windows 11:

Check Result
Scope ✅ 4 files, +80 −28
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 416 passed
rustfmt ✅
clippy ❌ manual_range_contains in horizon-world/src/worldgen/aquifer/noise_based.rs:450 and horizon-client-render/src/camera.rs:676, neither in this diff (local clippy 1.97). cargo clippy -p horizon-threads -p horizon-client-render -p horizon-client --all-targets --no-deps shows nothing else
tests: horizon-client, horizon-client-render, horizon-threads ✅ 1353 passed
doc tests ✅
Parity ➖ not run (--quick)

Rechecked on top of current main: packs:: tests 11 passed, horizon-threads tests pass.

🤖 Generated with Claude Code


🔄 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/4008 **Author:** [@Joansitoh](https://github.com/Joansitoh) **Created:** 10/29/2026 **Status:** ✅ Merged **Merged:** 10/31/2026 **Merged by:** [@rdbtCVS](https://github.com/rdbtCVS) **Base:** `main` ← **Head:** `fix/windows-pack-reload-speed` --- ### 📝 Commits (3) - [`acce84e`](https://github.com/horizon-rust/horizon/commit/acce84e884cb9d85b8c409f1e48c4b4368cd13b0) Resource packs: create overlay junctions natively and load models and GUI atlas side by side - [`8ae79aa`](https://github.com/horizon-rust/horizon/commit/8ae79aaad44bfe63020f89c5e643b8babb001dea) Merge upstream/main into fix/windows-pack-reload-speed - [`e10efca`](https://github.com/horizon-rust/horizon/commit/e10efca1bc79ae4fc8a4a810b4e068e02e5fd1e6) horizon-threads: check the junction reparse buffer's length sums ### 📊 Changes **4 files changed** (+115 additions, -28 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client-render/src/packs.rs` (+3 -23) 📝 `crates/horizon-client/src/game/packs.rs` (+11 -3) 📝 `crates/horizon-threads/Cargo.toml` (+2 -2) 📝 `crates/horizon-threads/src/lib.rs` (+99 -0) </details> ### 📄 Description > 🤖 Opened by Joansitoh's AI agent (Claude Code), not by Joansitoh. ## What and why Accepting a server resource pack still took ~7 s on Windows after #3438 (vanilla: ~1 s). Timed each phase of `stage_pack` while joining a real server that pushes a small pack (44 files, 841 KB), on Windows 11, `--profile fast`, overlay cache empty: | phase | before | after | | --- | --- | --- | | overlay (`packs::resource_root`) | 4.31 s | 0.31 s | | models + sprites (`Assets::reload`) | 0.92 s | 1.09 s (in parallel with the GUI atlas and panorama) | | GUI atlas (`HudAtlas::build_over`) + panorama | 0.94 s | | | `PackResources::load` + texture prep | 0.58 s | 0.53 s | | GPU apply (render thread) | 0.37 s | 0.38 s | | **total** | **~7.1 s** | **~2.3 s** | Two changes: 1. **Native junctions.** Each untouched directory in the overlay was linked with a `cmd /C mklink /J` process, ~100 ms each on Windows (34 of them measured at 3.4 s). `junction` now sets the mount point reparse point directly (`FSCTL_SET_REPARSE_POINT`), the same thing `mklink /J` does, without a process. It lives in `horizon-threads`, the crate for the OS calls the crates that `forbid(unsafe_code)` can't make; `horizon-client-render` just calls it. If it fails, the directory is removed and the overlay falls back to mirroring, as before. The existing `overlay_layers_packs_over_vanilla` test checks the untouched directory is a link and reads through it, under a path with `&`. 2. **Parallel staging.** `Assets::reload`, `HudAtlas::build_over` and the panorama read the same root and nothing of each other, so `stage_pack` runs them on three scoped threads (already on the pack-reload worker). Not in this PR: most of the remaining ~1 s rebuilds every vanilla sprite and model even when a pack changes a few files; reusing them across reloads would be a follow-up. ## Vanilla reference None: how the overlay is built on Windows and how the reload is scheduled. Resources loaded are the same. ## Self-check `tools/pr_ready.py --quick` on Windows 11: | Check | Result | | --- | --- | | Scope | ✅ 4 files, +80 −28 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 416 passed | | rustfmt | ✅ | | clippy | ❌ `manual_range_contains` in `horizon-world/src/worldgen/aquifer/noise_based.rs:450` and `horizon-client-render/src/camera.rs:676`, neither in this diff (local clippy 1.97). `cargo clippy -p horizon-threads -p horizon-client-render -p horizon-client --all-targets --no-deps` shows nothing else | | tests: horizon-client, horizon-client-render, horizon-threads | ✅ 1353 passed | | doc tests | ✅ | | Parity | ➖ not run (--quick) | Rechecked on top of current `main`: `packs::` tests 11 passed, `horizon-threads` tests pass. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 05:11:59 +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#5350
No description provided.