Latch, mutex and beyond

latch_times.d

#!/usr/sbin/dtrace -s
#pragma D option quiet
/*
     This file is part of demos for "Contemporary Latch Internals" 
        presentation at Hotsos Symposium 2011  v.21.02.2011
     Copyright: (c)  Andrey S. Nikolaev (Andrey.Nikolaev@rdtex.ru) 

http://AndreyNikolaev.wordpress.com

     Measure latch acquisition times and distributions
*/
BEGIN {
 printf("latch_time  pid: %d\n", $target);
 n=0;
 in_latch_acquisition=0;
 ts=0;
 tget=0;
}
pid$target::kslgetl:entry, 
pid$target::kslgetsl:entry 
/ arg0 == $1 /
{
 ts=timestamp;
 in_latch_acquisition=1;
 n++;
}
pid$target::kslgetl:return,
pid$target::kslgetsl:return
/ in_latch_acquisition /
{
 tget = timestamp;
 this->t = tget - ts;
 @time["Acquisition"] = quantize(this->t);
 @timeavg["acquisition"] = avg(this->t);
 in_latch_acquisition=0;
}
pid$target::kslfre:entry
/ (arg0 == $1) /
{
 this->t = timestamp - tget;
 @time["Holding"] = quantize(this->t);
 @timeavg["holding"] = avg(this->t);
}
tick-10s
{
  normalize(@timeavg,1000);
  printf("\nlatch gets traced: %d\n",n);
  printf("latch acquisition time histogramm for laddress=%p\n",$1);
  printa("%s time:\t%@d\n",@time);
  printa("average %s time =%@d mus\n",@timeavg);
}

1 Comment »

  1. [...] me compare the results of DTrace measurements and latch statistics discussed. I wrote latch_times.d script to measure both latch acquisition and holding times and their distribution. For the [...]

    Pingback by Latch statistics « Latch, mutex and beyond — February 26, 2011 @ 11:45 am | Reply


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

The Rubric Theme. Create a free website or blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.

Join 66 other followers

%d bloggers like this: