Helper function to dump REPL-optimized core
Pierre Neidhardt
mail at ambrevar.xyz
Tue Nov 17 10:20:09 UTC 2020
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 --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 511 bytes
Desc: not available
URL: <https://mailman.common-lisp.net/pipermail/asdf-devel/attachments/20201117/1968e5e9/attachment.sig>
More information about the asdf-devel
mailing list