Skip to content

Run idle player ticks on the MicroServer that ticks the player's world - #27

Merged
GrowlyX merged 1 commit into
masterfrom
perf/idle-ticks-on-owner-loop
Nov 14, 2026
Merged

GrowlyX merged 1 commit into
masterfrom
perf/idle-ticks-on-owner-loop

Conversation

@GrowlyX

@GrowlyX GrowlyX commented Nov 14, 2026

Copy link
Copy Markdown

On Blueprint with MicroServers, idle 1.9+ players are ticked on the game loop that owns their world instead of in the main thread's tick.

Why

ViaVersion's idle packet task ticks every 1.9+ player who sent no movement packet that tick, the way a 1.8 client's idle flying packet would. It runs in the main thread's tick. On Blueprint that tick is exclusive: every game loop waits while it runs. On legacy-fluid (2026-11-14, ~384 players, 120 s JFR) the task was 14.2% of main-thread samples, almost all of it the player tick itself, for players whose packets their game loop already handles.

Change

  • IdleTickDeferral: when a player's world is ticked by a game loop, the pass queues the tick for that loop. After the pass it hands each loop one task, which runs at the start of the loop's next tick, before its players' packets. Players in worlds the main thread ticks are still ticked inline.
  • No double ticks: the tracker advances when the tick is handed over, so the next pass does not queue the same tick again. If the player has left the loop's worlds or gone offline before the loop runs it, that one tick is dropped.
  • Stopped loops: if a loop has stopped, its queued players are ticked inline; the pass is still inside the exclusive tick.
  • MicroServersSupport: gains gameLoopOf(World) and execute(loop, task) next to its existing runOnGameThread, so this reuses the same binding.
  • MovementTransmitterProvider: gains afterIdlePass() (no-op by default), which IdlePacketTask calls after each pass.
  • Opt-out: -Dviaversion.idleTicksOnOwnerLoop=false keeps every idle tick on the main thread.

Testing

IdleTickDeferralTest covers inline main-thread players, one task per loop, one hand-off per pass, players who moved or quit before the loop ran, and a stopped loop. :viaversion-common:test and :viaversion-bukkit:test: 131 tests pass.

Local 1.8 Blueprint server with MicroServers on, the world adopted by a game loop (/microservers adopt world new), 60 mineflayer 1.12.2 bots standing still with physics off, a test plugin logging each player's getTicksLived() advance every 5 s, and JFR method timing on IdlePacketTask.run over 45 s:

IdlePacketTask.run on the main thread idle players' ticks per 5 s
arch.12 0.569 ms average (max 2.02) 99–101
this change 0.067 ms average (max 0.54) 100

The game loop's own tick went from 0.69 to 1.67 ms average, where the work moved. No idle-packet errors and no kicks in either run.

Not deployed.

🤖 Generated with Claude Code

On Blueprint the main thread's tick is exclusive: every game loop waits
while it runs, and the idle packet task ran in it, ticking every idle 1.9+
player. A player in a game loop's world now gets the idle tick handed to
that loop, one task per loop per pass, which runs it at the start of its
next tick before the player's packets. Players in worlds the main thread
ticks are ticked inline as before.

The tracker advances when the tick is handed over, so the next pass does
not queue it twice. If the player has left the loop or gone offline by
then, that one tick is dropped; if the loop has stopped, the pass ticks
its players inline. -Dviaversion.idleTicksOnOwnerLoop=false keeps every
idle tick on the main thread.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@GrowlyX
GrowlyX merged commit 0f7c9b8 into master Nov 14, 2026
2 of 3 checks passed
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