[PR #230] [MERGED] perf(streaming): skip unchanged generation scans #2419

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

📋 Pull Request Information

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

Base: main ← Head: perf/generation-scan-invalidation-20261014


📝 Commits (1)

  • 69925a5 perf(streaming): skip unchanged exhausted generation scans

📊 Changes

2 files changed (+511 additions, -58 deletions)

View changed files

📝 crates/horizon-client/src/streaming.rs (+459 -58)
➕ docs/generation-scan-benchmark.md (+52 -0)

📄 Description

Stationary worlds repeatedly scanned the complete generation area after all candidates were resident or in progress: radius 32 checks 5,041 square positions per frame. Cache only an exhausted scan and skip it until range, loaded membership, or generation state changes, preserving the original nearest-first bounded scheduling.

Generation results and proto pruning invalidate the gate. Pending candidate batches stay uncached so newly available capacity continues scheduling work. Public movement/radius/extra/forced changes are compared exactly. A minimal ChunkMap structural token detects removals, same-count key changes, external insertions, and map/world replacement without invalidating for block/light edits or unrelated lighting/meshing results. Existing-key value replacement leaves membership unchanged. This support is in its own commit, df1fac16351b89e17df0d9c1643decd18806b4b1, for reuse by independent loaded-membership consumers.

Actual production generation-candidate helper/gate benchmark against an independent copy of the original scan, Linux x86-64 / Ryzen 5 5600X / Rust 1.99.0 / optimized fast profile:

Workload Before ns/frame After ns/frame Speedup Scans per 2,000 frames Jobs before/after
Stationary radius 32 15,441.3 10.1 1,528.99x 2,000 / 0 0 / 0
Remove → queue → saved-load completion every 32 frames 14,794.3 1,004.8 14.72x 2,000 / 126 63 / 63

One warmup and eight measured 2,000-frame samples; median reported. Both implementations validate identical job coordinates/counts and final membership/in-flight state. Fixture uses 3,409 resident keys and 552 outer-margin proto keys, sharing empty Chunk/unit proto data because this path only reads membership. This measures generation scheduling only, excluding full-update costs and worker execution; it makes no FPS/startup claim. Memory cost is a u64 per map plus gate metadata and extra/forced range snapshots, without copying resident keys. Auxiliary range comparisons scale with their size. Reproduction command and complete scope are in docs/generation-scan-benchmark.md.

Validation passed with CARGO_INCREMENTAL=0 and shared target directory:

  • cargo test -p horizon-client --lib --profile fast streaming::tests -- --nocapture: 3 passed, benchmark ignored.
  • cargo test -p horizon-client --lib --profile fast chunk_map::tests -- --nocapture: 1 passed.
  • Explicit ignored generation_scan_benchmark: 1 passed.
  • cargo clippy -p horizon-client --all-targets --profile fast -- -D warnings: passed, including client binaries and test targets.
  • cargo fmt --all -- --check and git diff --check: passed.

Differential cases cover movement/radius, extra/forced ranges, unchanged-count membership replacement, reset, capacity pressure, staged generation transitions and retry after proto discard. Membership tests also verify block/value/light edits keep their token.


🔄 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/230 **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/generation-scan-invalidation-20261014` --- ### 📝 Commits (1) - [`69925a5`](https://github.com/horizon-rust/horizon/commit/69925a57c59cfeb8be3929a6328dcedd43fcd757) perf(streaming): skip unchanged exhausted generation scans ### 📊 Changes **2 files changed** (+511 additions, -58 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/streaming.rs` (+459 -58) ➕ `docs/generation-scan-benchmark.md` (+52 -0) </details> ### 📄 Description Stationary worlds repeatedly scanned the complete generation area after all candidates were resident or in progress: radius 32 checks 5,041 square positions per frame. Cache only an exhausted scan and skip it until range, loaded membership, or generation state changes, preserving the original nearest-first bounded scheduling. Generation results and proto pruning invalidate the gate. Pending candidate batches stay uncached so newly available capacity continues scheduling work. Public movement/radius/extra/forced changes are compared exactly. A minimal `ChunkMap` structural token detects removals, same-count key changes, external insertions, and map/world replacement without invalidating for block/light edits or unrelated lighting/meshing results. Existing-key value replacement leaves membership unchanged. This support is in its own commit, `df1fac16351b89e17df0d9c1643decd18806b4b1`, for reuse by independent loaded-membership consumers. Actual production generation-candidate helper/gate benchmark against an independent copy of the original scan, Linux x86-64 / Ryzen 5 5600X / Rust 1.99.0 / optimized fast profile: | Workload | Before ns/frame | After ns/frame | Speedup | Scans per 2,000 frames | Jobs before/after | | --- | ---: | ---: | ---: | ---: | ---: | | Stationary radius 32 | 15,441.3 | 10.1 | 1,528.99x | 2,000 / 0 | 0 / 0 | | Remove → queue → saved-load completion every 32 frames | 14,794.3 | 1,004.8 | 14.72x | 2,000 / 126 | 63 / 63 | One warmup and eight measured 2,000-frame samples; median reported. Both implementations validate identical job coordinates/counts and final membership/in-flight state. Fixture uses 3,409 resident keys and 552 outer-margin proto keys, sharing empty Chunk/unit proto data because this path only reads membership. This measures generation scheduling only, excluding full-update costs and worker execution; it makes no FPS/startup claim. Memory cost is a u64 per map plus gate metadata and extra/forced range snapshots, without copying resident keys. Auxiliary range comparisons scale with their size. Reproduction command and complete scope are in `docs/generation-scan-benchmark.md`. Validation passed with `CARGO_INCREMENTAL=0` and shared target directory: - `cargo test -p horizon-client --lib --profile fast streaming::tests -- --nocapture`: 3 passed, benchmark ignored. - `cargo test -p horizon-client --lib --profile fast chunk_map::tests -- --nocapture`: 1 passed. - Explicit ignored `generation_scan_benchmark`: 1 passed. - `cargo clippy -p horizon-client --all-targets --profile fast -- -D warnings`: passed, including client binaries and test targets. - `cargo fmt --all -- --check` and `git diff --check`: passed. Differential cases cover movement/radius, extra/forced ranges, unchanged-count membership replacement, reset, capacity pressure, staged generation transitions and retry after proto discard. Membership tests also verify block/value/light edits keep their token. --- <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:55 +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#2419
No description provided.