[PR #1042] [MERGED] Prepare startup handoff CPU resources off the UI thread #3009

Closed
opened 2026-11-02 16:00:47 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/1042
Author: @rdbtCVS
Created: 10/19/2026
Status: ✅ Merged
Merged: 10/21/2026
Merged by: @ludovic111

Base: main ← Head: t3/optimize-startup-handoff


📝 Commits (1)

  • 4ffb073 Prepare startup handoff CPU resources on the loader worker

📊 Changes

4 files changed (+281 additions, -44 deletions)

View changed files

📝 crates/horizon-client/src/game.rs (+162 -28)
📝 crates/horizon-client/src/game/integrated.rs (+1 -1)
📝 crates/horizon-client/src/gfx.rs (+96 -15)
📝 docs/performance/startup-stage-3.md (+22 -0)

📄 Description

What and why

Startup's core-to-game handoff generates texture mipmaps and loads/bakes game models on the UI thread, contributing to the reported 245 ms pause (103 ms renderer, 118 ms start_game). Prepare the block/border mip chains, entity and item-frame models, painting variants, and creative inventory on the resource worker, then consume those results during handoff. Share one entity-model document across all startup model lookups.

Use the live menu settings and title during handoff to avoid rereading preferences and constructing a temporary title. Keep prepared data owned by its loader generation, complete fallible preparation before spawning the rest worker, and release temporary mip buffers after upload. GPU pipeline creation, texture uploads, surface operations, and audio initialization remain on the main thread. Add separate worker and handoff timing logs.

Vanilla reference

Horizon-only startup scheduling and menu handoff. Existing model baking, mip generation, gameplay, and synchronous harness behavior are preserved.

Validation

  • Progressive startup smoke using prepared resources: resized the loading window, rendered 123 game frames, closed via WM_DELETE_WINDOW, exited 0 with no reported error.
  • Synchronous --offscreen --frames 3 smoke: exited 0, exactly 3 frames, no reported error.
  • New regressions cover mip upload bytes across array boundaries and per-layer settings, and owned game resources prepared on a worker and used after source files are removed.
  • The progressive debug smoke logged 647 ms of CPU preparation on the worker, 7 ms in start_game, 298 ms building the renderer, and 345 ms total handoff. These unoptimized-build diagnostics are not comparable to the original 245 ms measurement; a matched optimized-build benchmark is still needed to quantify the overall improvement.
  • Vanilla parity harnesses were not run (--quick); this change moves resource preparation and does not change gameplay rules.

Self-check

pr_ready (tools/pr_ready.py --quick on archlinux, against origin/main at defaa7cd2, 22 s)

Check Result
Scope ✅ 4 files, +281 −44
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ➖ no Python change
rustfmt ✅ (5 s)
clippy ✅ (9 s)
tests: horizon-client ✅ 1032 passed (7 s)
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)

🔄 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/1042 **Author:** [@rdbtCVS](https://github.com/rdbtCVS) **Created:** 10/19/2026 **Status:** ✅ Merged **Merged:** 10/21/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `t3/optimize-startup-handoff` --- ### 📝 Commits (1) - [`4ffb073`](https://github.com/horizon-rust/horizon/commit/4ffb073b59f5cef20426efcea088c5d0f57e6b90) Prepare startup handoff CPU resources on the loader worker ### 📊 Changes **4 files changed** (+281 additions, -44 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game.rs` (+162 -28) 📝 `crates/horizon-client/src/game/integrated.rs` (+1 -1) 📝 `crates/horizon-client/src/gfx.rs` (+96 -15) 📝 `docs/performance/startup-stage-3.md` (+22 -0) </details> ### 📄 Description ## What and why Startup's core-to-game handoff generates texture mipmaps and loads/bakes game models on the UI thread, contributing to the reported 245 ms pause (103 ms renderer, 118 ms `start_game`). Prepare the block/border mip chains, entity and item-frame models, painting variants, and creative inventory on the resource worker, then consume those results during handoff. Share one entity-model document across all startup model lookups. Use the live menu settings and title during handoff to avoid rereading preferences and constructing a temporary title. Keep prepared data owned by its loader generation, complete fallible preparation before spawning the rest worker, and release temporary mip buffers after upload. GPU pipeline creation, texture uploads, surface operations, and audio initialization remain on the main thread. Add separate worker and handoff timing logs. ## Vanilla reference Horizon-only startup scheduling and menu handoff. Existing model baking, mip generation, gameplay, and synchronous harness behavior are preserved. ## Validation - Progressive startup smoke using prepared resources: resized the loading window, rendered 123 game frames, closed via `WM_DELETE_WINDOW`, exited 0 with no reported error. - Synchronous `--offscreen --frames 3` smoke: exited 0, exactly 3 frames, no reported error. - New regressions cover mip upload bytes across array boundaries and per-layer settings, and owned game resources prepared on a worker and used after source files are removed. - The progressive debug smoke logged 647 ms of CPU preparation on the worker, 7 ms in `start_game`, 298 ms building the renderer, and 345 ms total handoff. These unoptimized-build diagnostics are not comparable to the original 245 ms measurement; a matched optimized-build benchmark is still needed to quantify the overall improvement. - Vanilla parity harnesses were not run (`--quick`); this change moves resource preparation and does not change gameplay rules. ## Self-check **pr_ready** (`tools/pr_ready.py --quick` on archlinux, against origin/main at defaa7cd2, 22 s) | Check | Result | | --- | --- | | Scope | ✅ 4 files, +281 −44 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ➖ no Python change | | rustfmt | ✅ (5 s) | | clippy | ✅ (9 s) | | tests: horizon-client | ✅ 1032 passed (7 s) | | 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) | --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 16:00: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#3009
No description provided.