I notice that slime now has GC hooks on CMUCL to display GC messages. This took a bit to get used to but I rather like it now.
However, for a long time, I've had GC notify function that would also print out how much time (user and real) GC took. What is the proper way of modifying slimes GC hook functions?
Ray
Raymond Toy rtoy@earthlink.net writes:
However, for a long time, I've had GC notify function that would also print out how much time (user and real) GC took. What is the proper way of modifying slimes GC hook functions?
The simplest way is probably something like:
(defun my-hook1 (&rest args) (when swank::*emacs-connection* (swank::eval-in-emacs `(slime-background-message "%s" ,(prin1-to-string args)) t)))
(defun my-hook2 (&rest args) ...)
(setq swank-backend::*install-gc-hooks* nil) (setq ext:*gc-notify-before* #'my-hook1) (setq ext:*gc-notify-after* #'my-hook2)
This basically disables the SLIME's default hooks and uses my-hook{1,2} instead. Testing whether swank::*emacs-connection* is non-nil makes sure that we can send something to Emacs. eval-in-emacs sends a sexp to Emacs and evaluates it there. Note that the symbol in the first position of that sexp is treated specially: it is downcased and the (CL) package prefix is stripped off, so that it makes more sense to Emacs.
You can, of course, use something other than slime-background-message. Especially if you use the typeout frame it might be annoying to the have the GC messages in that frame.
BTW, is there a way to get the size of the different GC generations in CMUCL?
Helmut.
Helmut Eller wrote:
Raymond Toy rtoy@earthlink.net writes:
However, for a long time, I've had GC notify function that would also print out how much time (user and real) GC took. What is the proper way of modifying slimes GC hook functions?
[snip]
This basically disables the SLIME's default hooks and uses my-hook{1,2} instead. Testing whether swank::*emacs-connection* is non-nil makes sure that we can send something to Emacs. eval-in-emacs sends a sexp to Emacs and evaluates it there. Note that the symbol in the first position of that sexp is treated specially: it is downcased and the (CL) package prefix is stripped off, so that it makes more sense to Emacs.
I just basically did the same thing, but it doesn't seem to get installed, if I put that in .swank.lisp.
But it's not really important.
You can, of course, use something other than slime-background-message. Especially if you use the typeout frame it might be annoying to the have the GC messages in that frame.
Right now it goes to the typeout frame that I always use. It's not too annoying.
BTW, is there a way to get the size of the different GC generations in CMUCL?
Will lisp::gencgc-stats do what you want? I don't really know what all of the data mean. It was meant for someone to use if they needed or wanted to try tuning GC for their app.
Ray
Raymond Toy rtoy@earthlink.net writes:
I just basically did the same thing, but it doesn't seem to get installed, if I put that in .swank.lisp.
But it's not really important.
Weird. Works here.
Will lisp::gencgc-stats do what you want? I don't really know what all of the data mean. It was meant for someone to use if they needed or wanted to try tuning GC for their app.
Good enough for me. I assume that there are always 6 generations. I changed the default gc-hook so that it also prints the time and the distribution. It looks now like:
[GC done. 11.2 mb freed 84.5 mb retained 0.0/.05/.01/.12/.78/.03 0.07 sec] ^^^^^^^^^^^^^^^^^^^^^^^ This here is the distribution.
The newest generation is first and, e.g. .78 means that 78% of the live objects are in the 5th generation.
Helmut.
Helmut Eller wrote:
Raymond Toy rtoy@earthlink.net writes:
Will lisp::gencgc-stats do what you want? I don't really know what all of the data mean. It was meant for someone to use if they needed or wanted to try tuning GC for their app.
Good enough for me. I assume that there are always 6 generations. I changed the default gc-hook so that it also prints the time and the distribution. It looks now like:
[GC done. 11.2 mb freed 84.5 mb retained 0.0/.05/.01/.12/.78/.03 0.07 sec] ^^^^^^^^^^^^^^^^^^^^^^^ This here is the distribution.
The newest generation is first and, e.g. .78 means that 78% of the live objects are in the 5th generation.
This looks good. The default is 6 generations, but it's a compile-time constant, that's never been changed AFAIK. It's also possible to change the number of "active" generations at run-time so older generations are never GCed. But people doing this should know what they're doing, so this default is pretty good.
Rather than using my own version, I just updated slime and this looks quite nice.
Many thanks!
Ray