[ltt-dev] UST clock rdtsc vs clock_gettime

David Goulet david.goulet at polymtl.ca
Tue Jul 6 14:12:11 EDT 2010


Hey,

After some talks with Nils from Ericsson, there was some questions about 
using the TSC counter and not clock_gettime in include/ust/clock.h

I ran some test after the meeting and was quite surprised by the 
overhead of clock_gettime.

On an average run ...
WITH clock_gettime : ~ 266ns per events
WITH rdtsc instruction : ~ 235ns per events

And it is systematic... I'm getting stable result with rdtsc with 
standard deviation of ~2ns.

As little as I know on TSC, one thing for sure, with SMP, it becomes 
much more "fragile" to rely on it because we don't have assurance of 
coherent counters between CPUs and also the CPU scaling policy (ondemand 
is default on Ubuntu now). New CPUs support constant_tsc and nonstop_tsc 
flags but still a small range of them.

Right now, UST is forcing the use of clock_gettime even if i386 or 
x86_64 is used.
Should a change be consider ?

Thanks
David




More information about the lttng-dev mailing list