Repository navigation
perf: let idle workers take queued tasks off a busy peer, and move woken tasks to their waker by default - #1233
Merged
Merged
Conversation
…ken tasks to their waker by default
# Conflicts: # cranelift/runtime/src/concurrency/green.rs
This was referenced Oct 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #1232.
A task runs on the first worker that resumes it, and every wake sends it back there. So whether two tasks that talk to each other share a worker is luck, and on 16 workers the luck was expensive:
task_pingpongtook 2.2-2.9 s in about one run in three instead of 400 ms, with all four million wakes crossing workers.chan_fanoutlanded anywhere from 70 to 130 ms.PITH_GREEN_MIGRATE=1already fixed both by moving a woken task to the worker that wakes it. It stayed off because it pulls parallel compute onto one worker. On 16 workers it tookcpu_parallel_syncfrom 911 ms to 2.6-4.7 s.docs/performance.mdnamed the missing piece: letting an idle worker take a ready task off a peer's pinned queue.This PR adds that piece and turns migration on by default:
Readyand held only by that queue, so popping it under the queue's lock gives the thief the same exclusive hand-over a migrating wake gets.has_any_work, so idle workers still park. When it did count, idle workers spun beside a busy pipeline:chan_fanoutused 0.75 s of CPU for a 49 ms run instead of 0.037 s.PITH_GREEN_MIGRATE=0turns migration off.Interleaved medians of 7 at 16 workers, b0cccee against this branch (which includes #1232):
The other concurrency rows and
http_head_readare within 3%.chan_fanoutandtask_pingpongnow match their one-worker times.HTTP server, migration off against the default, medians of three 5 s runs from a Go keep-alive client on the other CCD: 862k vs 863k req/s at 32 connections, 1173k vs 1157k at 256, and 1486k vs 1479k at 1024. The 256 row was 1-2% lower with migration on in all three rounds.
Checks:
examples/grpc_*programs give the same output as with migration off in 20 of 20 runs each.idle_peer_steals_from_a_busy_owners_pinned_queue.