[PR #1231] [MERGED] Load saved light faster with uniform-layer and paired-nibble paths #3437

Closed
opened 2026-11-03 04:09:32 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

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

Base: main ← Head: perf/saved-light-loading


📝 Commits (3)

  • 0eaa130 perf: load uniform saved light without expanding nibble layers
  • 756cf4a bench: measure read-only saved chunk loading
  • ca2d5e0 Remove benchmark report from pull request

📊 Changes

2 files changed (+365 additions, -2 deletions)

View changed files

➕ crates/horizon-client/examples/load_bench.rs (+153 -0)
📝 crates/horizon-client/src/save.rs (+212 -2)

📄 Description

What and why

Saved light layers were expanded into resident arrays and scanned again even when uniform. Detect uniform nibbles before allocating, and unpack two light values per byte for remaining layers. Preserve missing-layer inheritance, skyless dimensions, invalid-array handling, duplicate sections, compaction and loaded flags.

Complete warm saved-chunk loads improve by paired medians 6.18% for normal terrain (50.036 → 47.005 ms per 256 chunks; range 5.217–6.836%) and 10.98% for flat terrain (12.030 → 10.688 ms; 10.423–11.751%). All ten alternating measured pairs improve after a discarded pair per corpus. These are incremental to the palette-loading baseline in #1223; the published implementation is independent of that PR. Build flags, workload and corpus hashes match, with no concurrent builds/tests during timing. Reproduce with load_bench RESOURCES DIMENSION_DIR --rounds 5 --limit 256 --checksum.

The separate native-decode loop measured 4.64% / 3.19% slower although its source was unchanged; the cause was not isolated. Complete SaveDir::load, including native decode and light, improved in every measured pair. This result is disclosed rather than extrapolating the speedup to every loading path.

The read-only load_bench is the same tooling also included in #1223. This PR contains no palette or aquifer production changes.

Vanilla reference

Pinned Minecraft 26.3 DataLayer.get and SkyLightSectionStorage.repeatFirstLayer. A repeated packed byte is uniform light only when its two nibbles match; 0xF0 and 0x0F are not uniform.

Validation:

  • All 20 save tests, including differential coverage of every repeated packed byte, all uniform sky/block pairs, missing/wrong arrays, section bounds/duplicates, inherited rows, light representation and flags.
  • Fresh pinned Java oracle: 50,331,648 matching light values plus flags.
  • All 691 exact complete metadata snapshots match baseline: 400 normal chunks, 289 flat chunks and two synthetic unknown-NBT/tick cases. Includes full encoded NBT, blocks, biomes, light, heightmaps, entities, ticks, structures and preserved metadata.
  • Final-source release binaries used for the reported timing and parity checks.

Self-check

The combined campaign working tree passed the required quick self-check with tests serialized after an initial client-test process SIGSEGV. Public tree, formatting, Clippy with warnings denied, 1,443 client/core/world tests, and doc tests pass. The failed attempt is retained locally. The fresh relevant Java oracle above ran separately; broader parity harnesses are listed for CI. The standalone PR is based independently on upstream main.

pr_ready (tools/pr_ready.py --quick on archlinux, against origin/main at 41055168a, 11 min 15 s)

Check Result
Scope ⚠️ 8 files, +846 −57; 661 lines of code: over 500, split it if it can ship in parts
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ➖ no Python change
rustfmt ✅ (4 s)
clippy ✅ (18 s)
tests: horizon-client, horizon-core, horizon-world ✅ 1443 passed (10 min 48 s)
doc tests ✅ 0 passed (2 s)
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ 321 affected, to run in CI (--quick): active_effect_tick, active_effects, ambient_sound, anchor, arrow, attribute_health, attribute_map_queries, attribute, attribute_updates, audio_attributes, auto_jump, bamboo and 309 more
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/1231 **Author:** [@rdbtCVS](https://github.com/rdbtCVS) **Created:** 10/22/2026 **Status:** ✅ Merged **Merged:** 10/22/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `perf/saved-light-loading` --- ### 📝 Commits (3) - [`0eaa130`](https://github.com/horizon-rust/horizon/commit/0eaa13020cc16264f6e0488da7e7108f013750cd) perf: load uniform saved light without expanding nibble layers - [`756cf4a`](https://github.com/horizon-rust/horizon/commit/756cf4af07901f18d4e5b8e95a7d293b7f144231) bench: measure read-only saved chunk loading - [`ca2d5e0`](https://github.com/horizon-rust/horizon/commit/ca2d5e04dc35394c859146a64d35f47e1e2c1059) Remove benchmark report from pull request ### 📊 Changes **2 files changed** (+365 additions, -2 deletions) <details> <summary>View changed files</summary> ➕ `crates/horizon-client/examples/load_bench.rs` (+153 -0) 📝 `crates/horizon-client/src/save.rs` (+212 -2) </details> ### 📄 Description ## What and why Saved light layers were expanded into resident arrays and scanned again even when uniform. Detect uniform nibbles before allocating, and unpack two light values per byte for remaining layers. Preserve missing-layer inheritance, skyless dimensions, invalid-array handling, duplicate sections, compaction and loaded flags. Complete warm saved-chunk loads improve by paired medians **6.18% for normal terrain** (50.036 → 47.005 ms per 256 chunks; range 5.217–6.836%) and **10.98% for flat terrain** (12.030 → 10.688 ms; 10.423–11.751%). All ten alternating measured pairs improve after a discarded pair per corpus. These are incremental to the palette-loading baseline in #1223; the published implementation is independent of that PR. Build flags, workload and corpus hashes match, with no concurrent builds/tests during timing. Reproduce with `load_bench RESOURCES DIMENSION_DIR --rounds 5 --limit 256 --checksum`. The separate native-decode loop measured 4.64% / 3.19% slower although its source was unchanged; the cause was not isolated. Complete `SaveDir::load`, including native decode and light, improved in every measured pair. This result is disclosed rather than extrapolating the speedup to every loading path. The read-only `load_bench` is the same tooling also included in #1223. This PR contains no palette or aquifer production changes. ## Vanilla reference Pinned Minecraft 26.3 `DataLayer.get` and `SkyLightSectionStorage.repeatFirstLayer`. A repeated packed byte is uniform light only when its two nibbles match; `0xF0` and `0x0F` are not uniform. Validation: - All 20 save tests, including differential coverage of every repeated packed byte, all uniform sky/block pairs, missing/wrong arrays, section bounds/duplicates, inherited rows, light representation and flags. - Fresh pinned Java oracle: 50,331,648 matching light values plus flags. - All 691 exact complete metadata snapshots match baseline: 400 normal chunks, 289 flat chunks and two synthetic unknown-NBT/tick cases. Includes full encoded NBT, blocks, biomes, light, heightmaps, entities, ticks, structures and preserved metadata. - Final-source release binaries used for the reported timing and parity checks. ## Self-check The combined campaign working tree passed the required quick self-check with tests serialized after an initial client-test process SIGSEGV. Public tree, formatting, Clippy with warnings denied, **1,443 client/core/world tests**, and doc tests pass. The failed attempt is retained locally. The fresh relevant Java oracle above ran separately; broader parity harnesses are listed for CI. The standalone PR is based independently on upstream main. **pr_ready** (`tools/pr_ready.py --quick` on archlinux, against origin/main at 41055168a, 11 min 15 s) | Check | Result | | --- | --- | | Scope | ⚠️ 8 files, +846 −57; 661 lines of code: over 500, split it if it can ship in parts | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ➖ no Python change | | rustfmt | ✅ (4 s) | | clippy | ✅ (18 s) | | tests: horizon-client, horizon-core, horizon-world | ✅ 1443 passed (10 min 48 s) | | doc tests | ✅ 0 passed (2 s) | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ 321 affected, to run in CI (--quick): active_effect_tick, active_effects, ambient_sound, anchor, arrow, attribute_health, attribute_map_queries, attribute, attribute_updates, audio_attributes, auto_jump, bamboo and 309 more | | 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-03 04:09:32 +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#3437
No description provided.