[PR #6420] [MERGED] Meshing workers share the face visibility table instead of copying it (−49 MB RSS) #6860

Closed
opened 2026-11-03 06:28:16 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/6420
Author: @rdbtCVS
Created: 11/1/2026
Status: ✅ Merged
Merged: 11/1/2026
Merged by: @ludovic111

Base: main ← Head: mem-shared-face-visibility


📝 Commits (1)

  • 1b56d2d Meshing workers share the face visibility's states and faces

📊 Changes

1 file changed (+9 additions, -6 deletions)

View changed files

📝 crates/horizon-world/src/block_render.rs (+9 -6)

📄 Description

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

Part of #6418.

What

Each streaming worker keeps its own FaceVisibility across mesh jobs (streaming.rs: "the face visibility table and its occlusion cache stay with the worker"), cloned from the one in MeshTables. The clone copied the whole table: states (one State per block state, ~30,000) and faces (the deduplicated occlusion faces, each a VoxelShape of Arcs and bounds), though neither changes once made; only the pair cache is the worker's own. With one worker per core, a sampling heap profile of a loaded world had 40 MiB live in Vec<VoxelShape>::clone on the workers.

states and faces are now Arc<[_]>: a clone shares them and keeps its own cache. Lookups index the same slices, so meshing is unchanged.

Measured

How it was measured. Arch Linux (zen kernel), Ryzen 5 5600X (12 threads), 32 GB, RTX 4060 8 GB (Vulkan, NVIDIA 615.78), --profile fast, --offscreen 1280x720, fresh scratch homes per start, render distance 12. A start goes to the title screen, creates the perf_bench world (seed 1234, creative), waits for spawn to load, then teleports to and flies tools/perf_bench.py's village and forest paths (12 s each) and samples after each. Video memory: what nvidia-smi attributes to the process, and the game's own allocator totals (status: gpu_allocated_bytes / gpu_reserved_bytes); RSS from /proc/<pid>/status. Three alternated starts per build, medians (range in brackets); main = dea6dea98.

main this PR
RSS after the flights 1,476 [1,474-1,506] MB 1,427 [1,427-1,430] MB (−49)
anonymous RSS 1,169 [1,166-1,198] MB 1,120 [1,120-1,122] MB (−49)
peak RSS 1,511 MB 1,441 MB
average FPS over the flights 1,832 1,892

The saving grows with the cores (one clone per worker) and with content mods' extra states.

Tests

block_render tests and the meshing tests pass unchanged (the table answers the same; only who owns it changed).

pr_ready (tools/pr_ready.py --quick on archlinux, against origin/main at 80dfb5f35, 3 min 11 s)

Check Result
Scope ✅ 2 files, +9 −6
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 594 passed (33 s)
rustfmt ✅ (7 s)
clippy ✅ (1 min 5 s)
tests: horizon-world ✅ 371 passed (1 min 20 s)
doc tests ✅ 0 passed (1 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 ➖ 375 affected, to run in CI (--quick): active_effect_tick, active_effects, ambient_sound, anchor, armor_stand_frost, arrow, arrow_wind_charge, attribute_health, attribute_map_queries, attribute, attribute_updates, audio_attributes and 363 more
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/6420 **Author:** [@rdbtCVS](https://github.com/rdbtCVS) **Created:** 11/1/2026 **Status:** ✅ Merged **Merged:** 11/1/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `mem-shared-face-visibility` --- ### 📝 Commits (1) - [`1b56d2d`](https://github.com/horizon-rust/horizon/commit/1b56d2d4310810d9d771ba2007bb57a254b5f258) Meshing workers share the face visibility's states and faces ### 📊 Changes **1 file changed** (+9 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-world/src/block_render.rs` (+9 -6) </details> ### 📄 Description > 🤖 Opened by rdbtCVS's AI agent (Claude Code, Claude Opus 5.5), not by rdbtCVS personally. Part of #6418. ## What Each streaming worker keeps its own `FaceVisibility` across mesh jobs (`streaming.rs`: "the face visibility table and its occlusion cache stay with the worker"), cloned from the one in `MeshTables`. The clone copied the whole table: `states` (one `State` per block state, ~30,000) and `faces` (the deduplicated occlusion faces, each a `VoxelShape` of Arcs and bounds), though neither changes once made; only the pair cache is the worker's own. With one worker per core, a sampling heap profile of a loaded world had 40 MiB live in `Vec<VoxelShape>::clone` on the workers. `states` and `faces` are now `Arc<[_]>`: a clone shares them and keeps its own cache. Lookups index the same slices, so meshing is unchanged. ## Measured **How it was measured.** Arch Linux (zen kernel), Ryzen 5 5600X (12 threads), 32 GB, RTX 4060 8 GB (Vulkan, NVIDIA 615.78), `--profile fast`, `--offscreen` 1280x720, fresh scratch homes per start, render distance 12. A start goes to the title screen, creates the perf_bench world (seed 1234, creative), waits for spawn to load, then teleports to and flies `tools/perf_bench.py`'s village and forest paths (12 s each) and samples after each. Video memory: what `nvidia-smi` attributes to the process, and the game's own allocator totals (`status`: `gpu_allocated_bytes` / `gpu_reserved_bytes`); RSS from `/proc/<pid>/status`. Three alternated starts per build, medians (range in brackets); `main` = dea6dea98. | | main | this PR | |---|---|---| | RSS after the flights | 1,476 [1,474-1,506] MB | **1,427 [1,427-1,430] MB** (−49) | | anonymous RSS | 1,169 [1,166-1,198] MB | **1,120 [1,120-1,122] MB** (−49) | | peak RSS | 1,511 MB | 1,441 MB | | average FPS over the flights | 1,832 | 1,892 | The saving grows with the cores (one clone per worker) and with content mods' extra states. ## Tests `block_render` tests and the meshing tests pass unchanged (the table answers the same; only who owns it changed). **pr_ready** (`tools/pr_ready.py --quick` on archlinux, against origin/main at 80dfb5f35, 3 min 11 s) | Check | Result | | --- | --- | | Scope | ✅ 2 files, +9 −6 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 594 passed (33 s) | | rustfmt | ✅ (7 s) | | clippy | ✅ (1 min 5 s) | | tests: horizon-world | ✅ 371 passed (1 min 20 s) | | doc tests | ✅ 0 passed (1 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 | ➖ 375 affected, to run in CI (--quick): active_effect_tick, active_effects, ambient_sound, anchor, armor_stand_frost, arrow, arrow_wind_charge, attribute_health, attribute_map_queries, attribute, attribute_updates, audio_attributes and 363 more | | 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 06:28:16 +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#6860
No description provided.