[PR #3286] [CLOSED] Windows: hardlink the overlay's mirrored files instead of copying them #4890

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

📋 Pull Request Information

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

Base: main ← Head: fix/windows-overlay-hardlink


📝 Commits (1)

  • 0e266fd Windows: link the overlay's mirrored files instead of copying them

📊 Changes

1 file changed (+5 additions, -1 deletions)

View changed files

📝 crates/horizon-client/src/packs.rs (+5 -1)

📄 Description

🤖 Opened by Alexander's AI agent (Hermes), not by Alexander himself.

packs::build_overlay mirrors the prepared root into
.horizon-cache/resourcepacks/<hash>/. On Windows it recurses into every
untouched vanilla directory (#1688) and link copied each file there, so
turning a pack on wrote the whole prepared root out again. Unix symlinks those
files, and the overlay only reads them, so a hardlink gives the same view.

Measured on Windows 11, NTFS, the same prepared root
(versions/v0.2.93/.local/horizon-client/26.3: 28 181 files, 639 MB) and the
same pack (§6§lVanilla Experience+§0.zip), by calling build_overlay on it
with a cold cache directory:

cold build cache hit
fs::copy (main) 34.36 s 4.55 s
fs::hard_link (this branch) 20.78 s 4.52 s

Selecting the pack also costs 639 MB less on disk per selection now; two
selections used to keep two copies of the root.

fs::hard_link falls back to the copy when the volume differs or the
filesystem has no hardlinks, so nothing loses the mirror.

Refs #3234 rather than Fixes, because this is part of that report and not the
whole of it. What still costs a cold launch with a pack on, from the same
measurement:

  • the mirror still creates 28 181 files, one at a time, about 8 s here (a
    hardlink pass over the same tree took 8.1 s in a separate run);
  • the cache marker then validates those files by reading their content
    (cache::stamp hashes a file's bytes on not(unix)), which is most of the
    4.5 s a cache hit still takes, and ~11 s of the cold build.

Removing either needs junctions for the untouched directories, or trusting
size and mtime on Windows, which is a change of its own and not in this PR.

Tests: cargo test -p horizon-client --lib packs:: → 21 passed, 1 ignored on
this branch. No new test: the site is a #[cfg(not(unix))] shim that CI
(Linux and macOS) never compiles, so the numbers above are the evidence. The
pr_ready block follows as a comment.


🔄 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/3286 **Author:** [@Domanffe](https://github.com/Domanffe) **Created:** 10/28/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/windows-overlay-hardlink` --- ### 📝 Commits (1) - [`0e266fd`](https://github.com/horizon-rust/horizon/commit/0e266fd80767541069a82d4acc6fe2f43e43e55e) Windows: link the overlay's mirrored files instead of copying them ### 📊 Changes **1 file changed** (+5 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/packs.rs` (+5 -1) </details> ### 📄 Description > 🤖 Opened by Alexander's AI agent (Hermes), not by Alexander himself. `packs::build_overlay` mirrors the prepared root into `.horizon-cache/resourcepacks/<hash>/`. On Windows it recurses into every untouched vanilla directory (#1688) and `link` copied each file there, so turning a pack on wrote the whole prepared root out again. Unix symlinks those files, and the overlay only reads them, so a hardlink gives the same view. Measured on Windows 11, NTFS, the same prepared root (`versions/v0.2.93/.local/horizon-client/26.3`: 28 181 files, 639 MB) and the same pack (`§6§lVanilla Experience+§0.zip`), by calling `build_overlay` on it with a cold cache directory: | | cold build | cache hit | | --- | --- | --- | | `fs::copy` (`main`) | 34.36 s | 4.55 s | | `fs::hard_link` (this branch) | **20.78 s** | 4.52 s | Selecting the pack also costs 639 MB less on disk per selection now; two selections used to keep two copies of the root. `fs::hard_link` falls back to the copy when the volume differs or the filesystem has no hardlinks, so nothing loses the mirror. Refs #3234 rather than `Fixes`, because this is part of that report and not the whole of it. What still costs a cold launch with a pack on, from the same measurement: - the mirror still creates 28 181 files, one at a time, about 8 s here (a hardlink pass over the same tree took 8.1 s in a separate run); - the cache marker then validates those files by reading their content (`cache::stamp` hashes a file's bytes on `not(unix)`), which is most of the 4.5 s a cache hit still takes, and ~11 s of the cold build. Removing either needs junctions for the untouched directories, or trusting size and mtime on Windows, which is a change of its own and not in this PR. Tests: `cargo test -p horizon-client --lib packs::` → 21 passed, 1 ignored on this branch. No new test: the site is a `#[cfg(not(unix))]` shim that CI (Linux and macOS) never compiles, so the numbers above are the evidence. The `pr_ready` block follows as a comment. --- <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:41 +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#4890
No description provided.