[Openmcl-devel] DTrace and ccl

R. Matthew Emerson rme at clozure.com
Wed Oct 12 09:13:23 PDT 2011


Quoting from the DTrace book:

  DTrace is a observability technology that allows you to answer
  countless questions about how systems and applications are
  behaving in development and in production.

I'm a DTrace novice (at best), but I've been experimenting with
adding some DTrace probes to the lisp kernel.  The very latest
trunk ccl contains some experimental DTrace probes that work on
Darwin x86 and x86-64 systems.

The probes are as follows:

gc-start(unsigned long);
gc-finish(unsigned long);
Fired when a full gc starts or ends.  The argument to gc-start
is the number of bytes allocated.  The argument to gc-finish
is the number of bytes freed.

egc-start(unsigned long, unsigned);
egc-finish(unsigned long, unsigned);
Fired when an egc starts or ends.  The first argument is the
number of bytes allocated (for egc-start) or number of bytes
freed (for egc-finish).  The second argument is the generation
number.

create-thread(unsigned long);
Fired when a new thread is created.  The argument is the OS
thread id.

Here's a script that sort of reproduces the results of
setting ccl::*gc-event-status-bits* to (ash 1 ccl::$egc-verbose-bit).

#!/usr/sbin/dtrace -s

#pragma D option quiet

unsigned long bytes_used, start;
int i;

BEGIN
{
    i = 0;
    printf("%8s %14s %8s %8s\n", "serial", "elapsed ns", "K used", "K freed");
}

ccl$1:::egc-start
{
    bytes_used = arg0;
    start = walltimestamp;
}

ccl$1:::egc-finish
{
    printf("%8u %14u %8u %8u\n", i++, walltimestamp - start, bytes_used,  arg0);
}


Save this as "junk.d" or whatever.  Start a ccl in a terminal, and
find out what its pid is.  (#_getpid) is one way.

Then, run the script in another terminal as "sudo ./junk.d 1234",
where 1234 is the pid you found above.

Now, make the lisp start consing in your preferred way, and you
should see some output from the D script.

If you know a lot about DTrace, would you consider getting in touch?
Adding more DTrace support to ccl seems like a promising avenue, but
I almost don't know what questions to ask.

For instance, perhaps we could use DTrace for profiling if it would be
possible to write a DTrace ustack helper for ccl.  (At one point, ustack
helpers couldn't be built on Mac OS X, but there's still the Solaris
port.) 




More information about the Openmcl-devel mailing list