feat: short-circuit ContinuedTask.Scheduler.canTake when no continued tasks are buildable#564
Open
eleanorgoh wants to merge 1 commit into
Open
Conversation
… are buildable Track the number of buildable ContinuedTask items via a QueueListener so the QueueTaskDispatcher hot path can return immediately in the common case where no continued task is queued, instead of allocating a fresh buildable-items copy and scanning it on every (node × item) candidate pair per maintain pass. The counter is tracked on instanceof ContinuedTask (stable over the buildable lifecycle) rather than the dynamic isContinued() value, so drift is impossible in the increment/decrement direction. An @Initializer reconciles the counter after JOB_LOADED to cover items restored from queue.xml at startup (the exact case ContinuedTask exists for). Any missed callback would only cause the fast path to miss and fall through to the original scan — correctness is preserved. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
3646c4b to
ff1703b
Compare
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.
Track the number of buildable ContinuedTask items via a QueueListener so the QueueTaskDispatcher hot path can return immediately in the common case where no continued task is queued, instead of allocating a fresh buildable-items copy and scanning it on every (node × item) candidate pair per maintain pass.
The counter is tracked on instanceof ContinuedTask (stable over the buildable lifecycle) rather than the dynamic isContinued() value, so drift is impossible in the increment/decrement direction. An @Initializer reconciles the counter after JOB_LOADED to cover items restored from queue.xml at startup (the exact case ContinuedTask exists for). Any missed callback would only cause the fast path to miss and fall through to the original scan — correctness is preserved.
We're trying to solve for #560.
A performance improvement in the spirit of #563.
Testing done
Includes unit tests.
Submitter checklist