Skip to content

[1.20.1] Skip routing checks for empty cable buffers - #2546

Open
yaroslav4167 wants to merge 1 commit into
Lothrazar:trunk/1.20.1from
yaroslav4167:perf/1.20.1-skip-empty-cable-buffers
Open

yaroslav4167 wants to merge 1 commit into
Lothrazar:trunk/1.20.1from
yaroslav4167:perf/1.20.1-skip-empty-cable-buffers

Conversation

@yaroslav4167

@yaroslav4167 yaroslav4167 commented Nov 12, 2026 •

Copy link
Copy Markdown

Empty item/fluid cable buffers currently enter the outgoing-direction loop before discovering that there is nothing to transfer. Item cables can perform up to 36 connection checks per empty normalFlow() call; fluid cables perform 30, including block-state property lookups and randomized direction-list creation.

Add an early null/empty-buffer guard before that loop in both cable implementations on trunk/1.20.1. Extraction still runs first, so resources extracted during the current tick can flow immediately. Keep the existing fluid check inside the outgoing loop because a buffer can become empty during that loop. Transfer quantities, filters, routing predicates, dead-end fallback and saved data are unchanged. Skipping the shuffle for empty buffers changes random-number consumption, so identical future random routing sequences are not promised.

Validation:

  • git diff --check passes.
  • A standalone Java harness comparing the base and changed normalFlow() source methods passed 98,304 cases: all 64 occupied-buffer masks, all 64 blocked-side masks, six direction orders, two resource amounts and both cable types. Final resources and transfer traces matched; surrounding handlers/world were modeled.
  • Empty-buffer connection checks in those fixtures: item 36 → 0; fluid 30 → 0. These counts are not a claim of whole-server speedup.
  • Full compilation was attempted with Java 17 and Gradle 8.1.1. It stopped during project configuration, before Java compilation: Invalid patcher dependency, could not resolve sources: null. Full Forge compilation/integration is therefore unverified.

@yaroslav4167
yaroslav4167 marked this pull request as ready for review November 12, 2026 09:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant