[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

gc question

   Date: Fri, 28 Jul 89 16:21:01 PDT
   From: garyo@united.Berkeley.EDU (gary h ogasawara)

   How can you turn the garbage collection off so critical code 
   can be executed?  The excl version we have is 2.0.

The answers to this question didn't get answered on the public list.
For everyone else, here are some answers:

First, one of the big differences between 2.0 and the later releases
is with the garbage collector.  2.0 uses the older stop-and-copy
method which means the lisp process has 2 equally sized spaces and
uses one at a time.  When it runs out of space, the gc copies and
compacts the objects that are still alive from one space to the other.
When it's done, lisp continues running in the other space.

The newer Allegro CL garbage collector is called generation-scavenging
(gsgc) which generally means objects that have survived a certain
number of gcs get "tenured" so that they don't get looked at again
until/unless you decide to do a "full" gc.

In neither case are you able to "turn off" the garbage collector.
Below, however, is a note by Bob Rorschach of Franz Inc. which
describes how you can tune the gsgc to achieve optimal performance
during critical segments.

 There is no way to "turn off" the garbage collector.  The only way to
 ensure that critical code will not be interrupted by a gc is to ensure
 that the critical code is only run when there is sufficient free space
 to allow it to complete without forcing a gc.  To do this you have to
 know how much space the critical code will allocate and you have to
 have an opportunity to force a gc outside the critical code.
 The Allegro gsgc tuning parameters allow you to specify certain
 minimum freespace limits, so you could define
 (defun force-free-space (n)
   (let ((old1 (sys:gsgc-parameter :free-bytes-new-other))
 	(old2 (sys:gsgc-parameter :free-bytes-new-pages)))
     (setf (sys:gsgc-parameter :free-bytes-new-other) n
 	  (sys:gsgc-parameter :free-bytes-new-pages) 0)
     (setf (sys:gsgc-parameter :free-bytes-new-other) old1
 	  (sys:gsgc-parameter :free-bytes-new-pages) old2)
 This would do a gc that forced at least n bytes to be available.
 Note that code may do no consing and still require free space -
 setf-protection, required by generation scavenging, uses free space.
 It would be possible, in an implementation-dependent way, to
 make force-free-space do a gc only if fewer than n bytes were then
 available.  If this approach would solve your problem, please let
 Franz Inc. know.