[PR #3738] [MERGED] Server resource packs: keep the overlay when the pack is only touched #5181

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

📋 Pull Request Information

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

Base: main ← Head: fix/server-pack-overlay-cache


📝 Commits (1)

  • f383fdf Server resource packs: keep the overlay when the pack is only touched

📊 Changes

1 file changed (+36 additions, -3 deletions)

View changed files

📝 crates/horizon-client-render/src/packs/cache.rs (+36 -3)

📄 Description

🤖 Opened by GIGABAIT93's AI agent (Claude Code, Claude Opus 5.5), not by GIGABAIT93 directly.

What and why

Joining a server with a resource pack waited about a minute on "Preparing resources" on every join, not only the first. Measured on Windows on tensa.co.ua (Velocity, a 1.2 MB Nexo pack), the installed nightly-2026-10-29: "Joining world..." from 16:13:07 to 16:14:07, with the pack already in the download cache ("returning cached file since actual hash matches requested").

The cause, step by step:

  1. server_packs/download.rs finds the pack in downloads/ and touches it, as vanilla's HttpUtil.downloadFile does with updateModificationTime (so the cleaner keeps it longest). The file's modified time becomes the join's (4644168403… showed 16:13:07, the log line's second).
  2. packs/cache.rs keyed a ZIP pack by stamp(), which hashes its modified time, so the marker never matched again.
  3. So every join rebuilt the whole overlay (build_overlay_uncached: ~2,200 hard links and files plus 39 junctions here), and the reload then read thousands of freshly created files. On Windows, Defender scans each one (#1961), which is why it reached a minute; vanilla reads the pack from the ZIP and builds nothing.

The fix: pack_signature knows a ZIP by its bytes (content, now built on every platform, as stamp already did for files off Unix) instead of its stamp. One file read per load; a server pack's name is its SHA-1 anyway. Directory packs keep their stamps.

Measured with a throwaway probe over the real prepared root and this pack, touching it between builds as a join does:

first build next join (pack touched) again
main 7.96 s 8.00 s 8.60 s
this branch (same work) 1.42 s 1.08 s

The first build varies with Defender's cache (8 to 36 s across runs here); the next joins are what this changes. In the game they also skip re-reading thousands of new files.

In the game, with this branch built with temporary timing logs and started by the launcher with a Microsoft account on tensa.co.ua (Windows):

main (nightly-2026-10-29) this branch
first join sat on "Preparing resources" for over 8 minutes without writing a marker; the server let the player in after its timeout overlay built in 25.7 s, dependencies checked in 1.6 s, marker written; the whole stage 34.5 s
next join (the pack touched again) about 60 s every time, the overlay rebuilt cache hit in 2.1 s; the whole stage 8.7 s; in the world 9 s after the pack arrived

Regression test a_zip_touched_but_unchanged_keeps_its_overlay: builds an overlay from a ZIP, moves the ZIP's modified time a minute on with the same bytes, builds again, and checks the output was not rebuilt; it fails on main ("the overlay was rebuilt") and passes here. zip_content_and_failed_build_invalidate still covers a ZIP whose bytes change.

Likely related: #3283's Hypixel report ("stuck on preparing resources" after accepting the pack), and the per-join half of what #3290 describes.

No label (a fix).

Vanilla reference

net.minecraft.util.HttpUtil.downloadFile and updateModificationTime, which download.rs follows and which stay as they are; vanilla has no overlay, it reads FilePackResources from the ZIP.

Self-check

Run on Linux (WSL2). The first run there failed in horizon-client-render's tests: a SIGSEGV of the test binary, which upstream main shows too (1 run in 2 here), and normalized_and_external_overlay_roots_keep_merged_bytes_current, the flaky test #3602 fixes. The block below is the second run.

pr_ready (tools/pr_ready.py --quick --base upstream/main on GIGABAIT, against upstream/main at de8ffbb29, 2 min 22 s)

Check Result
Scope ✅ 1 files, +36 −3
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 416 passed (41 s)
rustfmt ✅ (14 s)
clippy ✅ (1 min 12 s)
tests: horizon-client-render ✅ 521 passed (7 s)
doc tests ✅ 0 passed (8 s)
content root tests ➖ content root untouched
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ not run (--quick): CI's parity job picks the affected harnesses
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

🤖 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/3738 **Author:** [@GIGABAIT93](https://github.com/GIGABAIT93) **Created:** 10/29/2026 **Status:** ✅ Merged **Merged:** 10/29/2026 **Merged by:** [@levzzz5154](https://github.com/levzzz5154) **Base:** `main` ← **Head:** `fix/server-pack-overlay-cache` --- ### 📝 Commits (1) - [`f383fdf`](https://github.com/horizon-rust/horizon/commit/f383fdf74ceab68f4265b41850deee6c1054b5a5) Server resource packs: keep the overlay when the pack is only touched ### 📊 Changes **1 file changed** (+36 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client-render/src/packs/cache.rs` (+36 -3) </details> ### 📄 Description > 🤖 Opened by GIGABAIT93's AI agent (Claude Code, Claude Opus 5.5), not by GIGABAIT93 directly. ## What and why Joining a server with a resource pack waited about a minute on "Preparing resources" on **every** join, not only the first. Measured on Windows on tensa.co.ua (Velocity, a 1.2 MB Nexo pack), the installed nightly-2026-10-29: "Joining world..." from 16:13:07 to 16:14:07, with the pack already in the download cache ("returning cached file since actual hash matches requested"). The cause, step by step: 1. `server_packs/download.rs` finds the pack in `downloads/` and `touch`es it, as vanilla's `HttpUtil.downloadFile` does with `updateModificationTime` (so the cleaner keeps it longest). The file's modified time becomes the join's (`4644168403…` showed 16:13:07, the log line's second). 2. `packs/cache.rs` keyed a ZIP pack by `stamp()`, which hashes its modified time, so the marker never matched again. 3. So every join rebuilt the whole overlay (`build_overlay_uncached`: ~2,200 hard links and files plus 39 junctions here), and the reload then read thousands of freshly created files. On Windows, Defender scans each one (#1961), which is why it reached a minute; vanilla reads the pack from the ZIP and builds nothing. The fix: `pack_signature` knows a ZIP by its bytes (`content`, now built on every platform, as `stamp` already did for files off Unix) instead of its stamp. One file read per load; a server pack's name is its SHA-1 anyway. Directory packs keep their stamps. Measured with a throwaway probe over the real prepared root and this pack, touching it between builds as a join does: | | first build | next join (pack touched) | again | | --- | --- | --- | --- | | main | 7.96 s | 8.00 s | 8.60 s | | this branch | (same work) | 1.42 s | 1.08 s | The first build varies with Defender's cache (8 to 36 s across runs here); the next joins are what this changes. In the game they also skip re-reading thousands of new files. In the game, with this branch built with temporary timing logs and started by the launcher with a Microsoft account on tensa.co.ua (Windows): | | main (nightly-2026-10-29) | this branch | | --- | --- | --- | | first join | sat on "Preparing resources" for over 8 minutes without writing a marker; the server let the player in after its timeout | overlay built in 25.7 s, dependencies checked in 1.6 s, marker written; the whole stage 34.5 s | | next join (the pack touched again) | about 60 s every time, the overlay rebuilt | cache hit in 2.1 s; the whole stage 8.7 s; in the world 9 s after the pack arrived | Regression test `a_zip_touched_but_unchanged_keeps_its_overlay`: builds an overlay from a ZIP, moves the ZIP's modified time a minute on with the same bytes, builds again, and checks the output was not rebuilt; it fails on main ("the overlay was rebuilt") and passes here. `zip_content_and_failed_build_invalidate` still covers a ZIP whose bytes change. Likely related: #3283's Hypixel report ("stuck on preparing resources" after accepting the pack), and the per-join half of what #3290 describes. No label (a fix). ## Vanilla reference `net.minecraft.util.HttpUtil.downloadFile` and `updateModificationTime`, which `download.rs` follows and which stay as they are; vanilla has no overlay, it reads `FilePackResources` from the ZIP. ## Self-check Run on Linux (WSL2). The first run there failed in `horizon-client-render`'s tests: a SIGSEGV of the test binary, which upstream main shows too (1 run in 2 here), and `normalized_and_external_overlay_roots_keep_merged_bytes_current`, the flaky test #3602 fixes. The block below is the second run. **pr_ready** (`tools/pr_ready.py --quick --base upstream/main` on GIGABAIT, against upstream/main at de8ffbb29, 2 min 22 s) | Check | Result | | --- | --- | | Scope | ✅ 1 files, +36 −3 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 416 passed (41 s) | | rustfmt | ✅ (14 s) | | clippy | ✅ (1 min 12 s) | | tests: horizon-client-render | ✅ 521 passed (7 s) | | doc tests | ✅ 0 passed (8 s) | | content root tests | ➖ content root untouched | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ not run (--quick): CI's parity job picks the affected harnesses | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | 🤖 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:10:47 +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#5181
No description provided.