Date: Wed, 17 Jun 2015 14:59:50 -0700 From: abhishek kulkarni <abhya007@gmail.com> To: freebsd-dtrace@freebsd.org Subject: Aggregation in Dtrace Script Causing performance issues Message-ID: <CAJUVsesJhuqxRV2gDTA=utqCZ=YOjPUnu0RTg65suJb-uHUbUA@mail.gmail.com>
next in thread | raw e-mail | index | archive | help
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; }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAJUVsesJhuqxRV2gDTA=utqCZ=YOjPUnu0RTg65suJb-uHUbUA>