more robust: imitate Isabelle/ML operation more closely (after 26a43785590b);
authorwenzelm
Sun, 03 Mar 2024 17:47:50 +0100
changeset 79759 5492439ffe89
parent 79758 68f2fe632b4c
child 79760 dbdb8ba05b2b
more robust: imitate Isabelle/ML operation more closely (after 26a43785590b); logical_cores is e.g. relevant for server-arm.sketis.net, where /proc/cpuinfo looks quite different;
src/Pure/Concurrent/multithreading.scala
--- a/src/Pure/Concurrent/multithreading.scala	Sun Mar 03 16:32:59 2024 +0100
+++ b/src/Pure/Concurrent/multithreading.scala	Sun Mar 03 17:47:50 2024 +0100
@@ -39,7 +39,17 @@
         }
         cores.valuesIterator.sum
       }
-      if (physical_cores > 1) physical_cores else 1
+
+      def logical_cores(): Int =
+        if (ssh.is_local) Runtime.getRuntime.availableProcessors()
+        else {
+          Library.trim_line(ssh.execute("nproc").check.out) match {
+            case Value.Nat(n) => n
+            case _ => 1
+          }
+        }
+
+      if (physical_cores > 0) physical_cores else logical_cores()
     }