[PR #204] [MERGED] perf(client): share parsed entity models across startup batches #2402

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

📋 Pull Request Information

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

Base: main ← Head: perf/entity-model-document-20261014


📝 Commits (1)

  • 5c076ca perf(client): parse entity model document once for startup batches

📊 Changes

9 files changed (+476 additions, -20 deletions)

View changed files

➕ benchmarks/entity-model-document-2026-10-14/README.md (+78 -0)
➕ benchmarks/entity-model-document-2026-10-14/generate_fixture.py (+31 -0)
➕ benchmarks/entity-model-document-2026-10-14/results.json (+43 -0)
📝 crates/horizon-client/src/game.rs (+15 -3)
📝 crates/horizon-client/src/game/armor_stands.rs (+5 -2)
📝 crates/horizon-client/src/game/boats.rs (+5 -8)
➕ crates/horizon-client/src/game/entity_model_loading_tests.rs (+272 -0)
📝 crates/horizon-client/src/game/minecarts.rs (+2 -4)
📝 crates/horizon-client/src/mobs.rs (+25 -3)

📄 Description

Boat, minecart and armor-stand startup loading reread and reparsed the entire entity-models.json for each model layer. These batches now share one EntityModelDocument and build independent Part trees from it. The document is released immediately after the batches are constructed; the compatible one-off load_model API remains available.

For a batch selecting 42 layers, this reduces full-document reads/parses from 43 (boat discovery plus 42 model lookups) to one.

Batch benchmark Median
Previous per-model algorithm 1,434.974 ms
Shared document, including read/parse 33.420 ms
Speedup 42.94×

The benchmark uses the actual optimized boat/cart/armor loaders and reproduces the previous per-model algorithm. Both run on the same synthetic 2,473,695-byte JSON document (458 layers, 42 selected), with three warmup pairs, 15 alternating measured pairs and black_box input/result consumption. Complete part trees are compared before timing. Prepared resources were unavailable locally. These are warm-page-cache model-batch measurements, excluding equipment textures; they do not establish overall startup or FPS gains. Reproduction commands, fixture generator, machine/profile details and all timing samples are committed under benchmarks/entity-model-document-2026-10-14/.

Validation:

  • Focused batch tests cover full/sparse model documents, unrelated layers, missing files, invalid/non-object JSON, missing keys, independent trees and equipment loading without a model document.
  • Existing model geometry/normal tests pass.
  • cargo clippy -p horizon-client --profile fast --lib --bin horizon-client --tests -- -D warnings passes.
  • cargo fmt --all -- --check and git diff --check pass.

This PR contains optimization 1 only: the three requested startup batches. Other entity loaders retain their current parsing behavior.


🔄 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/204 **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/entity-model-document-20261014` --- ### 📝 Commits (1) - [`5c076ca`](https://github.com/horizon-rust/horizon/commit/5c076ca38f70f2564a5ef1d79fde704ace47a8e4) perf(client): parse entity model document once for startup batches ### 📊 Changes **9 files changed** (+476 additions, -20 deletions) <details> <summary>View changed files</summary> ➕ `benchmarks/entity-model-document-2026-10-14/README.md` (+78 -0) ➕ `benchmarks/entity-model-document-2026-10-14/generate_fixture.py` (+31 -0) ➕ `benchmarks/entity-model-document-2026-10-14/results.json` (+43 -0) 📝 `crates/horizon-client/src/game.rs` (+15 -3) 📝 `crates/horizon-client/src/game/armor_stands.rs` (+5 -2) 📝 `crates/horizon-client/src/game/boats.rs` (+5 -8) ➕ `crates/horizon-client/src/game/entity_model_loading_tests.rs` (+272 -0) 📝 `crates/horizon-client/src/game/minecarts.rs` (+2 -4) 📝 `crates/horizon-client/src/mobs.rs` (+25 -3) </details> ### 📄 Description Boat, minecart and armor-stand startup loading reread and reparsed the entire `entity-models.json` for each model layer. These batches now share one `EntityModelDocument` and build independent `Part` trees from it. The document is released immediately after the batches are constructed; the compatible one-off `load_model` API remains available. For a batch selecting 42 layers, this reduces full-document reads/parses from 43 (boat discovery plus 42 model lookups) to one. | Batch benchmark | Median | | --- | ---: | | Previous per-model algorithm | 1,434.974 ms | | Shared document, including read/parse | 33.420 ms | | Speedup | 42.94× | The benchmark uses the actual optimized boat/cart/armor loaders and reproduces the previous per-model algorithm. Both run on the same **synthetic** 2,473,695-byte JSON document (458 layers, 42 selected), with three warmup pairs, 15 alternating measured pairs and `black_box` input/result consumption. Complete part trees are compared before timing. Prepared resources were unavailable locally. These are warm-page-cache model-batch measurements, excluding equipment textures; they do not establish overall startup or FPS gains. Reproduction commands, fixture generator, machine/profile details and all timing samples are committed under `benchmarks/entity-model-document-2026-10-14/`. Validation: - Focused batch tests cover full/sparse model documents, unrelated layers, missing files, invalid/non-object JSON, missing keys, independent trees and equipment loading without a model document. - Existing model geometry/normal tests pass. - `cargo clippy -p horizon-client --profile fast --lib --bin horizon-client --tests -- -D warnings` passes. - `cargo fmt --all -- --check` and `git diff --check` pass. This PR contains optimization 1 only: the three requested startup batches. Other entity loaders retain their current parsing behavior. --- <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: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#2402
No description provided.