]> git.lizzy.rs Git - rust.git/commitdiff
decreasw yield count a bit and explain reasoning a bit more
authorRalf Jung <post@ralfj.de>
Mon, 28 Nov 2022 09:27:21 +0000 (10:27 +0100)
committerRalf Jung <post@ralfj.de>
Mon, 28 Nov 2022 09:29:15 +0000 (10:29 +0100)
src/tools/miri/src/eval.rs

index c7f3c9577a8754db8dce549f808c7642ec2e4376..b8578b1277f53ad94a7103e963556d900d2ba47c 100644 (file)
@@ -27,7 +27,7 @@
 /// When the main thread would exit, we will yield to any other thread that is ready to execute.
 /// But we must only do that a finite number of times, or a background thread running `loop {}`
 /// will hang the program.
-const MAIN_THREAD_YIELDS_AT_SHUTDOWN: u32 = 1_000;
+const MAIN_THREAD_YIELDS_AT_SHUTDOWN: u32 = 256;
 
 #[derive(Copy, Clone, Debug, PartialEq)]
 pub enum AlignmentCheck {
@@ -208,8 +208,12 @@ fn on_main_stack_empty<'tcx>(
                         // Give background threads a chance to finish by yielding the main thread a
                         // couple of times -- but only if we would also preempt threads randomly.
                         if this.machine.preemption_rate > 0.0 {
+                            // There is a non-zero chance they will yield back to us often enough to
+                            // make Miri terminate eventually.
                             *self = Yield { remaining: MAIN_THREAD_YIELDS_AT_SHUTDOWN };
                         } else {
+                            // The other threads did not get preempted, so no need to yield back to
+                            // them.
                             *self = Done;
                         }
                     }