master: Add yet another way to run the parallelized build of cold-sbcl.core

snuglas via Sbcl-commits <[email protected]> Thu, 16 Jul 2026 03:11:23 +0000
Newsgroups gmane.lisp.steel-bank.cvs
Message-ID <[email protected]>
The branch "master" has been updated in SBCL:
       via  b1c1f00f62c886f6d12fb60b9a28b81dcffa0088 (commit)
      from  6bd776dee61987f6ce4f4104a1500ae3a3371a5a (commit)

- Log -----------------------------------------------------------------
commit b1c1f00f62c886f6d12fb60b9a28b81dcffa0088
Author: Douglas Katzman <[email protected]>
Date:   Thu Jul 16 03:06:24 2026 +0000

    Add yet another way to run the parallelized build of cold-sbcl.core
    
    Using a Bazel rule - which we can certainly commit to our git repo though
    probably nobody will use it - I was able to get the end-to-end build time
    excluding contribs down to 30 seconds using 300 execution machines.
    The usual caveat pertains about *DERIVE-FUNCTION-TYPES* not informing
    subsequent files of learned information.  But it's great for making
    small algorithmic changes and running some basic smoke tests.
---
 src/cold/compile-cold-sbcl.lisp | 45 +++++++++++++++++++++++++++++++----------
 1 file changed, 34 insertions(+), 11 deletions(-)

diff --git a/src/cold/compile-cold-sbcl.lisp b/src/cold/compile-cold-sbcl.lisp
index 2ad99c092..f2cb9439a 100644
--- a/src/cold/compile-cold-sbcl.lisp
+++ b/src/cold/compile-cold-sbcl.lisp
@@ -200,7 +200,7 @@
             (sb-cold::exit-process 1))))
       (values))))
 
-(sb-kernel::show-ctype-ctor-cache-metrics)
+#+nil (sb-kernel::show-ctype-ctor-cache-metrics)
 
 (defun write-sxhash-xcheck-data (pathname)
   (with-open-file (stream pathname :direction :output
@@ -218,15 +218,38 @@
 ;;; See whether we're in individual file mode
 (cond
   ((boundp 'cl-user::*compile-files*)
-   (let ((files
-          (mapcar (lambda (x) (concatenate 'string "src/" x))
-                  (symbol-value 'cl-user::*compile-files*))))
-     (with-compilation-unit ()
-       (do-stems-and-flags (stem flags 2)
-         (unless (position :not-target flags)
-           (let* ((*compile-for-effect-only* (not (member stem files :test #'string=)))
-                  (sb-xc:*compile-print* (not *compile-for-effect-only*)))
-             (target-compile-stem stem flags)))))))
+   (let ((spec (symbol-value 'cl-user::*compile-files*)))
+     (etypecase spec
+       (string
+        ;; Compile exactly 1 file by preloading (via compile-for-effect-only) all preceding files
+        ;; and then compiling. This is doing the same thing as the parallel build, but the division
+        ;; of labor is controlled by an external driver rather than by forking child processes
+        ;; which works better if you have as many (virtual) execution machines as there are files,
+        ;; but each machine appears to have not that many CPU cores.
+        (flet ((stem= (a b) (string= a (stem-remap-target b))))
+          (let* ((full-list (remove-if (lambda (x) (find :not-target (cdr x)))
+                                       (get-stems-and-flags 2)))
+                 (found (the (not null) (member spec full-list :key #'car :test #'stem=)))
+                 (prereq (ldiff full-list found)))
+            (sb-xc:proclaim '(sb-ext:muffle-conditions style-warning))
+            (let ((sb-xc:*compile-verbose* nil)
+                  (sb-xc:*compile-print* nil))
+              (let ((*compile-for-effect-only* t))
+                (dolist (x prereq)
+                  (target-compile-stem (car x) (cdr x))))
+              (let ((x (car found)))
+                (target-compile-stem (car x) (cdr x))))
+            (when (null (cdr found))
+              (sb-kernel::write-structure-definitions-as-text
+               (sb-cold:find-bootstrap-file "output/defstructs.lisp-expr" t))))))
+       (list
+        (let ((files (mapcar (lambda (x) (concatenate 'string "src/" x)) spec)))
+          (with-compilation-unit ()
+            (do-stems-and-flags (stem flags 2)
+              (unless (position :not-target flags)
+                (let* ((*compile-for-effect-only* (not (member stem files :test #'string=)))
+                       (sb-xc:*compile-print* (not *compile-for-effect-only*)))
+                  (target-compile-stem stem flags))))))))))
   (t
    ;; Actually compile
    (let ((sb-xc:*compile-print* nil))
@@ -268,7 +291,7 @@
       (sb-cold:find-bootstrap-file "output/sxhash-calls.lisp-expr" t))
      (sb-kernel::write-structure-definitions-as-text
       (sb-cold:find-bootstrap-file "output/defstructs.lisp-expr" t)))))
-(sb-kernel::show-ctype-ctor-cache-metrics)
+#+nil (sb-kernel::show-ctype-ctor-cache-metrics)
 
 (let ((s (find-symbol "*RAW-CONST-HISTOGRAM*" "SB-VM")))
   (when (and s (boundp s) (not (null (symbol-value s))))

-----------------------------------------------------------------------


hooks/post-receive
-- 
SBCL