Only use opened queue slots on running workers #7190
Closed
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.
Minor readability and performance improvement that avoids trying to send a queued task to processing when a slot opens on a non-running worker.
This doesn't affect correctness. Currently, a task will be recommended to
processingand we'll look for a worker for it. Since the worker isn't running, we won't pick it, and the task will stay inqueued. With this PR, we simply save ourselves doing the search when we know it won't be fruitful.I haven't come up with a nice way to test this (since it shouldn't affect behavior and the performance difference will be minuscule anyway.) I could look at the scheduler transition logs and assert there's no extra queued->processing->queued transition in this case, but that feels a bit nitpicky for a case that isn't very important.
pre-commit run --all-files