Is there a way in SBCL to query the implementation about how far we
currently are from a GC? e.g. "We allocated 1MB since last GC, and
will trigger a new GC after 3MB more allocation".
So as to parallelize compilation and do other fun
concurrent/distributed computations, I want to be able to fork a
single-threaded SBCL properly.
One problem when doing that is that it may be catastrophic to get a GC
just after the fork: that means we are doing all the work in double,
and the child may enter a GC before being done with some of its
One way to alleviate the problem is to do as many child cleanups in C,
not in Lisp, or avoid ever going back to Lisp (run-program does that,
but doesn't offer enough hooks to do all the crazy stuff that a Shell
would want to do before to execve... I will redo that at some point).
But if the child is to continue to run Lisp, the right thing to do is
to have a good heuristic to decide how far we are along the current
allocation cycle, and to trigger an early GC if we are too near to the
end, so as to not be surprised by it just afterwards.
And so I would like to have such a heuristic available.
[ Fran=E7ois-Ren=E9 =D0VB Rideau | Reflection&Cybernethics | http://fare.tu=
No matter what language you use, a Sufficiently Smart Compiler(TM) will be
able to find an efficient implementation for whatever apparently difficult
problem you specify. However, a Sufficiently Smart Compiler(TM) for
arbitrary problems is itself an AI-complete problem.
From: David Steuber <david@da...> - 2007-05-18 22:51:25
On May 18, 2007, at 5:16 PM, Far=E9 wrote:
> Is there a way in SBCL to query the implementation about how far we
> currently are from a GC? e.g. "We allocated 1MB since last GC, and
> will trigger a new GC after 3MB more allocation".
I just looked up ROOM in the CLHS and it seems like it would be =20
allowed to do something like this. The only downside of course is =20
that ROOM prints to *standard-output*.
OpenMCL will print out an estimate:
Welcome to OpenMCL Version 1.1-pre-070512 (DarwinX8664)!
Approximately 33,292,288 bytes of memory can be allocated
before the next full GC is triggered.
Total Size Free Used
Lisp Heap: 47185920 (46080K) 33292288 (32512K) 13893632 =20
Stacks: 11426144 (11158K) 11421968 (11154K) 4176 (4K)
Static: 1517040 (1481K) 0 (0K) 1517040 =20
506835.000 MB reserved for heap expansion.
Perhaps an sb-room could return a particular data structure (to =20
emphasize that it is not portable code).
Just a thought.
Or you could just run sb:gc before forking.