[PR #5917] [MERGED] Check only nearby chunks' entities for a client that moved #6560

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

📋 Pull Request Information

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

Base: main ← Head: perf/tracking-chunk-index


📝 Commits (2)

  • a5bee31 Check only nearby chunks' entities for a client that moved
  • 2704394 Merge main into perf/tracking-chunk-index

📊 Changes

1 file changed (+38 additions, -10 deletions)

View changed files

📝 crates/horizon-client/src/lan/entity.rs (+38 -10)

📄 Description

Why

Each tick, a client that moved (or whose own entity changed section) had every entity of the level checked against it, so the cost grew as players times entities. A client can only see an entity within its view distance (sees caps the range there), so most of those checks could never pass.

What it does

  • The tracker keeps each chunk's entities while it builds the tick's probes.
  • A client that moved walks only the chunks within its view distance plus one, and checks the entities in them. Everything else stays unseen, which is what checking it gave before.
  • The flags, the new pairs and their order are the same as before, so the packets each client gets and their order do not change. Clients that did not move keep the existing paths.

Measurements

tools/server_bench.py --servers horizon --behaviour walk --join-every 0.5 --warmup 30 --seconds 60, M1 Pro, bots on the same machine:

Bots MSPT avg before after p99 before after
50 7.48 7.52 22.5 19.2
100 19.15 16.16 46.3 48.2

At 50 walking bots there is no difference: the tracker is about 4 % of the tick thread there (macOS sample). At 100 bots the average fell by 16 %, from one run each, so read it as a direction: differences under about 20 % on one machine can be noise.

Testing

  • cargo clippy -p horizon-client --all-targets -- -D warnings: clean.
  • cargo test -p horizon-client --lib lan::: 131 passed (22 of them the tracker's).

🔄 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/5917 **Author:** [@kacpherek](https://github.com/kacpherek) **Created:** 11/1/2026 **Status:** ✅ Merged **Merged:** 11/1/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `perf/tracking-chunk-index` --- ### 📝 Commits (2) - [`a5bee31`](https://github.com/horizon-rust/horizon/commit/a5bee31eb5485cb2efe0764c7e080313bf84d644) Check only nearby chunks' entities for a client that moved - [`2704394`](https://github.com/horizon-rust/horizon/commit/270439435517367aca2c2a73e1adb3c978287932) Merge main into perf/tracking-chunk-index ### 📊 Changes **1 file changed** (+38 additions, -10 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/lan/entity.rs` (+38 -10) </details> ### 📄 Description ## Why Each tick, a client that moved (or whose own entity changed section) had every entity of the level checked against it, so the cost grew as players times entities. A client can only see an entity within its view distance (`sees` caps the range there), so most of those checks could never pass. ## What it does - The tracker keeps each chunk's entities while it builds the tick's probes. - A client that moved walks only the chunks within its view distance plus one, and checks the entities in them. Everything else stays unseen, which is what checking it gave before. - The flags, the new pairs and their order are the same as before, so the packets each client gets and their order do not change. Clients that did not move keep the existing paths. ## Measurements `tools/server_bench.py --servers horizon --behaviour walk --join-every 0.5 --warmup 30 --seconds 60`, M1 Pro, bots on the same machine: | Bots | MSPT avg before | after | p99 before | after | |---|---|---|---|---| | 50 | 7.48 | 7.52 | 22.5 | 19.2 | | 100 | 19.15 | 16.16 | 46.3 | 48.2 | At 50 walking bots there is no difference: the tracker is about 4 % of the tick thread there (macOS `sample`). At 100 bots the average fell by 16 %, from one run each, so read it as a direction: differences under about 20 % on one machine can be noise. ## Testing - `cargo clippy -p horizon-client --all-targets -- -D warnings`: clean. - `cargo test -p horizon-client --lib lan::`: 131 passed (22 of them the tracker's). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 06:23:03 +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#6560
No description provided.