cuitao2046 / gperftools

Automatically exported from code.google.com/p/gperftools
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

sleep not work in CPUPROFILE_REALTIME mode #268

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
1. Compile simple example:
  int main()
  {
    sleep(20);
    return 0;
  }
2. Observe results of following tests:
$ time env CPUPROFILE=/tmp/mybin.prof CPUPROFILE_REALTIME=1 ./pprof_test 
PROFILE: interrupts/evictions/bytes = 1/0/60

real    0m0.012s
user    0m0.000s
sys 0m0.000s
$ time env CPUPROFILE=/tmp/mybin.prof ./pprof_test 
PROFILE: interrupts/evictions/bytes = 0/0/32

real    0m20.003s
user    0m0.000s
sys 0m0.000s

Original issue reported on code.google.com by KultiH...@gmail.com on 17 Sep 2010 at 8:17

GoogleCodeExporter commented 9 years ago
This is a kernel issue that we won't be able to fix.  itimer_real (used by 
CPUPROFILE_REALTIME) is used, at least on some systems, to implement alarm(), 
which is used to implement sleep().  This conflicting usage is what is causing 
the problems you see.  See also:
   http://www.mombu.com/php/php/t-max-execution-time-itimer-real-vs-itimer-prof-1079606-last.html

Original comment by csilv...@gmail.com on 17 Sep 2010 at 2:28