Aggregation in Dtrace Script Causing performance issues
abhishek kulkarni
abhya007 at gmail.com
Wed Jun 17 21:59:51 UTC 2015
Hello All,
Iam Working on a Dtrace Script for the ping utility. The purpose is to
measure the CPU time for the current thread which is PING.We tried doing it
using an aggregation function and once while avoiding it.We observed the
times for a ping response, for both scripts. The response was roughly
taking thrice the time ( around 3.519 ms ) when an aggregation function
was used as against a script not using aggregation ( which took around
0.219 ms ) . Could this be explained in detail.I believe, Dtrace , being
considered a lightweight tool shouldnt affect the performance upto such an
extent.
Here are the 2 scripts :
*Not using an aggregate function* :
BEGIN
{
times = 0;
}
sched:::on-cpu
/execname == "ping"/
{
/* thread entering CPU */
start[execname] = timestamp;
}
sched:::off-cpu
/start[execname] != 0/
{
/* Thread leaving CPU */
times += timestamp - start[execname];
start[execname] = 0 ;
}
END
{
printf("The delta is : %d", (times/1000000));
times =0;
}
*Using an aggregate function "SUM"*
sched:::on-cpu
/execname == "ping"/
{
self->ts = timestamp;
}
sched:::off-cpu
/self->ts != 0/
{
@delta[execname] = sum((timestamp - self-.ts)/1000000);
self->ts =0;
}
More information about the freebsd-dtrace
mailing list