perf: a tank looks each neighbour tile up once per tick #32

Merged
layue13 merged 1 commits from perf/reuse-block-lookups into main 2026-11-07 18:16:40 +00:00
Owner

Requested by Ethyn · project thread

Re-check of closed #20

What

Follow-up to the closed thaumicadditions#20 ("not worth it"). Part of #20 was fixed since (tank meta helper, crop and singularity lookups, see #27/#28/#30), but TileTankBasic.updateEntity still asked the world for the tile above up to 3x (var4, the cast in the eject branch, canAccept path) and the tile below up to 2x per tick. Each neighbour tile is now read once, after the taint-explosion branch exactly where the first lookup used to be, so nothing can have changed between the read and its uses.

Dimensions

before after
world tile lookups per tank per tick 2 normally, 3 with a tank below, 4-5 on an eject tick 2
results (vis/taint of every tank in a stack) - identical over 40 random stacks x 30 ticks
memory / client / startup / latency - no change (two locals)

Tests

TileTankBasicLookupTest runs the old lookup sequence (inline reference) and the new method side by side on counting worlds: tank states match after every tick, lookups never more.

🤖 Generated with Claude Code

<!-- claude-projects-attribution --> _Requested by **Ethyn** · [project thread](https://claude.ai/code/project/chan_01DUNCDJLEksDHKpX5X5cThi?thread=cmsg_01DUNCDJLEksDHKpX5X5cThiWWzw9g2ZbURExfCGHZcnLC)_ Re-check of closed #20 ## What Follow-up to the closed thaumicadditions#20 ("not worth it"). Part of #20 was fixed since (tank meta helper, crop and singularity lookups, see #27/#28/#30), but `TileTankBasic.updateEntity` still asked the world for the tile above up to 3x (`var4`, the cast in the eject branch, `canAccept` path) and the tile below up to 2x per tick. Each neighbour tile is now read once, after the taint-explosion branch exactly where the first lookup used to be, so nothing can have changed between the read and its uses. ## Dimensions | | before | after | |---|---|---| | world tile lookups per tank per tick | 2 normally, 3 with a tank below, 4-5 on an eject tick | 2 | | results (vis/taint of every tank in a stack) | - | identical over 40 random stacks x 30 ticks | | memory / client / startup / latency | - | no change (two locals) | ## Tests TileTankBasicLookupTest runs the old lookup sequence (inline reference) and the new method side by side on counting worlds: tank states match after every tick, lookups never more. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
layue13 added 1 commit 2026-11-07 17:59:30 +00:00
perf: a tank looks each neighbour tile up once per tick
Build / build (push) Skipped
Build / publish (push) Skipped
Build / build (pull_request) Successful in 5m55s
Build / publish (pull_request) Skipped
3b4bc76cc6
updateEntity asked the world for the tile above up to three times and the tile
below up to two times per tick; the blocks around cannot change between those
calls (a taint explosion earlier in the tick is handled before the first
lookup), so each is read once. Results identical, pinned by a test that runs
the old lookup sequence next to the new one.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
layue13 merged commit 9c7845580b into main 2026-11-07 18:16:40 +00:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: TDLM/thaumicadditions#32