about summary refs log tree commit diff
path: root/compiler/rustc_thread_pool/src/sleep/mod.rs
diff options
context:
space:
mode:
authorywxt <ywxtcwh@gmail.com>2025-06-25 19:38:40 +0800
committerywxt <ywxtcwh@gmail.com>2025-06-28 17:58:20 +0800
commit0ceac216c9ea96b4b63cba77ae1fabfc8e0320a1 (patch)
treef5fbd7d559d9c36276958d2a7673cf57991fc666 /compiler/rustc_thread_pool/src/sleep/mod.rs
parentd41e12f1f4e4884c356f319b881921aa37040de5 (diff)
downloadrust-0ceac216c9ea96b4b63cba77ae1fabfc8e0320a1.tar.gz
rust-0ceac216c9ea96b4b63cba77ae1fabfc8e0320a1.zip
Only work-steal in the main loop for rustc_thread_pool
Co-authored-by: Zoxc <zoxc32@gmail.com>
Diffstat (limited to 'compiler/rustc_thread_pool/src/sleep/mod.rs')
-rw-r--r--compiler/rustc_thread_pool/src/sleep/mod.rs13
1 files changed, 10 insertions, 3 deletions
diff --git a/compiler/rustc_thread_pool/src/sleep/mod.rs b/compiler/rustc_thread_pool/src/sleep/mod.rs
index a9cdf68cc7e..31bf7184b42 100644
--- a/compiler/rustc_thread_pool/src/sleep/mod.rs
+++ b/compiler/rustc_thread_pool/src/sleep/mod.rs
@@ -144,6 +144,7 @@ impl Sleep {
         idle_state: &mut IdleState,
         latch: &CoreLatch,
         thread: &WorkerThread,
+        steal: bool,
     ) {
         if idle_state.rounds < ROUNDS_UNTIL_SLEEPY {
             thread::yield_now();
@@ -157,7 +158,7 @@ impl Sleep {
             thread::yield_now();
         } else {
             debug_assert_eq!(idle_state.rounds, ROUNDS_UNTIL_SLEEPING);
-            self.sleep(idle_state, latch, thread);
+            self.sleep(idle_state, latch, thread, steal);
         }
     }
 
@@ -167,7 +168,13 @@ impl Sleep {
     }
 
     #[cold]
-    fn sleep(&self, idle_state: &mut IdleState, latch: &CoreLatch, thread: &WorkerThread) {
+    fn sleep(
+        &self,
+        idle_state: &mut IdleState,
+        latch: &CoreLatch,
+        thread: &WorkerThread,
+        steal: bool,
+    ) {
         let worker_index = idle_state.worker_index;
 
         if !latch.get_sleepy() {
@@ -215,7 +222,7 @@ impl Sleep {
         // - that job triggers the rollover over the JEC such that we don't see it
         // - we are the last active worker thread
         std::sync::atomic::fence(Ordering::SeqCst);
-        if thread.has_injected_job() {
+        if steal && thread.has_injected_job() {
             // If we see an externally injected job, then we have to 'wake
             // ourselves up'. (Ordinarily, `sub_sleeping_thread` is invoked by
             // the one that wakes us.)