[PR #599] [CLOSED] Defer block-entity renderer resources until world entry #2665

Closed
opened 2026-11-02 15:58:03 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/599
Author: @rdbtCVS
Created: 10/16/2026
Status: ❌ Closed

Base: main ← Head: perf/defer-block-entity-render-20261017


📝 Commits (4)

  • 2820e27 Defer block entity renderer loading until gameplay rendering
  • cd569b1 Initialize block entity renderers at world entry and on pack reload
  • d77331d Preserve registry generation and measure deferred world-entry cost
  • 82a59c8 Benchmark menu and playable-frame latency with software Vulkan

📊 Changes

9 files changed (+632 additions, -23 deletions)

View changed files

➕ benchmarks/block-entity-renderer-startup-2026-10-17.md (+185 -0)
➕ crates/horizon-client/examples/block_entity_load_profile.rs (+19 -0)
📝 crates/horizon-client/src/game.rs (+111 -18)
📝 crates/horizon-client/src/game/integrated.rs (+2 -0)
📝 crates/horizon-client/src/game/minecarts.rs (+3 -3)
📝 crates/horizon-client/src/game/packs.rs (+21 -1)
📝 crates/horizon-client/src/game/remote.rs (+5 -1)
➕ tools/profile_client_startup.py (+140 -0)
➕ tools/test_block_entity_renderer_lifecycle.py (+146 -0)

📄 Description

Problem and resulting behavior

BlockEntityRenderer::load previously ran while constructing shared startup resources and delayed entry to the title screen. The renderer is now per Game, absent from title-menu and dedicated-server initialization, and prepared at world entry before the first relevant gameplay render. The same initialized renderer serves block entities and minecart contents.

The active resource-pack/mod overlay and block registry are used to load it. F3+T prepares the replacement renderer before committing reloaded resources; preparation errors preserve the old generation and can be recovered by restoring the resource and reloading. The active registry-mod selection is captured at startup so pending content-mod toggles cannot silently change registrations in an existing world. Registry changes still require a restart. World-entry telemetry now includes deferred renderer preparation for local, integrated and remote worlds, including correct integrated/local timer handoff.

Validation performed

  • cargo fmt --all -- --check, cargo check --offline -p horizon-client --bin horizon-client, git diff --check, Python syntax checks: pass on final code.
  • Focused renderer lifecycle tests: 2/2 pass, including multi-thread once-only initialization and successful/error cache generation replacement.
  • Renderer unit tests: 3/3 pass. Content-mod tests: 6/6 pass.
  • Minecraft vanilla chest rendering parity: 100/100 cases match.
  • Earlier offscreen world-entry smoke: success, six frames, 90 chunks, no error.
  • Automated world/F3+T reload: pass; world remains live; initial renderer 1011.7 ms and replacement 1326.4 ms in contended debug conditions.
  • Deliberately malformed entity-models.json in an isolated linked resource root: failed F3+T reload was rejected with current world still live; restoring file and retrying succeeded (debug 1090.5 ms initial / 953.5 ms replacement).
  • Dedicated-server smoke reached Done with no client block-entity renderer initialization; stopped after 100-second timeout as intended.

Performance: original vs optimized

Baseline checkout: 64a4c72e, parent of original 392ec447. Current PR head: d77331d8.

Controlled release loader, 15 order-alternating repetitions against identical Minecraft 26.3 resources:

Original Optimized
Isolated BlockEntityRenderer::load median 130.848 ms 130.590 ms
Range 125.037–157.920 ms 118.979–158.502 ms

Both release profiling executables had the same SHA-256. The paired median difference was -0.557 ms, range -27.330 to +22.451 ms. This validates approximately 131 ms of resource loading is removed from the menu path; it does not demonstrate a loader speedup or a measured reduction in menu wall time.

An earlier debug-client menu A/B (five alternating pairs) measured 23.68 s median original and 33.92 s optimized, with 21–64 s individual runs and a median paired difference of +1.46 s. Heavy host contention and huge variation make this inconclusive. Its process-to-exit timings include offscreen first-frame submission and shutdown, not confirmed GPU presentation.

An improved profiler now uses fresh isolated game directories on each run, captures first-frame markers and GPU adapter information separately, and supports original/optimized release-loader pairings. Attempts to obtain corresponding release-client menu data failed twice: original client initialized RTX 4060 Vulkan then exited with Horizon: Parent device is lost. A subsequent original debug world smoke reproduced the same Vulkan failure. A final optimized control-socket world smoke also returned {"error":"game exited"} after GPU initialization. These checks are recorded as environment-blocked, not passed.

Full samples, methodology, reproduction commands and limitations: Block-entity startup benchmark report.

Trade-offs / remaining validation

The renderer work shifts from startup to world entry (rather than stalling the first gameplay draw). In the controlled release loader harness that work is about 131 ms; contended debug world-entry loads have measured around 0.7–1.1 s. F3+T also waits for replacement resources. A stable graphical runner is still required for reproducible release-client A/B first-menu and first-playable-world timing, plus additional real resource-pack/mod permutations. The independent lifecycle review has not yet fully reported.

Keep draft: compilation, parity, startup-defer correctness, recovery and prior gameplay checks pass, but the GPU environment prevents completion of the requested end-to-end release comparison; no unsupported menu speedup is claimed.


🔄 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/599 **Author:** [@rdbtCVS](https://github.com/rdbtCVS) **Created:** 10/16/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `perf/defer-block-entity-render-20261017` --- ### 📝 Commits (4) - [`2820e27`](https://github.com/horizon-rust/horizon/commit/2820e274b2afb1d606757b5aa012b360180f43df) Defer block entity renderer loading until gameplay rendering - [`cd569b1`](https://github.com/horizon-rust/horizon/commit/cd569b16b347aa9ef355e0067db56ea467d8abc9) Initialize block entity renderers at world entry and on pack reload - [`d77331d`](https://github.com/horizon-rust/horizon/commit/d77331d86be9444f26777f6e102a9d390cabc23f) Preserve registry generation and measure deferred world-entry cost - [`82a59c8`](https://github.com/horizon-rust/horizon/commit/82a59c8adffd417e65fac2b858436b36f097f92d) Benchmark menu and playable-frame latency with software Vulkan ### 📊 Changes **9 files changed** (+632 additions, -23 deletions) <details> <summary>View changed files</summary> ➕ `benchmarks/block-entity-renderer-startup-2026-10-17.md` (+185 -0) ➕ `crates/horizon-client/examples/block_entity_load_profile.rs` (+19 -0) 📝 `crates/horizon-client/src/game.rs` (+111 -18) 📝 `crates/horizon-client/src/game/integrated.rs` (+2 -0) 📝 `crates/horizon-client/src/game/minecarts.rs` (+3 -3) 📝 `crates/horizon-client/src/game/packs.rs` (+21 -1) 📝 `crates/horizon-client/src/game/remote.rs` (+5 -1) ➕ `tools/profile_client_startup.py` (+140 -0) ➕ `tools/test_block_entity_renderer_lifecycle.py` (+146 -0) </details> ### 📄 Description ## Problem and resulting behavior `BlockEntityRenderer::load` previously ran while constructing shared startup resources and delayed entry to the title screen. The renderer is now **per Game**, absent from title-menu and dedicated-server initialization, and prepared **at world entry before the first relevant gameplay render**. The same initialized renderer serves block entities and minecart contents. The active resource-pack/mod overlay and block registry are used to load it. F3+T prepares the replacement renderer before committing reloaded resources; preparation errors preserve the old generation and can be recovered by restoring the resource and reloading. The active registry-mod selection is captured at startup so pending content-mod toggles cannot silently change registrations in an existing world. Registry changes still require a restart. World-entry telemetry now includes deferred renderer preparation for local, integrated and remote worlds, including correct integrated/local timer handoff. ## Validation performed - `cargo fmt --all -- --check`, `cargo check --offline -p horizon-client --bin horizon-client`, `git diff --check`, Python syntax checks: **pass** on final code. - Focused renderer lifecycle tests: **2/2 pass**, including multi-thread once-only initialization and successful/error cache generation replacement. - Renderer unit tests: **3/3 pass**. Content-mod tests: **6/6 pass**. - Minecraft vanilla chest rendering parity: **100/100 cases match**. - Earlier offscreen world-entry smoke: **success**, six frames, 90 chunks, no error. - Automated world/F3+T reload: **pass**; world remains live; initial renderer 1011.7 ms and replacement 1326.4 ms in contended debug conditions. - Deliberately malformed `entity-models.json` in an isolated linked resource root: failed F3+T reload was rejected with current world still live; restoring file and retrying succeeded (debug 1090.5 ms initial / 953.5 ms replacement). - Dedicated-server smoke reached `Done` with no client block-entity renderer initialization; stopped after 100-second timeout as intended. ## Performance: original vs optimized Baseline checkout: `64a4c72e`, parent of original `392ec447`. Current PR head: `d77331d8`. **Controlled release loader**, 15 order-alternating repetitions against identical Minecraft 26.3 resources: | | Original | Optimized | | --- | ---: | ---: | | Isolated `BlockEntityRenderer::load` median | 130.848 ms | 130.590 ms | | Range | 125.037–157.920 ms | 118.979–158.502 ms | Both release profiling executables had the **same SHA-256**. The paired median difference was -0.557 ms, range -27.330 to +22.451 ms. This validates approximately **131 ms of resource loading is removed from the menu path**; it does **not** demonstrate a loader speedup or a measured reduction in menu wall time. An earlier debug-client menu A/B (five alternating pairs) measured 23.68 s median original and 33.92 s optimized, with 21–64 s individual runs and a median paired difference of +1.46 s. Heavy host contention and huge variation make this **inconclusive**. Its process-to-exit timings include offscreen first-frame submission and shutdown, not confirmed GPU presentation. An improved profiler now uses fresh isolated game directories on each run, captures first-frame markers and GPU adapter information separately, and supports original/optimized release-loader pairings. Attempts to obtain corresponding release-client menu data failed **twice**: original client initialized RTX 4060 Vulkan then exited with `Horizon: Parent device is lost`. A subsequent original debug world smoke reproduced the same Vulkan failure. A final optimized control-socket world smoke also returned `{"error":"game exited"}` after GPU initialization. These checks are recorded as **environment-blocked**, not passed. Full samples, methodology, reproduction commands and limitations: [Block-entity startup benchmark report](https://github.com/ludovic111/horizon/blob/perf/defer-block-entity-render-20261017/benchmarks/block-entity-renderer-startup-2026-10-17.md). ## Trade-offs / remaining validation The renderer work shifts from startup to world entry (rather than stalling the first gameplay draw). In the controlled release loader harness that work is about 131 ms; contended debug world-entry loads have measured around 0.7–1.1 s. F3+T also waits for replacement resources. A stable graphical runner is still required for reproducible release-client A/B first-menu and first-playable-world timing, plus additional real resource-pack/mod permutations. The independent lifecycle review has not yet fully reported. **Keep draft:** compilation, parity, startup-defer correctness, recovery and prior gameplay checks pass, but the GPU environment prevents completion of the requested end-to-end release comparison; no unsupported menu speedup is claimed. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 15:58:03 +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#2665
No description provided.