diff --git a/core/autoload/system.el b/core/autoload/system.el index 1585b31bf..bd679656b 100644 --- a/core/autoload/system.el +++ b/core/autoload/system.el @@ -77,30 +77,31 @@ 'face '(:height 1) 'display '(raise 0))) -(defvar doom--system-cpus nil) ;;;###autoload (defun doom-system-cpus () "Return the max number of processing units on this system. Tries to be portable. Returns 1 if cannot be determined." - (or doom--system-cpus - (setq doom--system-cpus - (let ((cpus - (cond ((getenv "NUMBER_OF_PROCESSORS")) - ((executable-find "nproc") - (doom-call-process "nproc")) - ((executable-find "sysctl") - (doom-call-process "sysctl" "-n" "hw.ncpu"))))) - (max - 1 (or (cl-typecase cpus - (string - (condition-case _ - (string-to-number cpus) - (wrong-type-argument - (user-error "NUMBER_OF_PROCESSORS contains an invalid value: %S" - cpus)))) - (consp - (if (zerop (car cpus)) - (string-to-number (cdr cpus)) - (user-error "Failed to look up number of processors, because:\n\n%s" - (cdr cpus))))) - 1)))))) + (or (get 'doom-system-cpus 'cached-value) + (put 'doom-system-cpus 'cached-value + (let ((cpus + (cond ((eq 'windows-nt system-type) + (w32-get-nproc)) + ((getenv "NUMBER_OF_PROCESSORS")) + ((executable-find "nproc") + (doom-call-process "nproc")) + ((executable-find "sysctl") + (doom-call-process "sysctl" "-n" "hw.ncpu"))))) + (max + 1 (or (cl-typecase cpus + (string + (condition-case _ + (string-to-number cpus) + (wrong-type-argument + (user-error "NUMBER_OF_PROCESSORS contains an invalid value: %S" + cpus)))) + (consp + (if (zerop (car cpus)) + (string-to-number (cdr cpus)) + (user-error "Failed to look up number of processors, because:\n\n%s" + (cdr cpus))))) + 1)))))) diff --git a/core/core-cli.el b/core/core-cli.el index 6df3c366a..0bf6a2424 100644 --- a/core/core-cli.el +++ b/core/core-cli.el @@ -70,6 +70,12 @@ purpose.") ;; Stop user configuration from interfering with package management (setq enable-dir-local-variables nil) +;; Default to using all cores, rather than half of them, since we compile things +;; ahead-of-time in a non-interactive session. +(defadvice! doom--comp-use-all-cores-a (&rest _) + :before #'comp-effective-async-max-jobs + (setq comp-num-cpus (doom-system-cpus))) + ;; ;;; Entry point diff --git a/core/core.el b/core/core.el index dafff73bf..e3337e40c 100644 --- a/core/core.el +++ b/core/core.el @@ -189,14 +189,7 @@ users).") (concat local-dir-re ".*/evil-collection-vterm\\.el\\'") (concat local-dir-re ".*/with-editor\\.el\\'") ;; https://github.com/nnicandro/emacs-jupyter/issues/297 - (concat local-dir-re ".*/jupyter-channel\\.el\\'")))) - ;; Default to using all cores, rather than half of them, since we compile - ;; things ahead-of-time in a non-interactive session. - (defun doom--comp-use-all-cores-a () - (if (zerop native-comp-async-jobs-number) - (setq comp-num-cpus (doom-system-cpus)) - native-comp-async-jobs-number)) - (advice-add #'comp-effective-async-max-jobs :override #'doom--comp-use-all-cores-a)) + (concat local-dir-re ".*/jupyter-channel\\.el\\'"))))) ;;