[PR #1223] [MERGED] Load saved chunks 10% faster by retaining packed list palettes #3431

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

📋 Pull Request Information

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

Base: main ← Head: perf/chunk-palette-loads


📝 Commits (5)

  • 4e46f2a bench: profile chunk generation and saved chunk loading
  • 5d82b4c perf: load list palettes without unpacking discarded indices
  • 753c071 docs: record early-stopped chunk optimization attempts
  • c9c7cda docs: record the completed ten-agent optimization sequence
  • fba4292 Remove benchmark report from pull request

📊 Changes

3 files changed (+324 additions, -17 deletions)

View changed files

➕ crates/horizon-client/examples/load_bench.rs (+153 -0)
📝 crates/horizon-core/src/paletted.rs (+134 -16)
📝 crates/horizon-world/examples/chunkgen_bench.rs (+37 -1)

📄 Description

What and why

Saved list palettes unpacked every stored index into a temporary IDs array that was immediately discarded. Keep their packed words directly and validate occupied word slots in order. This removes the temporary allocation and repeated packed-index division while retaining palette order, unused padding and first-invalid-index errors.

Complete warm SaveDir::load of 256 vanilla-generated normal-world chunks improves 55.459 → 49.770 ms: median paired reduction 10.257%, with all five alternating process pairs improving 9.656–10.573%. Measurements use matching release builds, one discarded warm pair, identical corpus hashes and no concurrent builds or tests. Flat-world loads improve too, but their 2.609–5.617% range does not establish a stable 5% gain. These are saved-chunk load measurements, not total world-entry or generation speedups.

The accompanying read-only loading benchmark and exact generation timing options make the measurements reproducible. No world-generation algorithm changes are included.

Vanilla reference

Pinned Minecraft 26.3 PalettedContainer.unpack, SimpleBitStorage, and palette configuration selection. List configurations retain their packed indices; global configurations still reencode.

Validation completed:

  • 7 palette tests, including differential uniform/list/global widths, duplicate values, malformed storage, dirty padding and first-error ordering.
  • Fresh pinned Java palette oracle: 266 scenarios / 861,864 edits match.
  • All 19 existing save unit tests pass.
  • Exact baseline/candidate resident storage and complete canonical saved-NBT snapshots match all 691 cases: 400 normal-world chunks, 289 flat-world chunks and two nested unknown-NBT/scheduled-tick cases. Includes blocks, biomes, light, heightmaps, structures, entities, ticks and preserved metadata.
  • Vanilla saved-world comparison: flat is clean; normal-world light recomputation has the same seven differing values on baseline and candidate. The optimization introduces no additional differences. Full interactive vanilla → Horizon → vanilla roundtrip was not run.

Self-check

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

Check Result
Scope ✅ 4 files, +466 −17
Cargo.lock ✅ unchanged
Public tree ✅ (1 s)
Python tests ➖ no Python change
rustfmt ✅ (4 s)
clippy ✅ (50 s)
tests: horizon-client, horizon-core, horizon-world ✅ 1442 passed (4 min 19 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)

The focused pinned oracle above also passed. The quick self-check lists the broader affected harnesses for CI rather than running all 321 locally.


🔄 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/1223 **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/chunk-palette-loads` --- ### 📝 Commits (5) - [`4e46f2a`](https://github.com/horizon-rust/horizon/commit/4e46f2a57a804fe81afc825b6fdfc9d3eef2df25) bench: profile chunk generation and saved chunk loading - [`5d82b4c`](https://github.com/horizon-rust/horizon/commit/5d82b4c999d182db825741b2998b26d7bac90167) perf: load list palettes without unpacking discarded indices - [`753c071`](https://github.com/horizon-rust/horizon/commit/753c071c3776229928508b5d7d6451644f4c8ec1) docs: record early-stopped chunk optimization attempts - [`c9c7cda`](https://github.com/horizon-rust/horizon/commit/c9c7cda779e1462e1801bb601d8a9c17c1e00f00) docs: record the completed ten-agent optimization sequence - [`fba4292`](https://github.com/horizon-rust/horizon/commit/fba42920e4c112893ceab14989e83069d113d898) Remove benchmark report from pull request ### 📊 Changes **3 files changed** (+324 additions, -17 deletions) <details> <summary>View changed files</summary> ➕ `crates/horizon-client/examples/load_bench.rs` (+153 -0) 📝 `crates/horizon-core/src/paletted.rs` (+134 -16) 📝 `crates/horizon-world/examples/chunkgen_bench.rs` (+37 -1) </details> ### 📄 Description ## What and why Saved list palettes unpacked every stored index into a temporary IDs array that was immediately discarded. Keep their packed words directly and validate occupied word slots in order. This removes the temporary allocation and repeated packed-index division while retaining palette order, unused padding and first-invalid-index errors. Complete warm `SaveDir::load` of 256 vanilla-generated normal-world chunks improves **55.459 → 49.770 ms**: median paired reduction **10.257%**, with all five alternating process pairs improving **9.656–10.573%**. Measurements use matching release builds, one discarded warm pair, identical corpus hashes and no concurrent builds or tests. Flat-world loads improve too, but their 2.609–5.617% range does not establish a stable 5% gain. These are saved-chunk load measurements, not total world-entry or generation speedups. The accompanying read-only loading benchmark and exact generation timing options make the measurements reproducible. No world-generation algorithm changes are included. ## Vanilla reference Pinned Minecraft 26.3 `PalettedContainer.unpack`, `SimpleBitStorage`, and palette configuration selection. List configurations retain their packed indices; global configurations still reencode. Validation completed: - 7 palette tests, including differential uniform/list/global widths, duplicate values, malformed storage, dirty padding and first-error ordering. - Fresh pinned Java palette oracle: 266 scenarios / 861,864 edits match. - All 19 existing save unit tests pass. - Exact baseline/candidate resident storage and complete canonical saved-NBT snapshots match all 691 cases: 400 normal-world chunks, 289 flat-world chunks and two nested unknown-NBT/scheduled-tick cases. Includes blocks, biomes, light, heightmaps, structures, entities, ticks and preserved metadata. - Vanilla saved-world comparison: flat is clean; normal-world light recomputation has the same seven differing values on baseline and candidate. The optimization introduces no additional differences. Full interactive vanilla → Horizon → vanilla roundtrip was not run. ## Self-check **pr_ready** (`tools/pr_ready.py --quick` on archlinux, against origin/main at 41055168a, 5 min 18 s) | Check | Result | | --- | --- | | Scope | ✅ 4 files, +466 −17 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ (1 s) | | Python tests | ➖ no Python change | | rustfmt | ✅ (4 s) | | clippy | ✅ (50 s) | | tests: horizon-client, horizon-core, horizon-world | ✅ 1442 passed (4 min 19 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) | The focused pinned oracle above also passed. The quick self-check lists the broader affected harnesses for CI rather than running all 321 locally. --- <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:29 +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#3431
No description provided.