perf(server): keep the pending queue sorted instead of re-sorting per dispatch (RIG-1180) - #32
Open
rigel-mintaka wants to merge 1 commit into
Open
perf(server): keep the pending queue sorted instead of re-sorting per dispatch (RIG-1180)#32rigel-mintaka wants to merge 1 commit into
rigel-mintaka wants to merge 1 commit into
Conversation
… dispatch (RIG-1180) Replace the per-dispatch full re-sort of the pending queue with sorted-insert helpers. Previously assignToWorker called pendingByCreation() on every dispatch, copying the whole pending list and running slices.SortStableFunc to order it by taskOrderLess (creation time, then workflow name). The sort key is immutable once a task is queued, so the order can be maintained at insertion time instead. pushPending inserts a task into its creation-order position (after equals, matching the append-then-stable-sort order it replaces); pushPendingFront places a resubmitted expired task ahead of its equals, preserving the retry priority a list push-front gave it. filterWaiting now merges the two already-sorted lists in a single walk. assignToWorker walks the pending list directly. New tests cover multi-dispatch tick ordering, the two insert helpers' placement among equals and at the list ends, and filterWaiting drain ordering. Co-authored-by: Matt Wilkinson <matt@rigel.build> Spec-impact: none. Refs RIG-1180
rigel-mintaka
force-pushed
the
pipelines/rig-1180-sorted-insert-dispatch
branch
from
August 30, 2026 16:37
fc82fc4 to
90700a0
Compare
rigel-mintaka
marked this pull request as ready for review
August 30, 2026 16:38
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.
Replace the per-dispatch full re-sort of the pending queue with sorted-insert helpers. Previously assignToWorker called pendingByCreation() on every dispatch, copying the whole pending list and running slices.SortStableFunc to order it by taskOrderLess (creation time, then workflow name).
The sort key is immutable once a task is queued, so the order can be maintained at insertion time instead. pushPending inserts a task into its creation-order position (after equals, matching the append-then-stable-sort order it replaces); pushPendingFront places a resubmitted expired task ahead of its equals, preserving the retry priority a list push-front gave it. filterWaiting now merges the two already-sorted lists in a single walk. assignToWorker walks the pending list directly.
New tests cover multi-dispatch tick ordering, the two insert helpers' placement among equals and at the list ends, and filterWaiting drain ordering.
Co-authored-by: Matt Wilkinson matt@rigel.build
Spec-impact: none. Refs RIG-1180