[PR #6613] [MERGED] Pose mob models without allocating part names #6982

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

📋 Pull Request Information

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

Base: main ← Head: perf/mob-poses-no-alloc


📝 Commits (2)

  • c481f9c Pose mob models without allocating part names
  • 2eb2bc1 Merge remote-tracking branch 'origin/main' into perf/mob-poses-no-alloc

📊 Changes

2 files changed (+203 additions, -26 deletions)

View changed files

📝 crates/horizon-client/src/mobs/anim.rs (+39 -26)
📝 crates/horizon-client/src/mobs/render.rs (+164 -0)

📄 Description

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

What

anim::Poses keyed every model part by an owned String: each mob built a new String per part for its body and for every layer (wool, clothes, armour, eyes) every frame, so a mob farm made tens of thousands of small allocations per frame. Parts are now keyed by the Fx hash of their name (FxHashMap<u64, _> / FxHashSet<u64>). Lookups and the first-name-wins rule stay the same, and skips_named / is_hidden_named keep their meaning.

  • no_two_part_names_share_a_key: no two part names of any vanilla model or layer (every model in MobTypes) share a key.
  • benchmark_mob_farm_geometry (#[ignore]) poses the stress_mobs farm (1000 mobs of 8 kinds, as in tools/stress_scenes.py) through render_with. It hashes the 282k vertices and times them with thread CPU time.

The output is identical (same vertex hash), so nothing changes on screen.

A/B: stress_mobs (1000 mobs), CPU geometry per frame

playhorizon (8 vCPU, under load), thread CPU time, 5 alternating base/patched pairs, median of 30 frames each:

Metric Before (main) After Change
Mob geometry (all 1000 mobs) 6.93 ms 5.73 ms −17%
Body poses alone 1.28 ms 0.65 ms −49%
Body vertex emission alone 3.09 ms 2.97 ms ≈
Vertex hash 5435c1f81cfe66fd 5435c1f81cfe66fd identical

Vertex emission still dominates; GPU posing (workstream #8, perf-20x-baseline.md) is the next step. The full-game Horizon vs vanilla runs of the stress scenes come with the --scenes stress tooling PR.

Run it: cargo test --profile fast -p horizon-client-lib --lib mobs::render::scroll_tests::benchmark_mob_farm_geometry -- --ignored --nocapture (needs .local/horizon-client/26.3).

Checks

These ran on playhorizon instead of pr_ready.py: it builds every crate's tests, and the slot-limited box can't fit that tonight.

head 2eb2bc1538 (main merged in, with #6236's armor_stand_motion_tests fix)
cargo fmt --all -- --check                                   ok
cargo clippy --profile fast -p horizon-client -p horizon-client-lib -p horizon-client-render --lib --bins --tests -- -D warnings   ok, 0 diagnostics
cargo test --profile fast -p horizon-client-lib --lib mobs::  339 passed, 0 failed, 12 ignored

🤖 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/6613 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 11/1/2026 **Status:** ✅ Merged **Merged:** 11/2/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `perf/mob-poses-no-alloc` --- ### 📝 Commits (2) - [`c481f9c`](https://github.com/horizon-rust/horizon/commit/c481f9c68aaf21f3d36f72a3d844c2c9e7a6134b) Pose mob models without allocating part names - [`2eb2bc1`](https://github.com/horizon-rust/horizon/commit/2eb2bc15381a4d25b89a466b9cdc8b1afefcc31e) Merge remote-tracking branch 'origin/main' into perf/mob-poses-no-alloc ### 📊 Changes **2 files changed** (+203 additions, -26 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/mobs/anim.rs` (+39 -26) 📝 `crates/horizon-client/src/mobs/render.rs` (+164 -0) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. ## What `anim::Poses` keyed every model part by an owned `String`: each mob built a new `String` per part for its body and for every layer (wool, clothes, armour, eyes) every frame, so a mob farm made tens of thousands of small allocations per frame. Parts are now keyed by the Fx hash of their name (`FxHashMap<u64, _>` / `FxHashSet<u64>`). Lookups and the first-name-wins rule stay the same, and `skips_named` / `is_hidden_named` keep their meaning. - `no_two_part_names_share_a_key`: no two part names of any vanilla model or layer (every model in `MobTypes`) share a key. - `benchmark_mob_farm_geometry` (`#[ignore]`) poses the `stress_mobs` farm (1000 mobs of 8 kinds, as in `tools/stress_scenes.py`) through `render_with`. It hashes the 282k vertices and times them with thread CPU time. The output is identical (same vertex hash), so nothing changes on screen. ## A/B: stress_mobs (1000 mobs), CPU geometry per frame playhorizon (8 vCPU, under load), thread CPU time, 5 alternating base/patched pairs, median of 30 frames each: | Metric | Before (main) | After | Change | |---|---|---|---| | Mob geometry (all 1000 mobs) | 6.93 ms | 5.73 ms | −17% | | Body poses alone | 1.28 ms | 0.65 ms | −49% | | Body vertex emission alone | 3.09 ms | 2.97 ms | ≈ | | Vertex hash | 5435c1f81cfe66fd | 5435c1f81cfe66fd | identical | Vertex emission still dominates; GPU posing (workstream #8, `perf-20x-baseline.md`) is the next step. The full-game Horizon vs vanilla runs of the stress scenes come with the `--scenes stress` tooling PR. Run it: `cargo test --profile fast -p horizon-client-lib --lib mobs::render::scroll_tests::benchmark_mob_farm_geometry -- --ignored --nocapture` (needs `.local/horizon-client/26.3`). ## Checks These ran on playhorizon instead of `pr_ready.py`: it builds every crate's tests, and the slot-limited box can't fit that tonight. ``` head 2eb2bc1538 (main merged in, with #6236's armor_stand_motion_tests fix) cargo fmt --all -- --check ok cargo clippy --profile fast -p horizon-client -p horizon-client-lib -p horizon-client-render --lib --bins --tests -- -D warnings ok, 0 diagnostics cargo test --profile fast -p horizon-client-lib --lib mobs:: 339 passed, 0 failed, 12 ignored ``` 🤖 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:30:44 +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#6982
No description provided.