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

Re: Profiling and garbage collecting



Concerning questions about metering the GC:
----------------
Return-Path: <tsf@theory.cs.cmu.edu>
Date: Thursday, 13 August 1987 19:45:10 EDT
From: labrea!Timothy.Freeman@theory.cs.cmu.edu
To: hotline@sun.com
Cc: fahlman@c.cs.cmu.edu, scherlis@c.cs.cmu.edu,
        edsel!sun-support@labrea.stanford.edu, rpg@sail.stanford.edu,
        lucites@Think.COM, James.reinders@SAM.CS.CMU.EDU
Subject: Profiling and garbage collecting

James Reinders (James.reinders@sam.cs.cmu.edu) is trying to write some
code to measure which user-written routines consume time with Sun
Common Lisp version 2.1.0 Beta.  His code works, except that when a
garbage collection happens, the routine that was executing gets
charged with the time consumed by the garbage collection.  He wants to
be able to measure the time spent by the garbage collection so that
the routine that was executing is not charged for it.  

Neither James nor I can figure out a way to do this.  Does anyone have
any ideas?

One thing he tried is to redefine the function system:gc so
that it does some accounting and then calls the garbage collector.
This loses miserably.  
	.
	.
	.
----------------
It appears that the code that did the accounting was consing.
Since it was called when there was no space available, it
triggered another GC recursively, and so on.

I do not know of a time function that does not cons.

The Release Notes for version 2.1 document that *gc-silence* can
have a value that is a compiled function.  When it is a function,
GC funcalls it instead of printing a message on the screen.  The
function should take a single argument, which argument will be
one of :before, :after, :reserved-expansion, or
:dynamic-expansion.  The function should use no more than about
1000 bytes of dynamic memory.  No object consed in dynamic space
by the function will survive the function call.

(This was originally intended to be used to let window-system
applications print the progress messages in visible windows.  It
was not intended to be a general purpose tool.)

If you write a function that saves, for example, the value
(logand #xFFFFFF (get-internal-real-time))
in the symbol *gc-start-time* when its argument is :before, and
that does appropriate things with other arguments, then you
should be able to get the measurements you want.


-jim