Helper function to dump REPL-optimized core

Robert Goldman rpgoldman at sift.info
Tue Nov 17 15:29:07 UTC 2020


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 `image-op` 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.

Best,
R


On 17 Nov 2020, at 4:20, Pierre Neidhardt wrote:

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


More information about the asdf-devel mailing list