rt: don't notify when pushing task to empty LIFO slot

See #8065
This commit is contained in:
Eliza Weisman
2026-04-18 10:11:14 -07:00
parent b010b5ddaf
commit bc62e2d94c
@@ -1349,9 +1349,12 @@ impl Handle {
// task must always be pushed to the back of the queue, enabling other
// tasks to be executed. If **not** a yield, then there is more
// flexibility and the task may go to the front of the queue.
if is_yield || !core.lifo_enabled {
let should_notify = if is_yield || !core.lifo_enabled {
core.run_queue
.push_back_or_overflow(task, self, &mut core.stats);
// Always notify another parked worker when pushing a yielded task
// to the main run queue if we are not currently parked.
true
} else {
// Push to the LIFO slot
if let Some(prev) = core.run_queue.push_lifo(task) {
@@ -1359,13 +1362,26 @@ impl Handle {
// to be pushed to the back of the run queue.
core.run_queue
.push_back_or_overflow(prev, self, &mut core.stats);
// We have pushed the previous LIFO task to the back of the run
// queue, so we should attempt to notify another worker if we
// are not currently parked.
true
} else {
// If the scheduled task was pushed to the LIFO slot and there
// is no other task previously in the slot, skip notifying
// another worker, so that we can preferentially poll the LIFO
// task next. It can still be stolen if another worker is
// searching. This reduces cross thread notifications, and
// reduces the chance of the LIFO task moving across threads if
// the next poll is short.
false
}
};
// Only notify if not currently parked. If `park` is `None`, then the
// scheduling is from a resource driver. As notifications often come in
// batches, the notification is delayed until the park is complete.
if core.park.is_some() {
if should_notify && core.park.is_some() {
self.notify_parked_local();
}
}