zsh-workers
 help / color / mirror / code / Atom feed
From: Stephane Chazelas <stephane@chazelas.org>
To: Zsh hackers list <zsh-workers@zsh.org>
Subject: wrong unit for TIMEFMT=%M
Date: Mon, 24 Feb 2020 19:40:21 +0000	[thread overview]
Message-ID: <20200224194021.kibawzliyystsu7o@chazelas.org> (raw)

TIMEFMT=%M is meant to report memory usage in KiB, but it's not the
case in Linux and FreeBSD at least.

It seems like zsh's TIMEFMT has had a tormented history.

For %M,

2.00.03 had

case 'M': fprintf(stderr,"%ld",ru->ru_maxrss); break

In 2.2, that changed to

#if sun
case 'M': fprintf(stderr,"%ld",ru->ru_maxrss*pk); break;
#else
fprintf(stderr, "%ld", ru->ru_maxrss / 1024);
#endif

(pk being the number of KiB per page).

It seemed to disappear altogether in 2.6 and came back circa
4.0.4 as 

fprintf(stderr, "%ld", ru->ru_maxrss / 1024);

GNU time's configure.ac has:

# What memory units are reported by getrusage(2) ?
warn_getrusage_mem_units=
if test -z "$time_getrusage_mem_units" ; then
  # if envvar 'time_getrusage_mem_units' isn't set,
  # autodetect based on OS.
  case "$host_os" in
    minix*|aix*|*bsd*|linux*|gnu*)
                     time_getrusage_mem_units=kb ;;

    macos*|darwin*)  time_getrusage_mem_units=bytes ;;

    solaris*)        time_getrusage_mem_units=pages ;;

    # As a fallback, assume KB (the most common value).
    # Set the 'warn' variable to warn the user at the end
    # of ./configure
    *) time_getrusage_mem_units=kb
       warn_getrusage_mem_units=yes
       ;;
  esac
fi

Suggesting zsh is only correct on macos/darwin atm.

-- 
Stephane

                 reply	other threads:[~2020-02-24 19:41 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200224194021.kibawzliyystsu7o@chazelas.org \
    --to=stephane@chazelas.org \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).