[PR #4078] [MERGED] Block entity rendering: reuse the meshes' face visibility instead of loading it again #5407

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/4078
Author: @ludovic111
Created: 10/29/2026
Status: ✅ Merged
Merged: 10/30/2026
Merged by: @ludovic111

Base: main ← Head: perf/shared-face-visibility


📝 Commits (1)

  • 23c5335 Block entity rendering: reuse the meshes' face visibility instead of loading it again

📊 Changes

2 files changed (+23 additions, -5 deletions)

View changed files

📝 crates/horizon-client-render/src/block_entity_render.rs (+11 -1)
📝 crates/horizon-client/src/game.rs (+12 -4)

📄 Description

🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself.

What and why

Third PR of the server plan (#3989, docs/server-next.md §7). Independent of #4009 and #4027.

Loading built the block face visibility twice: once for the mesh tables (PackResources::load) and once more in
BlockEntityRenderer::load. That meant reading occlusion.nbt and render-definitions.json again, and making
a second set of shapes whose faces were computed again on first use. On the dedicated server's live heap that
was 13.6 MB of face shapes for each copy, plus the second table.

The block entity renderer now takes a clone of the mesh tables' FaceVisibility. A VoxelShape clone shares its
identity, and so its cached faces. The renderer keeps its own occlusion cache behind its Mutex, as before. The
tables are game data, which resource packs don't change. Probes and tests that load the renderer on its own
still call BlockEntityRenderer::load, which loads its own copy. Clients save the same memory.

Measured

sn_idle.py: fresh scratch dedicated server, seed 12345, nobody on. Ready = first status ping answered from exec;
RSS read 10 s after ready. Mac mini M4 Pro, load 43–61 (busy); main c3071c7b6 against this branch, 4 interleaved
pairs.

1 2 3 4 median
RSS idle, main 861 MB 855 MB 850 MB 842 MB 852 MB
RSS idle, this PR 828 MB 836 MB 816 MB 818 MB 823 MB (−30)
Ready, main 5.64 s 8.17 s 7.83 s 4.96 s 6.73 s
Ready, this PR 4.51 s 6.91 s 5.17 s 4.63 s 4.90 s

Each pair started faster, but the machine was busy, so the ready times are only indicative.

Self-check

pr_ready (tools/pr_ready.py --quick on ludovics-mac-mini, against origin/main at c3071c7b6, 16 min 12 s)

Check Result
Scope ✅ 2 files, +23 −5
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 475 passed (2 min 4 s)
rustfmt ✅ (14 s)
clippy ✅ (5 min 1 s)
tests: horizon-client, horizon-client-render ✅ 1450 passed (8 min 6 s)
doc tests ✅ 0 passed (4 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 ➖ 108 affected, to run in CI (--quick): ambient_sound, arrow, audio_attributes, auto_jump, block_entity_anim, block_entity_render, block_entity_tickers, block_particles, block_removal, block_tint, block_transformer, breaking_model and 96 more
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

Parity: run-parity label for CI (block_entity_render, block_entity_anim and the others listed).

🤖 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/4078 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/29/2026 **Status:** ✅ Merged **Merged:** 10/30/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `perf/shared-face-visibility` --- ### 📝 Commits (1) - [`23c5335`](https://github.com/horizon-rust/horizon/commit/23c53359109be3d88cdc4543ca75cd95e86e507f) Block entity rendering: reuse the meshes' face visibility instead of loading it again ### 📊 Changes **2 files changed** (+23 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client-render/src/block_entity_render.rs` (+11 -1) 📝 `crates/horizon-client/src/game.rs` (+12 -4) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. ## What and why Third PR of the server plan (#3989, `docs/server-next.md` §7). Independent of #4009 and #4027. Loading built the block face visibility twice: once for the mesh tables (`PackResources::load`) and once more in `BlockEntityRenderer::load`. That meant reading `occlusion.nbt` and `render-definitions.json` again, and making a second set of shapes whose faces were computed again on first use. On the dedicated server's live heap that was 13.6 MB of face shapes for each copy, plus the second table. The block entity renderer now takes a clone of the mesh tables' `FaceVisibility`. A `VoxelShape` clone shares its identity, and so its cached faces. The renderer keeps its own occlusion cache behind its `Mutex`, as before. The tables are game data, which resource packs don't change. Probes and tests that load the renderer on its own still call `BlockEntityRenderer::load`, which loads its own copy. Clients save the same memory. ## Measured `sn_idle.py`: fresh scratch dedicated server, seed 12345, nobody on. Ready = first status ping answered from exec; RSS read 10 s after ready. Mac mini M4 Pro, load 43–61 (busy); main c3071c7b6 against this branch, 4 interleaved pairs. | | 1 | 2 | 3 | 4 | median | |---|---|---|---|---|---| | RSS idle, main | 861 MB | 855 MB | 850 MB | 842 MB | 852 MB | | RSS idle, this PR | 828 MB | 836 MB | 816 MB | 818 MB | **823 MB (−30)** | | Ready, main | 5.64 s | 8.17 s | 7.83 s | 4.96 s | 6.73 s | | Ready, this PR | 4.51 s | 6.91 s | 5.17 s | 4.63 s | **4.90 s** | Each pair started faster, but the machine was busy, so the ready times are only indicative. ## Self-check **pr_ready** (`tools/pr_ready.py --quick` on ludovics-mac-mini, against origin/main at c3071c7b6, 16 min 12 s) | Check | Result | | --- | --- | | Scope | ✅ 2 files, +23 −5 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 475 passed (2 min 4 s) | | rustfmt | ✅ (14 s) | | clippy | ✅ (5 min 1 s) | | tests: horizon-client, horizon-client-render | ✅ 1450 passed (8 min 6 s) | | doc tests | ✅ 0 passed (4 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 | ➖ 108 affected, to run in CI (--quick): ambient_sound, arrow, audio_attributes, auto_jump, block_entity_anim, block_entity_render, block_entity_tickers, block_particles, block_removal, block_tint, block_transformer, breaking_model and 96 more | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | Parity: `run-parity` label for CI (`block_entity_render`, `block_entity_anim` and the others listed). 🤖 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:12:23 +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#5407
No description provided.