Hello,
On 2018-12-23 6:58 a.m., Donald Buczek wrote:
we just learned the hard way about a bug in gnu time, that the maximum resident
set size reported is scaled up by a factor 4, because the corresponding field
the the rusage struct is wrongly interpreted as pages instead of kilobyte and
scaled up on output.
This bug is 8 years old, and usually fixed by the distros, so distro-users
don't see it. It has never been fixed in upstream, however. [1] [2]
OlderGNU Time has not been updated for a long time (excuse the pun).
Version 1.7 was released in 1996 (!), more than 20 years ago.
In that version, the kernel interface reported pages, and that's
what was reported by "time".
As you correctly noticed, every GNU/Linux distribution that packaged
time had their own version of a patch to fix this issue.
The bug still exists in the master branch.
That is not accurate.
In 2017 maintenance of GNU time was resumed,
and many of the downstream patches have been incorporated upstream:
https://git.savannah.gnu.org/cgit/time.git/log/
$ curl -so mem.cpp https://ideone.com/plain/5bsp0R && make mem && /usr/bin/time -f
"time thinks my peak rss is %M kB" ./mem
g++ mem.cpp -o mem
procfs thinks my peak RSS is: 514652 kB
time thinks my peak rss is 2058608 kB
In the above example, you are likely using version 1.7.