[PR #233] [MERGED] perf: return only lighting from chunk light workers #2421

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/233
Author: @rdbtCVS
Created: 10/14/2026
Status: ✅ Merged
Merged: 10/15/2026
Merged by: @ludovic111

Base: main ← Head: perf/lighting-worker-results-20261014


📝 Commits (1)

  • cb28f69 perf: return only lighting from chunk light workers

📊 Changes

8 files changed (+299 additions, -43 deletions)

View changed files

📝 crates/horizon-client/examples/chunk_bench.rs (+2 -2)
📝 crates/horizon-client/examples/light_parity.rs (+5 -5)
📝 crates/horizon-client/examples/mob_ai_probe.rs (+2 -2)
📝 crates/horizon-client/examples/save_parity.rs (+2 -2)
📝 crates/horizon-client/src/chunk.rs (+10 -4)
📝 crates/horizon-client/src/light.rs (+219 -21)
📝 crates/horizon-client/src/streaming.rs (+3 -7)
➕ docs/performance/lighting-worker-results.md (+56 -0)

📄 Description

Light workers copied whole snapshot sections to return light, and streaming then copied current sections and the returned light again. Workers now return Vec<Light> and application moves each light into the current section through Arc::make_mut. Current block/biome edits survive, while snapshots held by other workers remain immutable. The existing stale-sequence rejection, missing-current-chunk handling, and forced edit replay stay in the same order. All direct examples use the new result API.

The committed ignored benchmark compares production packaging/application with original main's former loops on identical precomputed propagation arrays. It verifies every light, block and biome before timing. Synthetic fixture: 24 sections, 16 block states, four biomes, previously full light storage. Ten measured batches of 500 columns after warm-up, alternating order, median, black_box; AMD Ryzen 5 5600X, Linux x86_64, rustc 1.99.0, fast optimized profile, no LTO, CARGO_INCREMENTAL=0.

Packaging + application Before After Speedup
Uniquely owned sections 63.948 us/column 44.397 us/column 1.44x
Retained snapshot 65.332 us/column 53.025 us/column 1.23x

The old worker copied 149,760 bytes of section heap payload and allocated 24 section Arcs. Those copies/Arcs disappear. Application also avoids cloning 98,304 returned light bytes; uniquely owned sections avoid another whole-section payload copy and 24 Arcs. Shared current sections still incur copy-on-write, as required. Payload/Arc accounting is structural, not global allocator instrumentation. New result/light storage still allocates. Timings exclude propagation, outer chunk copy-on-write, channels, edit replay and remeshing; no full lighting runtime/FPS claim. Reproduction and scope are in docs/performance/lighting-worker-results.md.

Validation:

  • cargo test -p horizon-client --lib --profile fast light::tests -- --nocapture: 5 passed; benchmark ignored.
  • Ignored benchmark: passed exact light/block/biome equivalence and timing.
  • Compiled library test binary streaming::tests: 1 passed.
  • cargo clippy -p horizon-client --lib --tests --examples --profile fast -- -D warnings: passed, including all updated examples.
  • cargo fmt --all -- --check and git diff --check: passed.
  • Tests cover moved buffer identity, retained snapshots, block/biome edits, forced replay equivalence, empty chunk/missing neighbours/no-sky, attenuation, occlusion and incremental/full equivalence. No saved-world/Java parity run; fixtures are synthetic.

Every Cargo invocation used CARGO_INCREMENTAL=0 and the existing shared target cache. Based directly on original main; no other optimization branches included.


🔄 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/233 **Author:** [@rdbtCVS](https://github.com/rdbtCVS) **Created:** 10/14/2026 **Status:** ✅ Merged **Merged:** 10/15/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `perf/lighting-worker-results-20261014` --- ### 📝 Commits (1) - [`cb28f69`](https://github.com/horizon-rust/horizon/commit/cb28f691ffedefcf4a125de7dd53c21a1691ec5a) perf: return only lighting from chunk light workers ### 📊 Changes **8 files changed** (+299 additions, -43 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/examples/chunk_bench.rs` (+2 -2) 📝 `crates/horizon-client/examples/light_parity.rs` (+5 -5) 📝 `crates/horizon-client/examples/mob_ai_probe.rs` (+2 -2) 📝 `crates/horizon-client/examples/save_parity.rs` (+2 -2) 📝 `crates/horizon-client/src/chunk.rs` (+10 -4) 📝 `crates/horizon-client/src/light.rs` (+219 -21) 📝 `crates/horizon-client/src/streaming.rs` (+3 -7) ➕ `docs/performance/lighting-worker-results.md` (+56 -0) </details> ### 📄 Description Light workers copied whole snapshot sections to return light, and streaming then copied current sections and the returned light again. Workers now return `Vec<Light>` and application moves each light into the current section through `Arc::make_mut`. Current block/biome edits survive, while snapshots held by other workers remain immutable. The existing stale-sequence rejection, missing-current-chunk handling, and forced edit replay stay in the same order. All direct examples use the new result API. The committed ignored benchmark compares production packaging/application with original main's former loops on identical precomputed propagation arrays. It verifies every light, block and biome before timing. Synthetic fixture: 24 sections, 16 block states, four biomes, previously full light storage. Ten measured batches of 500 columns after warm-up, alternating order, median, black_box; AMD Ryzen 5 5600X, Linux x86_64, rustc 1.99.0, fast optimized profile, no LTO, CARGO_INCREMENTAL=0. | Packaging + application | Before | After | Speedup | | --- | ---: | ---: | ---: | | Uniquely owned sections | 63.948 us/column | 44.397 us/column | 1.44x | | Retained snapshot | 65.332 us/column | 53.025 us/column | 1.23x | The old worker copied 149,760 bytes of section heap payload and allocated 24 section Arcs. Those copies/Arcs disappear. Application also avoids cloning 98,304 returned light bytes; uniquely owned sections avoid another whole-section payload copy and 24 Arcs. Shared current sections still incur copy-on-write, as required. Payload/Arc accounting is structural, not global allocator instrumentation. New result/light storage still allocates. Timings exclude propagation, outer chunk copy-on-write, channels, edit replay and remeshing; no full lighting runtime/FPS claim. Reproduction and scope are in `docs/performance/lighting-worker-results.md`. Validation: - `cargo test -p horizon-client --lib --profile fast light::tests -- --nocapture`: 5 passed; benchmark ignored. - Ignored benchmark: passed exact light/block/biome equivalence and timing. - Compiled library test binary `streaming::tests`: 1 passed. - `cargo clippy -p horizon-client --lib --tests --examples --profile fast -- -D warnings`: passed, including all updated examples. - `cargo fmt --all -- --check` and `git diff --check`: passed. - Tests cover moved buffer identity, retained snapshots, block/biome edits, forced replay equivalence, empty chunk/missing neighbours/no-sky, attenuation, occlusion and incremental/full equivalence. No saved-world/Java parity run; fixtures are synthetic. Every Cargo invocation used CARGO_INCREMENTAL=0 and the existing shared target cache. Based directly on original main; no other optimization branches included. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 15:55:58 +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#2421
No description provided.