xach / buildapp

Buildapp makes it easy to build application executables with SBCL
http://www.xach.com/lisp/buildapp/
122 stars 26 forks source link

Add support for CCL --heap-reserve option #31

Open dimitri opened 7 years ago

dimitri commented 7 years ago

It is documented at https://ccl.clozure.com/manual/chapter16.1.html and is comparable to --dynamic-space-size in SBCL I think. Following up on problems to build pgloader with CCL on dockerhub and travis environments I got the following piece of advice:

rme: The second thing might be to try running ccl with "--heap-reserve 150g". Perhaps the container environment doesn't like ccl's default reservation of 512 gigabytes of address space.

It looks like the following patch would allow buildapp to support --heap-reserve?

modified   buildapp.lisp
@@ -400,7 +400,8 @@ ARGV. See *USAGE* for details."
     (quit))
   (let* ((dumper (command-line-dumper (rest argv)))
          (*package* (find-package :buildapp))
-         #+sbcl (dynamic-space-size (dynamic-space-size dumper)))
+         #+sbcl (dynamic-space-size (dynamic-space-size dumper))
+         #+ccl  (heap-reserve (heap-reserve dumper)))
     (with-tempfile (stream ("dumper.lisp" file))
       (write-dumpfile dumper stream)
       (force-output stream)
@@ -415,6 +416,11 @@ ARGV. See *USAGE* for details."
                                       (list "--dynamic-space-size"
                                             (princ-to-string
                                              dynamic-space-size)))
+                                    #+ccl
+                                    (when heap-reserve
+                                      (list "--heap-reserve"
+                                            (princ-to-string
+                                             heap-reserve)))
                                     #+sbcl "--noinform"
                                     #+ccl  "--quiet"
                                     #+sbcl "--disable-debugger"
modified   command-line.lisp
@@ -160,6 +160,8 @@
              (push entry (dispatched-entries plan))))
           (:dynamic-space-size
            (setf (dynamic-space-size plan) (parse-integer value)))
+          (:heap-reserve
+           (setf (heap-reserve plan) (parse-integer value)))
           (t
            (error 'unknown-argument :flag argument)))))))

modified   dumper.lisp
@@ -86,6 +86,10 @@
    (dynamic-space-size
     :initarg :dynamic-space-size
     :accessor dynamic-space-size
+    :initform nil)
+   (heap-reserve
+    :initarg :heap-reserve
+    :accessor heap-reserve
     :initform nil)))

 (defgeneric needs-asdf-p (dumper)