Trac 107: dumping structs with make-load-form
From Trac 107.
When dumping structs that have a custom make-load-form the resulting fasl file is very big. For example this:
(in-package cl-user)
(defstruct foo)
(defmethod make-load-form ((o foo) &optional env)
(make-load-form-saving-slots o :environment env))
(defun test-dump (object)
(let ((filename "/tmp/foo.lisp"))
(with-open-file (out filename :direction :output :if-exists :supersede)
(with-standard-io-syntax
(format out "(defun dumped-object () '#.***)~%")))
(load (let ((*** object))
(compile-file filename)))
(funcall 'dumped-object)))
(defun object-to-dump (size)
(let ((x (make-array size)))
(dotimes (i size)
(setf (aref x i) (make-foo)))
x))
(test-dump (object-to-dump 1000))
produces a /tmp/foo.sse2f that's about 1MB big. That's about 1 KB per object which seems very much. Maybe the layout and class are dumped for each struct object individually instead of being shared.
For comparision CCL only creates a 5 KB file and AllegroCL 25 KB. SBCL is also quite big: 650 KB.
This is not a big deal but maybe it's easy to fix.