Discussion:
bug in gnu time 1.7
(too old to reply)
Mark Visser
2013-11-27 14:16:32 UTC
Permalink
max rss is reported to be 4 times larger than it actually is:

http://stackoverflow.com/questions/10035232/maximum-resident-set-size-does-not-make-sense

original bug report:

https://groups.google.com/forum/#!topic/gnu.utils.help/u1MOsHL4bhg

patch:

diff -ru time-1.7.orig/ChangeLog time-1.7/ChangeLog
--- time-1.7.orig/ChangeLog 1996-07-11 10:37:20.000000000 -0600
+++ time-1.7/ChangeLog 2010-10-01 16:03:09.000000000 -0600
@@ -1,3 +1,10 @@
+2010-10-01 Bob Proulx <***@proulx.com>
+
+ The struct rusage reports ru_maxrss in kbytes not pages and
+ should not be converted through pages-to-kbytes again.
+ Reported by Sven Hartrumpf.
+ * time.c (summarize): Do not call ptok on ru_maxrss.
+
diff -ru time-1.7.orig/time.c time-1.7/time.c
--- time-1.7.orig/time.c 1996-06-13 13:38:21.000000000 -0600
+++ time-1.7/time.c 2010-10-01 15:49:11.000000000 -0600
@@ -392,7 +392,7 @@
ptok ((UL) resp->ru.ru_ixrss) / MSEC_TO_TICKS (v));
break;
case 'M': /* Maximum resident set size. */
- fprintf (fp, "%lu", ptok ((UL) resp->ru.ru_maxrss));
+ fprintf (fp, "%lu", (UL) resp->ru.ru_maxrss);
break;
case 'O': /* Outputs. */
fprintf (fp, "%ld", resp->ru.ru_oublock);
Andreas Schwab
2013-11-27 17:45:43 UTC
Permalink
Post by Mark Visser
diff -ru time-1.7.orig/time.c time-1.7/time.c
--- time-1.7.orig/time.c 1996-06-13 13:38:21.000000000 -0600
+++ time-1.7/time.c 2010-10-01 15:49:11.000000000 -0600
@@ -392,7 +392,7 @@
ptok ((UL) resp->ru.ru_ixrss) / MSEC_TO_TICKS (v));
break;
case 'M': /* Maximum resident set size. */
- fprintf (fp, "%lu", ptok ((UL) resp->ru.ru_maxrss));
+ fprintf (fp, "%lu", (UL) resp->ru.ru_maxrss);
What about the other uses of ptok?

Andreas.
--
Andreas Schwab, ***@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
Mark Visser
2013-11-27 18:38:31 UTC
Permalink
Good question. I did some digging, and ru_idrss, ru_isrss and ru_ixrss are
unused on Linux -- from
http://man7.org/linux/man-pages/man2/getrusage.2.html:

*ru_maxrss* (since Linux 2.6.32)
This is the maximum resident set size used (in kilobytes).
For *RUSAGE_CHILDREN*, this is the resident set size of the
largest child, not the maximum resident set size of the
process tree.

*ru_ixrss* (unmaintained)
This field is currently unused on Linux.

*ru_idrss* (unmaintained)
This field is currently unused on Linux.

*ru_isrss* (unmaintained)

This field is currently unused on Linux.

But GNU libc implies they are all in kilobytes
http://www.gnu.org/software/libc/manual/html_node/Resource-Usage.html:

long int ru_maxrssThe maximum resident set size used, in kilobytes. That
is, the maximum number of kilobytes of physical memory that processes used
simultaneously.
long int ru_ixrssAn integral value expressed in kilobytes times ticks of
execution, which indicates the amount of memory used by text that was
shared with other processes.
long int ru_idrssAn integral value expressed the same way, which is the
amount of unshared memory used for data.
long int ru_isrssAn integral value expressed the same way, which is the
amount of unshared memory used for stack space.

BSD explicitly states they are in kilobytes
http://www.manpages.info/freebsd/getrusage.2.html:

*ru_maxrss* the maximum resident set size utilized (in kilobytes).

*ru_ixrss* an ``integral'' value indicating the amount of memory used
by the text segment that was also shared among other pro-
cesses. This value is expressed in units of kilobytes *
ticks-of-execution. Ticks are statistics clock ticks. The
statistics clock has a frequency of *sysconf*(*_SC_CLOCK_TCK*)
ticks per second.

*ru_idrss* an integral value of the amount of unshared memory residing
in the data segment of a process (expressed in units of
kilobytes * ticks-of-execution).

*ru_isrss* an integral value of the amount of unshared memory residing
in the stack segment of a process (expressed in units of
kilobytes * ticks-of-execution).


Except, of course, for Darwin, which uses bytes for all four of these
fields http://lists.apple.com/archives/darwin-kernel/2009/Mar/msg00005.html.

So a unit of pages is definitely wrong for all four fields, but what is
right depends on the target OS.

cheers,
-Mark
Post by Andreas Schwab
Post by Mark Visser
diff -ru time-1.7.orig/time.c time-1.7/time.c
--- time-1.7.orig/time.c 1996-06-13 13:38:21.000000000 -0600
+++ time-1.7/time.c 2010-10-01 15:49:11.000000000 -0600
@@ -392,7 +392,7 @@
ptok ((UL) resp->ru.ru_ixrss) / MSEC_TO_TICKS
(v));
Post by Mark Visser
break;
case 'M': /* Maximum resident set size. */
- fprintf (fp, "%lu", ptok ((UL) resp->ru.ru_maxrss));
+ fprintf (fp, "%lu", (UL) resp->ru.ru_maxrss);
What about the other uses of ptok?
Andreas.
--
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
Bob Proulx
2013-11-27 21:22:25 UTC
Permalink
Post by Mark Visser
http://stackoverflow.com/questions/10035232/maximum-resident-set-size-does-not-make-sense
https://groups.google.com/forum/#!topic/gnu.utils.help/u1MOsHL4bhg
Yes. That is an old well known problem. The problem is that the
official GNU time maintainer isn't MIA. He will respond to email.

http://lists.gnu.org/archive/html/bug-gnu-utils/2013-02/msg00020.html

But he has never made a release.

http://ftp.gnu.org/gnu/time/

Hope springs eternal though.
I maintain patches for time-1.7 for Debian. These patches are
available for viewing here:

http://patch-tracker.debian.org/package/time/1.7-24

Of which the two you are most interested in are these:

http://patch-tracker.debian.org/patch/series/view/time/1.7-24/rusage-portability.patch

http://patch-tracker.debian.org/patch/series/view/time/1.7-24/ru_maxrss.patch

However the others are also important and useful.

Bob
Mark Visser
2013-11-27 21:33:55 UTC
Permalink
Thanks, and sorry for the noise.
Post by Mark Visser
http://stackoverflow.com/questions/10035232/maximum-resident-set-size-does-not-make-sense
Post by Mark Visser
https://groups.google.com/forum/#!topic/gnu.utils.help/u1MOsHL4bhg
Yes. That is an old well known problem. The problem is that the
official GNU time maintainer isn't MIA. He will respond to email.
http://lists.gnu.org/archive/html/bug-gnu-utils/2013-02/msg00020.html
But he has never made a release.
http://ftp.gnu.org/gnu/time/
Hope springs eternal though.
I maintain patches for time-1.7 for Debian. These patches are
http://patch-tracker.debian.org/package/time/1.7-24
http://patch-tracker.debian.org/patch/series/view/time/1.7-24/rusage-portability.patch
http://patch-tracker.debian.org/patch/series/view/time/1.7-24/ru_maxrss.patch
However the others are also important and useful.
Bob
Jim Meyering
2015-01-20 17:36:10 UTC
Permalink
Post by Mark Visser
Thanks, and sorry for the noise.
Post by Mark Visser
http://stackoverflow.com/questions/10035232/maximum-resident-set-size-does-not-make-sense
Post by Mark Visser
https://groups.google.com/forum/#!topic/gnu.utils.help/u1MOsHL4bhg
Yes. That is an old well known problem. The problem is that the
official GNU time maintainer isn't MIA. He will respond to email.
http://lists.gnu.org/archive/html/bug-gnu-utils/2013-02/msg00020.html
But he has never made a release.
http://ftp.gnu.org/gnu/time/
Hope springs eternal though.
I maintain patches for time-1.7 for Debian. These patches are
http://patch-tracker.debian.org/package/time/1.7-24
http://patch-tracker.debian.org/patch/series/view/time/1.7-24/rusage-portability.patch
http://patch-tracker.debian.org/patch/series/view/time/1.7-24/ru_maxrss.patch
However the others are also important and useful.
Hi David,

Can you give us an idea when to expect the next upstream release of GNU Time?
David C Niemi
2015-01-21 21:30:32 UTC
Permalink
I'm trying to set GNU Time up in Git. Will let you know if I succeed.

I made a release a couple of years ago but failed to get it onto GNU's
server.

David
Post by Jim Meyering
Post by Mark Visser
Thanks, and sorry for the noise.
Post by Mark Visser
http://stackoverflow.com/questions/10035232/maximum-resident-set-size-does-not-make-sense
Post by Mark Visser
https://groups.google.com/forum/#!topic/gnu.utils.help/u1MOsHL4bhg
Yes. That is an old well known problem. The problem is that the
official GNU time maintainer isn't MIA. He will respond to email.
http://lists.gnu.org/archive/html/bug-gnu-utils/2013-02/msg00020.html
But he has never made a release.
http://ftp.gnu.org/gnu/time/
Hope springs eternal though.
I maintain patches for time-1.7 for Debian. These patches are
http://patch-tracker.debian.org/package/time/1.7-24
http://patch-tracker.debian.org/patch/series/view/time/1.7-24/rusage-portability.patch
http://patch-tracker.debian.org/patch/series/view/time/1.7-24/ru_maxrss.patch
However the others are also important and useful.
Hi David,
Can you give us an idea when to expect the next upstream release of GNU Time?
Jim Meyering
2015-01-21 23:10:36 UTC
Permalink
Post by David C Niemi
I'm trying to set GNU Time up in Git. Will let you know if I succeed.
Glad to hear it.

For a project like GNU time, savannah.gnu.org should host the primary
repository. Let me know if you'd like a hand.
Karl Berry
2015-01-21 23:52:51 UTC
Permalink
Hi David,

I'm trying to set GNU Time up in Git. Will let you know if I succeed.

On https://savannah.gnu.org/projects/time (after logging in of course),
under the "administer" part of the main group menu, choose the
option "select features".

This will take you to
https://savannah.gnu.org/project/admin/editgroupfeatures.php?group=time
(you can also go there directly)
and then you can enable git there.

After that, here is the info for using it on savannah (written by other
people, not me):
http://savannah.gnu.org/maintenance/UsingGit

I made a release a couple of years ago but failed to get it onto GNU's
server.

The basic procedure for making releases is given here:
http://www.gnu.org/prep/maintain/html_node/Automated-FTP-Uploads.html

The process is not and cannot be 100% trivial, but hundreds of people
have succeeded in navigating it. If and when you have a problem with
it, please don't give up. Just email (for example) ***@gnu.org.
All you had to do was ask and we would have tried to help. Sigh.

Karl
David C Niemi
2015-01-22 01:53:03 UTC
Permalink
Post by Jim Meyering
Post by David C Niemi
I'm trying to set GNU Time up in Git. Will let you know if I succeed.
Glad to hear it.
For a project like GNU time, savannah.gnu.org should host the primary
repository. Let me know if you'd like a hand.
Thanks for the help, Karl! There was a git checkbox I needed to check...

I think I've got it. I put in versions 1.7 and 1.7.1 (GPLv3) and they
are tagged.

You should be able to clone it:

git clone git://git.savannah.gnu.org/time.git

DCN
Jim Meyering
2015-01-22 02:11:40 UTC
Permalink
Post by David C Niemi
Post by Jim Meyering
Post by David C Niemi
I'm trying to set GNU Time up in Git. Will let you know if I succeed.
Glad to hear it.
For a project like GNU time, savannah.gnu.org should host the primary
repository. Let me know if you'd like a hand.
Thanks for the help, Karl! There was a git checkbox I needed to check...
I think I've got it. I put in versions 1.7 and 1.7.1 (GPLv3) and they are
tagged.
git clone git://git.savannah.gnu.org/time.git
Thank you.
Are you planning to make it build with modern autoconf and automake?
David C Niemi
2015-01-23 02:43:20 UTC
Permalink
Post by Jim Meyering
Thank you.
Are you planning to make it build with modern autoconf and automake?
Yes, that should be straightforward now that it is in Git.

DCN

Loading...