]> git.eshelyaron.com Git - emacs.git/commitdiff
* Windows: Use NUMBER_OF_PROCESSORS environment variable.
authorNicolás Bértolo <nicolasbertolo@gmail.com>
Wed, 13 May 2020 19:22:17 +0000 (16:22 -0300)
committerAndrea Corallo <akrl@sdf.org>
Sat, 23 May 2020 08:36:52 +0000 (09:36 +0100)
* lisp/emacs-lisp/comp.el (comp-effective-async-max-jobs): Use
NUMBER_OF_PROCESSORS environment variable if system is Windows NT,
"nproc" if it is in PATH or a default of 1.

lisp/emacs-lisp/comp.el

index e5d3be6eed042aaa2a271f9c52ce4154c148879f..6c152136fb5aaec519232d8bd990787530ec62fb 100644 (file)
@@ -2302,9 +2302,14 @@ processes from `comp-async-compilations'"
   (if (zerop comp-async-jobs-number)
       (or comp-num-cpus
           (setf comp-num-cpus
-                ;; Half of the CPUs or at least one.
-                ;; FIXME portable?
-                (max 1 (/ (string-to-number (shell-command-to-string "nproc"))
+                ;; FIXME: we already have a function to determine
+                ;; the number of processors, see get_native_system_info in w32.c.
+                ;; The result needs to be exported to Lisp.
+                (max 1 (/ (cond ((eq 'windows-nt system-type)
+                                 (string-to-number (getenv "NUMBER_OF_PROCESSORS")))
+                                ((executable-find "nproc")
+                                 (string-to-number (shell-command-to-string "nproc")))
+                                (t 1))
                           2))))
     comp-async-jobs-number))