Repository navigation
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7322 +/- ##
==========================================
+ Coverage 66.61% 66.64% +0.02%
==========================================
Files 449 449
Lines 22516 22524 +8
==========================================
+ Hits 14999 15011 +12
+ Misses 7517 7513 -4 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
6543
commented
Oct 23, 2026
With the index the limit check is a binary search, while looking for a worker loops over all idle agents. Checking workers first made every blocked task pay tasks x agents filter calls: 110 ms per pass for 10k tasks and 1000 agents, and with 1000 tasks and 1000 agents it was twice as slow as before the index. Check the limit first again, as before the index. Blocked tasks then never reach the worker loop, so a pass stays at about 4 ms for 10k tasks no matter how many agents are idle. Tasks without a limit still skip the index.
Member
Author
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.
assignToWorker checked the concurrency limit of every pending task, and each check scanned all running, pending and waiting tasks again. so a backlog in a concurrency group made every scheduling pass quadratic while holding the queue lock, ~1s per pass at 10k tasks.
now the check uses an index of the queue built once per attempt: running tasks counted per group, queued ones sorted by creation order per group and per group+pipeline, so "how many are ahead of me" is a binary search. the limit is still checked before looking for a worker, so blocked tasks never loop over all agents and it stays fast with many agents too. result stays the same as before.
tradeoff: once a task with a limit is checked, the index gets built (~20k allocs at 10k tasks per call), still way cheaper than holding the lock for a second.
Both shapes hit the same worst case: the whole backlog is blocked, so
assignToWorkerchecks every pending task and returns nothing. The only difference is why each task is skipped.unmatched: the worker's filter rejects every task
reserved: the worker accepts every task, but the slot is taken