Question:
What is the resolution of the LINUX profile timer? Clearly, this is system specific, so I will provide more details below.
Background:
I am trying to use the Google GPerfTools suite, and I am finding that no matter how hard I try, I cannot get more than about 200 samples/second of CPU time (NOT wallclock time, that's even LOWER), even though the allowable max in the GPerfTools is 4000/second.
Please see this (unloved) question: /questions/22799490
In looking thru the GPerfTools code, I also found that it is using an ITIMER_PROF
(no surprise there), and is using the setitimer(2)
system call with the correct timestruct values (duh!):
void ProfileHandler::StartTimer() {
if (!allowed_) {
return;
}
struct itimerval timer;
timer.it_interval.tv_sec = 0;
timer.it_interval.tv_usec = 1000000 / frequency_;
timer.it_value = timer.it_interval;
setitimer(timer_type_, &timer, 0);
}
Thus, the limitation on sampling rate is either in a system ITIMER_PROF limitation, or a byproduct of how GPerfTools is interacting with the program I am profiling (perhaps the timer is going off when we're blocked on I/O? When that happens...maybe that doesn't count as a sample? :) )
System Specifics:
I am running on a standard x86_64 box running Ubuntu Linux. Here is my uname result:
Linux <hostname> 3.2.0-58-generic #88-Ubuntu SMP Tue Dec 3 17:37:58 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
Program and the GPerfTools library were compiled in 32-bit mode. In fact, the configure
step in the GPerfTools build was done in a 32-bit chroot'd
jail setarch'd
to i386.