From 81d25daf6192709504867509f2004106e27c6c95 Mon Sep 17 00:00:00 2001
From: Aryadev Chavali <aryadev@aryadevchavali.com>
Date: Wed, 14 Sep 2022 00:14:06 +0100
Subject: (Emacs)+early-init native-compilation options

Set to 4 workers at the start to make compilation at least as fast as
possible: my laptop has 4 cores so it'll just slow it down until early
compilation is done, while my desktop can still keep going as it has 8
threads.  In config.org this is setup correctly so the rest of the
config (which is the much larger part) uses a system dependent number
of cores.
---
 Emacs/.config/emacs/config.org    | 15 +++++++++++++++
 Emacs/.config/emacs/early-init.el |  7 ++++++-
 Emacs/.config/emacs/init.el       |  2 +-
 3 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/Emacs/.config/emacs/config.org b/Emacs/.config/emacs/config.org
index f20b66b..e06745c 100644
--- a/Emacs/.config/emacs/config.org
+++ b/Emacs/.config/emacs/config.org
@@ -140,6 +140,21 @@ common use of this macro.
     `(cond
       ,@current-lisp)))
 #+end_src
+
+In [[file:early-init.el][early-init.el]] I set the number of native-workers to 4, which isn't
+necessarily optimal for the rest of my config to use depending on the
+machine I use:
+- On my laptop (spiderboy) I'd prefer to have it use 2-3 threads so I
+  can use the rest of the laptop while waiting for compilation
+- On my desktop (oldboy) I'd prefer to use 4-6 threads as I can afford
+  more and get a much faster compilation as a result.
+#+begin_src emacs-lisp
+(+dx/sys-name-cond
+ ("spiderboy"
+  (setq native-comp-async-jobs-number 3))
+ ("oldboy"
+  (setq native-comp-async-jobs-number 6)))
+#+end_src
 ** Clean buffer list
 Instead of cleaning my buffer list manually, just use this.  Preserves
 any buffers in ~+dx/keep-buffer~ and kills the rest.
diff --git a/Emacs/.config/emacs/early-init.el b/Emacs/.config/emacs/early-init.el
index afcb4ab..e7a3e75 100644
--- a/Emacs/.config/emacs/early-init.el
+++ b/Emacs/.config/emacs/early-init.el
@@ -6,7 +6,12 @@
 (setq gc-cons-threshold most-positive-fixnum
       package-enable-at-startup nil
       frame-inhibit-implied-resize nil
-      frame-resize-pixelwise t)
+      frame-resize-pixelwise t
+      native-comp-async-jobs-number 4
+      native-comp-eln-load-path (list (concat user-emacs-directory ".local/native-compile"))
+      native-comp-always-compile nil
+      native-comp-async-report-warnings-errors 'silent)
+
 (push '(menu-bar-lines . 0) default-frame-alist)
 (push '(tool-bar-lines . 0) default-frame-alist)
 (push '(vertical-scroll-bars) default-frame-alist)
diff --git a/Emacs/.config/emacs/init.el b/Emacs/.config/emacs/init.el
index d4d376d..f84cb6a 100644
--- a/Emacs/.config/emacs/init.el
+++ b/Emacs/.config/emacs/init.el
@@ -35,8 +35,8 @@
       (eval-print-last-sexp)))
   (load bootstrap-file nil 'nomessage))
 
+
 (setq straight-disable-native-compile nil
-      straight-disable-native-compilation nil
       straight-use-package-by-default t
       use-package-enable-imenu-support t
       use-package-always-demand nil
-- 
cgit v1.2.3-13-gbd6f