Repository navigation
Cut the per-connection overhead around idle player ticks - #26
Conversation
IdlePacketTask runs every tick on the main thread over every connection. It now resolves the movement transmitter and reads the clock once per run, and passes the MovementTracker it already looked up to the transmitter, which used to look it up twice more. The Bukkit transmitter calls getHandle, the playerConnection field and the flying handler through method handles resolved once. A failure inside the tick is still logged rather than thrown: Method#invoke wrapped it before, and the handles would otherwise let it escape the task's loop over the remaining connections. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Loopy reviewConfidence: 5/5 — No open findings. Reviewed 4 of 4 changed files. Trims per-connection overhead in Via's idle player ticking for 1.8 servers.
Reviews: 1 · last reviewed |
Trims the per-connection work around Via's idle player ticks, which run every tick on the server's main thread.
Evidence
A 90 s JFR of legacy-fluid's main thread (2026-11-14, 422 players, arch.11) put
IdlePacketTask.runat 15.6% of main-thread samples. By source line (222 samples):sendPlayer(the player tick itself)connection.get(MovementTracker.class)for every connectionBukkit.getPlayerField.get(playerConnection)getProviders().get(...)per due connectionMovementTrackerlookups insendPlayerChange
IdlePacketTask: resolves the transmitter and readsSystem.currentTimeMillis()once per run, and passes the tracker it already looked up through a newMovementTransmitterProvider.sendPlayer(UserConnection, MovementTracker). Its default implementation delegates to the existing method.BukkitViaMovementTransmitter: callsgetHandle, theplayerConnectionfield andPlayerConnection#a(PacketPlayInFlying)through method handles resolved once, inPlayerTicker.Method#invokeused to wrap it, and through handles it would otherwise escape the task's loop over the remaining connections.nms-player-ticking: false) is unchanged.Expected effect
Small. The rows this touches add up to about 8 of the 1,423 main-thread samples (≈0.6%). A synthetic benchmark (450 stand-in players, JDK 25) puts the reflective calls at 19.2 ns per player against 17.5 ns through the handles: JDK 25's
Method#invokeis already handle-based, so most of the remaining overhead is the per-connection lookup and iteration, which this leaves alone.Testing
BukkitIdlePlayerTickerTestbinds the ticker to stand-in classes with the NMS shapes. It checks the packet reaches the connection and the tracker advances, a missing connection is skipped without advancing, and a failing tick or a non-player object is reported to the failure sink instead of thrown.:viaversion-common:testand:viaversion-bukkit:test: 126 tests pass.Not deployed or measured in production.
🤖 Generated with Claude Code