Repository navigation
perf: read grave tags without copying the chest on hopper moves - #136
Conversation
GraveManager.getAt runs for both inventories of every InventoryMoveItemEvent. It used block.getState(), which snapshots the block entity and deep-copies the whole chest inventory just to read the grave id tag. A spark profile on Main showed this at ~3 s of server-thread time per minute. Read the live block entity with getState(false) instead. The lookup only reads the persistent data container on the server thread and never keeps the state, so the result is identical. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Summary
Merge Risk: ⚪ Minimal · up to
|
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@coderabbitai review |
✅ Action performedReview finished.
|
Summary
Stops the grave check from copying a whole chest on every hopper transfer.
GraveInteractListener.onHopperMovecallsGraveManager.isGravefor the source and the destination of everyInventoryMoveItemEventon the server.GraveManager.getAtread the grave tag throughblock.getState(). That builds a snapshot of the block entity, so each check deep-copied every item in the chest just to read one tag.In a spark profile of Main (2026-10-22, 20:28–21:28 UTC, about 30 players), this path (
CraftBlock.getState→CraftContainer.<init>→ContainerHelper.loadAllItems) cost about 3 s of server-thread time per minute, around 5% of every tick. The copies are also garbage that adds to young-GC work.getAtnow reads the tag withblock.getState(false), the live block entity, without a snapshot. The state is only read for the tag on the server thread and never stored. Lookups return the same graves as before, including thebyBlocklocation fallback.Testing
GraveManagerTest: newtaggedLookupReadsTheLiveBlockEntityWithoutCopyingTheChestchecks thatgetAtfinds a tagged grave and never callsgetState(). The existing grave tests pass.main. They're Windows file-permission tests (AccessDenied, POSIX views); Linux CI is the reference.~/grave-hopper-test/test.js+open.js, character bot TestChar1). I ran it on the old jar first (pass), then on this build:getAttag path.Part of the 2026-10-22 ping/lag investigation, together with VehicleFramework and Games PRs.
🤖 Generated with Claude Code