[PR #5799] [MERGED] Scheduled ticks: FxHash for the per-tick position sets #6505

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

📋 Pull Request Information

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

Base: main ← Head: perf/ticks-fx-hash


📝 Commits (1)

  • d16d57b Scheduled ticks: FxHash for the per-tick position sets

📊 Changes

5 files changed (+99 additions, -94 deletions)

View changed files

📝 crates/horizon-client-render/src/fast_hash.rs (+3 -85)
➕ crates/horizon-core/src/fast_hash.rs (+88 -0)
📝 crates/horizon-core/src/lib.rs (+1 -0)
📝 crates/horizon-core/src/ticks/generation.rs (+2 -2)
📝 crates/horizon-core/src/ticks/mod.rs (+5 -7)

📄 Description

🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself.

Scheduled ticks hash a (type, position) key at every schedule, poll and duplicate check, and look up the chunk map at every access. All of it used std's SipHash: in a 20-bot profile, LevelTicks::schedule, ChunkTicks::poll and begin_tick spent about 65 samples in SipHash alone.

These maps are now FxHashMap/FxHashSet:

  • LevelTicks.chunks;
  • LevelTicks.to_run_set;
  • ChunkTicks.positions;
  • ProtoChunkTicks.positions.

None of them is iterated where order could matter:

  • the sets are only inserted into, removed from, tested and cleared;
  • the chunk map's values() are only summed;
  • its keys() are sorted before use (chunks_in_area).

Tick order, which comes from the heaps and the deadline index, is unchanged.

The Fx hasher moves from horizon-client-render to horizon-core (horizon_core::fast_hash), which the ticks live in. horizon_client_render::fast_hash re-exports it, so every existing path still works. write uses chunks_exact instead of as_chunks, for horizon-core's MSRV (1.85); the hashes are the same.

Measurement

playhorizon (EPYC, CPUs 0-3, exclusive), server_bench.py horizon, 20 mixed bots, 3 alternated rounds. Base is main 78043f09a, test is this PR.

ms/tick round 1 round 2 round 3 median
tick_blocks, main 5.42 5.35 5.34 5.35
tick_blocks, this PR 5.05 5.06 5.06 5.06 (−5.5 %)
MSPT, main 26.41 25.91 25.81 25.91
MSPT, this PR 25.24 25.46 25.63 25.46

Checks

  • Mac mini:
    • cargo fmt --all --check: pass.
    • cargo clippy -p horizon-core -p horizon-client-render --lib --bins --tests -D warnings: pass.
    • cargo test -p horizon-core: 113 passed, the hasher's test included.
  • playhorizon, pr_ready --quick: horizon-client-render and horizon-core tests, 955 passed.
    • Its toolchain has no rustfmt or clippy; those ran on the Mac mini.
    • Its 2 Python failures, test_lab ... start_no_virtual_screen, come from VSCREEN set in that machine's shell; they pass on the Mac mini.
  • CI runs the 311 affected harnesses (run-parity).

🤖 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/5799 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 11/1/2026 **Status:** ✅ Merged **Merged:** 11/1/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `perf/ticks-fx-hash` --- ### 📝 Commits (1) - [`d16d57b`](https://github.com/horizon-rust/horizon/commit/d16d57b1978d5ae91995f08b1e6d1b55bfabb946) Scheduled ticks: FxHash for the per-tick position sets ### 📊 Changes **5 files changed** (+99 additions, -94 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client-render/src/fast_hash.rs` (+3 -85) ➕ `crates/horizon-core/src/fast_hash.rs` (+88 -0) 📝 `crates/horizon-core/src/lib.rs` (+1 -0) 📝 `crates/horizon-core/src/ticks/generation.rs` (+2 -2) 📝 `crates/horizon-core/src/ticks/mod.rs` (+5 -7) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. Scheduled ticks hash a `(type, position)` key at every `schedule`, `poll` and duplicate check, and look up the chunk map at every access. All of it used std's SipHash: in a 20-bot profile, `LevelTicks::schedule`, `ChunkTicks::poll` and `begin_tick` spent about 65 samples in SipHash alone. These maps are now `FxHashMap`/`FxHashSet`: - `LevelTicks.chunks`; - `LevelTicks.to_run_set`; - `ChunkTicks.positions`; - `ProtoChunkTicks.positions`. None of them is iterated where order could matter: - the sets are only inserted into, removed from, tested and cleared; - the chunk map's `values()` are only summed; - its `keys()` are sorted before use (`chunks_in_area`). Tick order, which comes from the heaps and the deadline index, is unchanged. The Fx hasher moves from `horizon-client-render` to `horizon-core` (`horizon_core::fast_hash`), which the ticks live in. `horizon_client_render::fast_hash` re-exports it, so every existing path still works. `write` uses `chunks_exact` instead of `as_chunks`, for horizon-core's MSRV (1.85); the hashes are the same. ### Measurement playhorizon (EPYC, CPUs 0-3, exclusive), `server_bench.py` horizon, 20 mixed bots, 3 alternated rounds. Base is main 78043f09a, test is this PR. | ms/tick | round 1 | round 2 | round 3 | median | |---|---|---|---|---| | `tick_blocks`, main | 5.42 | 5.35 | 5.34 | 5.35 | | `tick_blocks`, this PR | 5.05 | 5.06 | 5.06 | **5.06 (−5.5 %)** | | MSPT, main | 26.41 | 25.91 | 25.81 | 25.91 | | MSPT, this PR | 25.24 | 25.46 | 25.63 | 25.46 | ### Checks - **Mac mini:** - `cargo fmt --all --check`: pass. - `cargo clippy -p horizon-core -p horizon-client-render --lib --bins --tests -D warnings`: pass. - `cargo test -p horizon-core`: 113 passed, the hasher's test included. - **playhorizon**, `pr_ready --quick`: horizon-client-render and horizon-core tests, 955 passed. - Its toolchain has no rustfmt or clippy; those ran on the Mac mini. - Its 2 Python failures, `test_lab ... start_no_virtual_screen`, come from `VSCREEN` set in that machine's shell; they pass on the Mac mini. - CI runs the 311 affected harnesses (run-parity). 🤖 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:21:45 +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#6505
No description provided.