[PR #4200] [MERGED] Server: answer one command suggestion request a tick, the latest, as vanilla does #5478

Closed
opened 2026-11-03 05:12:52 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

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

Base: main ← Head: fix/suggestions-one-per-tick


📝 Commits (1)

  • b9f8ea2 Server: answer one command suggestion request a tick, the latest (ServerCommandSuggestionsProvider)

📊 Changes

1 file changed (+25 additions, -1 deletions)

View changed files

📝 crates/horizon-client/src/game/lan_actions.rs (+25 -1)

📄 Description

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

Part of #4179: one client could take the whole server to 17 TPS by asking for command suggestions.

Cause. Horizon parsed and answered every ServerboundCommandSuggestionPacket as soon as it arrived. A client sending 100 a tick made the server parse 100 commands a tick, for everyone's tick. Every other request was 30 000 characters long.

Fix. Vanilla 26.3's ServerCommandSuggestionsProvider behaviour, from its bytecode (tools/rea_vanilla.py):

  • request keeps only the latest request. A newer one replaces it, and the replaced one never gets an answer.
  • tryProcessRequest answers it only while this tick's budget is free.
  • tick, run from ServerGamePacketListenerImpl.tick right after the spam throttlers, frees the budget every tick (MIN_INTERVAL_TICKS 1). The budget starts spent, so a request sent before the player's first tick waits for it.

So a player gets at most one answer a tick, the latest. A real client asks once per keystroke and sees no difference.

A/B (playhorizon, Linux, CPUs 0-3 exclusive)

Setup: 20 mixed horizon-bots plus one --behaviour flood-suggest --flood 100 bot (#4181). The bot sends 100 requests a tick, alternating / and a 30 000-character /msg. 30 s warm-up, 60 s window, dedicated build --profile fast --no-default-features. Main is b76ae35f5.

TPS MSPT avg MSPT p99 tick_lan ms/tick
main, round 1 17.92 55.3 85.7 22.4
main, round 2 17.67 56.2 83.5 22.3
this PR, round 1 20.0 33.5 53.7 5.6
this PR, round 2 20.0 34.6 50.5 6.0

Runs with no abuser sit at 32–45 ms MSPT and 5.1–7.0 ms tick_lan (#4179).

Also checked: python3 tools/lan_e2e.py --check commands passes. This covers a guest's Tab completion of a literal and an argument, and a suggestion only the server can give.

pr_ready

pr_ready (tools/pr_ready.py --quick on ludovics-mac-mini, against origin/main at b76ae35f5, 4 min 24 s)

Check Result
Scope ✅ 1 files, +25 −1
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 480 passed (1 min 8 s)
rustfmt ✅ (6 s)
clippy ✅ (1 min 23 s)
tests: horizon-client ✅ 962 passed (1 min 27 s)
doc tests ✅ 0 passed (1 s)
Parity ➖ 31 affected, to run in CI (--quick): block_removal, command_exec, composter, crafter, cursor_death, dedicated_server, dispenser, forced_end, friends_integration, hardcore_respawn, lan_integration, locator_bar and 19 more

🤖 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/4200 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/30/2026 **Status:** ✅ Merged **Merged:** 10/30/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/suggestions-one-per-tick` --- ### 📝 Commits (1) - [`b9f8ea2`](https://github.com/horizon-rust/horizon/commit/b9f8ea2f27bc1b842d53b912cb91f5542c424edf) Server: answer one command suggestion request a tick, the latest (ServerCommandSuggestionsProvider) ### 📊 Changes **1 file changed** (+25 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/lan_actions.rs` (+25 -1) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. Part of #4179: one client could take the whole server to 17 TPS by asking for command suggestions. **Cause.** Horizon parsed and answered every `ServerboundCommandSuggestionPacket` as soon as it arrived. A client sending 100 a tick made the server parse 100 commands a tick, for everyone's tick. Every other request was 30 000 characters long. **Fix.** Vanilla 26.3's `ServerCommandSuggestionsProvider` behaviour, from its bytecode (`tools/rea_vanilla.py`): - `request` keeps only the latest request. A newer one replaces it, and the replaced one never gets an answer. - `tryProcessRequest` answers it only while this tick's budget is free. - `tick`, run from `ServerGamePacketListenerImpl.tick` right after the spam throttlers, frees the budget every tick (`MIN_INTERVAL_TICKS` 1). The budget starts spent, so a request sent before the player's first tick waits for it. So a player gets at most one answer a tick, the latest. A real client asks once per keystroke and sees no difference. ## A/B (playhorizon, Linux, CPUs 0-3 exclusive) Setup: 20 `mixed` horizon-bots plus one `--behaviour flood-suggest --flood 100` bot (#4181). The bot sends 100 requests a tick, alternating `/` and a 30 000-character `/msg`. 30 s warm-up, 60 s window, dedicated build `--profile fast --no-default-features`. Main is b76ae35f5. | | TPS | MSPT avg | MSPT p99 | `tick_lan` ms/tick | |---|---|---|---|---| | main, round 1 | 17.92 | 55.3 | 85.7 | 22.4 | | main, round 2 | 17.67 | 56.2 | 83.5 | 22.3 | | this PR, round 1 | **20.0** | **33.5** | 53.7 | **5.6** | | this PR, round 2 | **20.0** | **34.6** | 50.5 | **6.0** | Runs with no abuser sit at 32–45 ms MSPT and 5.1–7.0 ms `tick_lan` (#4179). Also checked: `python3 tools/lan_e2e.py --check commands` passes. This covers a guest's Tab completion of a literal and an argument, and a suggestion only the server can give. <details><summary>pr_ready</summary> **pr_ready** (`tools/pr_ready.py --quick` on ludovics-mac-mini, against origin/main at b76ae35f5, 4 min 24 s) | Check | Result | | --- | --- | | Scope | ✅ 1 files, +25 −1 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 480 passed (1 min 8 s) | | rustfmt | ✅ (6 s) | | clippy | ✅ (1 min 23 s) | | tests: horizon-client | ✅ 962 passed (1 min 27 s) | | doc tests | ✅ 0 passed (1 s) | | Parity | ➖ 31 affected, to run in CI (--quick): block_removal, command_exec, composter, crafter, cursor_death, dedicated_server, dispenser, forced_end, friends_integration, hardcore_respawn, lan_integration, locator_bar and 19 more | </details> 🤖 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 05:12:52 +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#5478
No description provided.