[Bug 13206] New: Maximum resident set size might be wrong by time command

bugzilla at busybox.net bugzilla at busybox.net
Sat Sep 12 15:48:35 UTC 2020


https://bugs.busybox.net/show_bug.cgi?id=13206

            Bug ID: 13206
           Summary: Maximum resident set size might be wrong by time
                    command
           Product: Busybox
           Version: 1.27.x
          Hardware: All
                OS: Linux
            Status: NEW
          Severity: minor
          Priority: P5
         Component: Other
          Assignee: unassigned at busybox.net
          Reporter: tetsuya.morimoto at gmail.com
                CC: busybox-cvs at busybox.net
  Target Milestone: ---

The time command has an ability to show the maximum resident set size in rusage
struct. For example, you can see it with "-v" option.

$ busybox time --version
time: unrecognized option '--version'
BusyBox v1.27.2 (Ubuntu 1:1.27.2-2ubuntu3.2) multi-call binary.
$ busybox time -v echo 
        Command being timed: "echo"
        User time (seconds): 0.00
        System time (seconds): 0.00
        Percent of CPU this job got: ?%
        Elapsed (wall clock) time (h:mm:ss or m:ss): 0m 0.00s
        Average shared text size (kbytes): 0
        Average unshared data size (kbytes): 0
        Average stack size (kbytes): 0
        Average total size (kbytes): 0
        Maximum resident set size (kbytes): 7936
        Average resident set size (kbytes): 0
        Major (requiring I/O) page faults: 0
        Minor (reclaiming a frame) page faults: 62
        Voluntary context switches: 1
        Involuntary context switches: 1
        Swaps: 0
        File system inputs: 0
        File system outputs: 0
        Socket messages sent: 0
        Socket messages received: 0
        Signals delivered: 0
        Page size (bytes): 4096
        Exit status: 0

I guess busybox's time command is based on gnu time version 1.7. This version
of time command expects ru.ru_maxrss is page size instead of kilo bytes.

> case 'M':   /* Maximum resident set size.  */
>     printf("%lu", ptok(pagesize, (UL) resp->ru.ru_maxrss));
>     break;

However, this assumption is wrong for some operating systems. In my environment
(Ubuntu 18.04), busybox's time command shows a 4 times larger value than the
correct value.

> While other entries are documented as pages that entry is without units attached to the comment. That is undoubtedly the source of the error. Pages were assumed when it was really kbytes. Looking at the libc documentation we see that it is not ambiguous:
> 
> https://groups.google.com/g/gnu.utils.help/c/u1MOsHL4bhg/m/ewaNE5uxLxoJ?pli=1

Then, gnu time 1.8 fixed in this commit. This fix introduced a configure option
which unit is used for ru.ru_maxrss. 
https://git.savannah.gnu.org/cgit/time.git/commit/?id=fe24b572fca28dc9922096d21b665736dc477534

I think busybox's time command also need to fix what gnu time 1.8 fixed.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


More information about the busybox-cvs mailing list