]> granicus.if.org Git - strace/commit
Tweaks for -c: fixed setitimer/getitimer hack; optimized call_summary_pers()
authorDenys Vlasenko <vda.linux@googlemail.com>
Thu, 7 Mar 2013 11:27:40 +0000 (12:27 +0100)
committerDenys Vlasenko <vda.linux@googlemail.com>
Thu, 7 Mar 2013 11:27:40 +0000 (12:27 +0100)
commit8050cdc43c7d804cebe7657d6b5fe8bc37700f2c
tree46673d9273f31fe3e5f1b37be8c89a821dbf5a91
parent5198ed4bb36e3105a1f12bb3250bee78b6e0dd72
Tweaks for -c: fixed setitimer/getitimer hack; optimized call_summary_pers()

count_syscall() was calling setitimer/getitimer once in order to find
smallest "tick" OS uses in time accounting, in order to use it
for syscalls which apparently spent less than that time in syscall.
The code assumed that this "tick" is not zero... but it is zero
on linux-3.6.11. Which means that this hack doesn't work...

At least this change prevents this measurement from being done
_repeatedly_, by initializing one_tick to -1, not 0.

While at it, added comments in count_syscall() explaining what we are doing.

Optimized call_summary_pers() a bit, by eliminating redundant tv -> float
conversions, and prevented 0.0/0.0 which was resulting in "% time"
being shown as "-nan" if total CPU time spent was 0.000000
(try "strace -c /bin/true").

The code seems to seriously underestimate CPU usage:
"strace -c ls -lR /usr/share >/dev/null" shows total time spent
in syscalls to be only ~10..20% of what "time ls -lR /usr/share >/dev/null"
shows.

It might be useful to have a mode where we show wall clock time
spent in syscalls, not CPU time. It might also be more accurate.

   text    data     bss     dec     hex filename
 245019     676    5708  251403   3d60b strace_old
 244923     684    5676  251283   3d593 strace

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
count.c