<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/xhtml; charset=utf-8">
</head>
<body>
<div style="font-family:sans-serif"><div style="white-space:normal">
<p dir="auto">ASDF already has a build-image command, and I believe you could do what you want by creating a "shell" system that depends on the packages you want (sb-bsd-sockets, sb-posix, sb-introspect, sb-cltl2), and build an image for that system.  See <code style="background-color:#F7F7F7; border-radius:3px; margin:0; padding:0 0.4em" bgcolor="#F7F7F7">image-op</code> in the ASDF manual.  If that doesn't work for you, please post again to explain why it won't, and we can try to improve things.</p>

<p dir="auto">Best,<br>
R</p>

<p dir="auto">On 17 Nov 2020, at 4:20, Pierre Neidhardt wrote:</p>

</div>
<div style="white-space:normal"><blockquote style="border-left:2px solid #777; color:#777; margin:0 0 5px; padding-left:5px"><p dir="auto">Hi!<br>
<br>
Generating a core with pre-loaded packages (namely sb-bsd-sockets,<br>
sb-posix, sb-introspect, sb-cltl2, asdf) is a common optimization<br>
technique for faster REPL startups. The technique is detailed in the<br>
SLIME and SLY manuals.<br>
<br>
Some may argue that modern machines are fast enough. But from personal<br>
experience even on very fast hardware, I find that it makes for a much<br>
smoother experience, especially for people using SLIME / SLY as their<br>
shell :)<br>
<br>
I've implemented my own Emacs helper<br>
(<a href="https://github.com/joaotavora/sly/pull/366" style="color:#777">https://github.com/joaotavora/sly/pull/366</a>), but in<br>
<a href="https://bugs.launchpad.net/sbcl/+bug/1904042" style="color:#777">https://bugs.launchpad.net/sbcl/+bug/1904042</a> it was suggested to bring<br>
the issue to ASDF which might be the most appropriate place where to<br>
share a helper for everyone, independently of the Lisp implementation or<br>
editor.<br>
<br>
So what about adding a function the would dump an optimized core a bit<br>
like I did in the SLY pull request:<br>
<br>
--8<---------------cut here---------------start------------->8---<br>
(defvar *default-core-extra-modules* '(asdf))<br>
<br>
(defun asdf:dump-core (&key (path *asdf-default-core-location*)<br>
                            (extra-modules *default-core-extra-modules*))<br>
 ...<br>
 ;; Complete the extra-modules with implementation specific modules, as documented in the SLIME / SLY manuals.<br>
 (cond<br>
  ((sbcl-p)<br>
   (append '(sb-bsd-sockets sb-posix sb-introspect sb-cltl2)<br>
           extra-modules))<br>
  ((ccl-p)<br>
   ...<br>
--8<---------------cut here---------------end--------------->8---<br>
<br>
Then all the user would have to do is:<br>
<br>
--8<---------------cut here---------------start------------->8---<br>
CL-USER> (asdf:dump-core)<br>
--8<---------------cut here---------------end--------------->8---<br>
<br>
And restart their REPL, assuming they've configured their REPL to use<br>
this new core.<br>
<br>
It can also be useful to only replace an existing core if the modules or<br>
the Lisp version are different.  This would allow the user to<br>
systematically run `asdf:dump-core` before starting their REPL, thus<br>
automatically ensuring they run an optimized core.<br>
<br>
--8<---------------cut here---------------start------------->8---<br>
;; In Emacs:<br>
(setq sly-lisp-implementations<br>
      '((sbcl (lambda ()<br>
                (call-process "sbcl" nil t nil "--no-userinit"<br>
                              "--eval" "(require :asdf)"<br>
                              "--eval" "(asdf:core-dump)"<br>
                              "--quit")<br>
                `(("sbcl" "--core" path-to-core))))))<br>
--8<---------------cut here---------------end--------------->8---<br>
<br>
Thoughts?<br>
<br>
-- <br>
Pierre Neidhardt<br>
<a href="https://ambrevar.xyz/" style="color:#777">https://ambrevar.xyz/</a></p>
</blockquote></div>
<div style="white-space:normal">
</div>
</div>
</body>
</html>