[PR #649] [MERGED] LAN hub: hand a tick's packets to each connection together #2696

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/649
Author: @ludovic111
Created: 10/17/2026
Status: ✅ Merged
Merged: 10/17/2026
Merged by: @ludovic111

Base: main ← Head: perf/server-batched-sends


📝 Commits (1)

  • 5118d82 LAN hub: hand a tick's packets to each connection together

📊 Changes

5 files changed (+111 additions, -16 deletions)

View changed files

📝 crates/horizon-client/src/game/lan.rs (+6 -0)
📝 crates/horizon-client/src/game/scoreboard.rs (+1 -4)
📝 crates/horizon-client/src/lan/conn.rs (+99 -9)
📝 crates/horizon-client/src/lan/hub.rs (+2 -2)
📝 crates/horizon-client/src/lan/mod.rs (+3 -1)

📄 Description

Profiling the dedicated server at 25 walking bots (macOS sample, 20 s) showed about a quarter of the server thread's tick in mpsc::Sender::send: every packet sent to a guest woke that guest's writer thread (SyncWaker::notify, semaphore_signal).

While tick_lan runs, the packets for each guest are now held in its PlayerSender and handed over as one Out::Packets when the tick ends: one wake-up per guest per tick instead of one per packet. A send outside a tick, and disconnect (kick, server stop), first hand over what is held, so the bytes and their order on the wire don't change.

Same profile after the change (with #623 also applied): tick_lan went from 4311 to 1856 samples, and the remaining send cost is about one wake-up per guest per tick (PlayerSender::flush).

Checks:

  • cargo fmt --all --check, cargo clippy -p horizon-client --all-targets -- -D warnings
  • new test lan::conn::tests::held_packets_go_together_and_in_order, lan:: unit tests, tests/lan_bot.rs
  • parity: dedicated_server, server_player_combat, server_player_damage pass

🤖 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/649 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/17/2026 **Status:** ✅ Merged **Merged:** 10/17/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `perf/server-batched-sends` --- ### 📝 Commits (1) - [`5118d82`](https://github.com/horizon-rust/horizon/commit/5118d824a688a8ae3e4fb0ee25406b65f57aef5b) LAN hub: hand a tick's packets to each connection together ### 📊 Changes **5 files changed** (+111 additions, -16 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/lan.rs` (+6 -0) 📝 `crates/horizon-client/src/game/scoreboard.rs` (+1 -4) 📝 `crates/horizon-client/src/lan/conn.rs` (+99 -9) 📝 `crates/horizon-client/src/lan/hub.rs` (+2 -2) 📝 `crates/horizon-client/src/lan/mod.rs` (+3 -1) </details> ### 📄 Description Profiling the dedicated server at 25 walking bots (macOS `sample`, 20 s) showed about a quarter of the server thread's tick in `mpsc::Sender::send`: every packet sent to a guest woke that guest's writer thread (`SyncWaker::notify`, `semaphore_signal`). While `tick_lan` runs, the packets for each guest are now held in its `PlayerSender` and handed over as one `Out::Packets` when the tick ends: one wake-up per guest per tick instead of one per packet. A send outside a tick, and `disconnect` (kick, server stop), first hand over what is held, so the bytes and their order on the wire don't change. Same profile after the change (with #623 also applied): `tick_lan` went from 4311 to 1856 samples, and the remaining send cost is about one wake-up per guest per tick (`PlayerSender::flush`). Checks: - `cargo fmt --all --check`, `cargo clippy -p horizon-client --all-targets -- -D warnings` - new test `lan::conn::tests::held_packets_go_together_and_in_order`, `lan::` unit tests, `tests/lan_bot.rs` - parity: dedicated_server, server_player_combat, server_player_damage pass 🤖 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-02 15:58:21 +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#2696
No description provided.