Subject: | time process statistics "truncated" under AIX |
Date: | Mon, 7 Dec 2009 15:29:33 +0100 |
To: | bug-Proc-ProcessTable [...] rt.cpan.org |
From: | Christian BOITEL <christian.boitel [...] gmail.com> |
Process execution stats are reported by AIX using two long values: tv_sec
and tv_usec. When looking at the time consumption reported by module under
AIX, we found they were all a factor of 100 meaning precision was a second.
In aix_getprocs.c or aix.c, under bless_procs function, tv_sec and tv_usec
members are combined to produce a unique time value which is stored in a
long (i.e. utime, stime, cutime or cstime). Due to the long cast, these
values are finally reflecting only the tv_sec part: the tv_usec part is
lost. Later, the long values are multiplied by 100 (uselessly)
By simply declaring utime, stime, cutime or cstime as double instead of long
at the beginning of the bless_procs function, the tv_usec part is no longer
lost and module will report cpu consumption with a better precision.
Example:
--- Proc-ProcessTable-0.45.original/os/aix_getprocs.c 2003-05-28
08:41:15.000000000 +0200
+++ Proc-ProcessTable-0.45.patched/os/aix_getprocs.c 2009-12-03
17:54:54.000000000 +0100
@@ -112,31 +112,31 @@
void bless_procs(struct procsinfo64 *procs, int count)
{
int index;
char cmndline[ARG_MAX];
char comm[ARG_MAX];
char pctmem[PCT_LENGTH];
char pctcpu[PCT_LENGTH];
char state[STATE_LENGTH];
char *c = NULL;
struct procsinfo64 *curproc = NULL;
struct procsinfo curproc_for_getargs;
int zombie;
int done;
- long utime, stime, cutime, cstime;
+ double utime, stime, cutime, cstime;
/* initialize */
Zero(&curproc_for_getargs, 1, struct procsinfo);