Signal workers for priority tasks - #3423
Open
chenBright wants to merge 1 commit into
Open
Conversation
chenBright
force-pushed
the
fix_priority_to_run
branch
from
August 2, 2026 08:10
6927428 to
3f9e759
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses a scheduling gap in bthread’s global priority queue path: after enqueuing a task into the global per-tag priority queue, no worker was explicitly signaled, so eligible workers could remain asleep and leave priority work pending until another wake-up event occurred.
Changes:
- Enqueueing into the global ED priority queue now additionally signals one worker for the task’s tag.
- The priority-queue unit test now keeps track of started urgent children and joins them to ensure completion.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/bthread/task_group.cpp |
Signals a worker after pushing a task into the global per-tag priority queue to avoid stalled priority work. |
test/bthread_priority_queue_unittest.cpp |
Joins urgent child bthreads in a priority-queue test to ensure spawned tasks complete before returning. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
chenBright
force-pushed
the
fix_priority_to_run
branch
from
August 2, 2026 09:57
3f9e759 to
3e25097
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
Suppressed comments (2)
src/bthread/task_group.cpp:1026
- The new wakeup in
priority_to_run()always callssignal_task()even when theBTHREAD_NOSIGNALflag was set on the newly created bthread (passed throughargs->nosignal). That changes the documented NOSIGNAL behavior (“worker pthreads are not notified”) and can defeat batching/flush semantics.
g->control()->push_ed_priority_queue(
args->tag, args->meta->priority_index, args->meta->tid);
++g->_nsignaled;
g->control()->signal_task(1, args->tag);
src/bthread/task_group.cpp:1025
- There isn’t a regression test that specifically exercises the original failure mode described in the PR (all eligible workers parked, then an ED is enqueued into the global priority queue and must wake a worker). The current unit tests create/execute priority work, but they don’t assert the wakeup behavior from the ED priority queue under idle-worker conditions, so this change could regress without being caught.
++g->_nsignaled;
g->control()->signal_task(1, args->tag);
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.
What problem does this PR solve?
Issue Number: resolve N/A
Problem Summary:
Tasks placed into a global priority queue did not signal worker threads after being enqueued. If all eligible workers were sleeping, these tasks could remain pending until another event woke a worker.
What is changed and the side effects?
Changed:
Signal one worker after adding a task to the global priority queue. The signal uses the task's tag so that a worker associated with the correct tag is notified.
Side effects:
Performance effects:
Breaking backward compatibility:
Check List: