# HG changeset patch # User wenzelm # Date 1707987238 -3600 # Node ID 7a432595fb665ef17100de07f2cbf677f4852805 # Parent 8836386d6e3f0cc67a03033ff3fc1193e110b3c0 more robust defaults; diff -r 8836386d6e3f -r 7a432595fb66 src/Pure/Concurrent/multithreading.ML --- a/src/Pure/Concurrent/multithreading.ML Thu Feb 15 08:25:25 2024 +0100 +++ b/src/Pure/Concurrent/multithreading.ML Thu Feb 15 09:53:58 2024 +0100 @@ -26,9 +26,10 @@ (* physical processors *) fun num_processors () = - (case Thread.Thread.numPhysicalProcessors () of - SOME n => n - | NONE => Thread.Thread.numProcessors ()); + Int.max + (case Thread.Thread.numPhysicalProcessors () of + SOME n => n + | NONE => Thread.Thread.numProcessors (), 1); (* max_threads *) @@ -38,7 +39,7 @@ fun max_threads_result m = if Thread_Data.is_virtual then 1 else if m > 0 then m - else Int.min (Int.max (num_processors (), 1), 8); + else Int.min (num_processors (), 8); val max_threads_state = ref 1; diff -r 8836386d6e3f -r 7a432595fb66 src/Pure/Concurrent/multithreading.scala --- a/src/Pure/Concurrent/multithreading.scala Thu Feb 15 08:25:25 2024 +0100 +++ b/src/Pure/Concurrent/multithreading.scala Thu Feb 15 09:53:58 2024 +0100 @@ -15,7 +15,7 @@ if (ssh.isabelle_platform.is_macos) { val result = ssh.execute("sysctl -n hw.physicalcpu").check Library.trim_line(result.out) match { - case Value.Int(n) => n + case Value.Int(n) => n max 1 case _ => 1 } } @@ -36,7 +36,7 @@ case _ => } } - physical_cores.valuesIterator.sum.max(1) + physical_cores.valuesIterator.sum max 1 } @@ -44,6 +44,6 @@ def max_threads(): Int = { val m = Value.Int.unapply(System.getProperty("isabelle.threads", "0")) getOrElse 0 - if (m > 0) m else (num_processors() max 1) min 8 + if (m > 0) m else num_processors() min 8 } }