[PR #3058] [MERGED] Server lag in new forests: count minecart signals only when a detector rail reads them #4774

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/3058
Author: @kacpherek
Created: 10/28/2026
Status: ✅ Merged
Merged: 10/28/2026
Merged by: @Online5277

Base: main ← Head: perf/cart-signals-only-on-detector-rails


📝 Commits (2)

  • 5b13af2 Count a minecart's comparator signal only when a detector rail reads it
  • 6960b65 Keep the cart and its box apart in detector_rail_signal

📊 Changes

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

View changed files

📝 crates/horizon-client/src/game.rs (+20 -9)
📝 crates/horizon-client/src/game/minecarts.rs (+1 -17)

📄 Description

What and why

  • Players see the integrated server's MSPT spike while new chunks with leaves generate (reported on Discord by rdbt). Two macOS sample profiles of the server thread on a Nightly build, flying and teleporting over new terrain, show where the time goes.
  • with_level builds the block-behaviour context, and it used to compute every minecart's comparator signal up front (cart_signals): for each chest and hopper cart, every slot through an item lookup (SipHash on the item id).
  • tick_scheduled calls with_level once per scheduled tick (one at a time, as vanilla runs them). A freshly generated forest has thousands of scheduled leaf ticks, and a new world has many chest carts in mineshafts. In the second profile cart_signals with its item lookups was about a fifth of the server thread's busy time, most of it under tick_scheduled.
  • That signal is only read by detector_rail_signal. The context now holds the carts themselves, and detector_rail_signal counts the slots of the container cart it is reading, when it reads it. No behaviour change.

Vanilla reference

DetectorRailBlock.getAnalogOutputSignal (reads the carts inside its area, when a comparator asks).

Self-check

fmt passes. Built and tested by this pull request's checks. Not run in game.


🔄 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/3058 **Author:** [@kacpherek](https://github.com/kacpherek) **Created:** 10/28/2026 **Status:** ✅ Merged **Merged:** 10/28/2026 **Merged by:** [@Online5277](https://github.com/Online5277) **Base:** `main` ← **Head:** `perf/cart-signals-only-on-detector-rails` --- ### 📝 Commits (2) - [`5b13af2`](https://github.com/horizon-rust/horizon/commit/5b13af2f7592ef9a2dfd0d368064f57789e88fb8) Count a minecart's comparator signal only when a detector rail reads it - [`6960b65`](https://github.com/horizon-rust/horizon/commit/6960b65c62f2b898d3a96bc0445402644a75c03d) Keep the cart and its box apart in detector_rail_signal ### 📊 Changes **2 files changed** (+21 additions, -26 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game.rs` (+20 -9) 📝 `crates/horizon-client/src/game/minecarts.rs` (+1 -17) </details> ### 📄 Description ## What and why - Players see the integrated server's MSPT spike while new chunks with leaves generate (reported on Discord by rdbt). Two macOS `sample` profiles of the server thread on a Nightly build, flying and teleporting over new terrain, show where the time goes. - `with_level` builds the block-behaviour context, and it used to compute every minecart's comparator signal up front (`cart_signals`): for each chest and hopper cart, every slot through an item lookup (SipHash on the item id). - `tick_scheduled` calls `with_level` once per scheduled tick (one at a time, as vanilla runs them). A freshly generated forest has thousands of scheduled leaf ticks, and a new world has many chest carts in mineshafts. In the second profile `cart_signals` with its item lookups was about a fifth of the server thread's busy time, most of it under `tick_scheduled`. - That signal is only read by `detector_rail_signal`. The context now holds the carts themselves, and `detector_rail_signal` counts the slots of the container cart it is reading, when it reads it. No behaviour change. ## Vanilla reference `DetectorRailBlock.getAnalogOutputSignal` (reads the carts inside its area, when a comparator asks). ## Self-check fmt passes. Built and tested by this pull request's checks. Not run in game. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 05:07:49 +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#4774
No description provided.