Bug 152820 - [patch] shells/zsh: correct memory report for time builtin
Summary: [patch] shells/zsh: correct memory report for time builtin
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: Normal Affects Only Me
Assignee: Baptiste Daroussin
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-12-04 03:50 UTC by swell.k
Modified: 2011-11-06 18:40 UTC (History)
0 users

See Also:


Attachments
a.diff (932 bytes, patch)
2010-12-04 03:50 UTC, swell.k
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description swell.k 2010-12-04 03:50:10 UTC
- numbers for shared/unshared space don't match those from `time -l'
- zsh manual page claims that %M stands for memory in Kbytes while it
  displays them in Mbytes

Fix: A workaround

% time xz -c /COPYRIGHT >/dev/null
56 shared 3431 unshared 3488 total 18296 maxres
How-To-Repeat: $ tcsh -f
% set time=(3 "%X shared %D unshared %K total %M maxres")
% time xz -c /COPYRIGHT >/dev/null
52 shared 3148 unshared 3200 total 8132 maxres

$ zsh -f
% TIMEFMT="%X shared %D unshared %K total %M maxres"
% time xz -c /COPYRIGHT >/dev/null
6953 shared 420930 unshared 427883 total 17 maxres

$ command time -l xz -c /COPYRIGHT >/dev/null
        0.02 real         0.00 user         0.02 sys
     17220  maximum resident set size
        78  average shared memory size
      3032  average unshared data size
       192  average unshared stack size
      4386  page reclaims
         0  page faults
         0  swaps
         0  block input operations
         1  block output operations
         0  messages sent
         0  messages received
         0  signals received
         1  voluntary context switches
         1  involuntary context switches
Comment 1 Edwin Groothuis freebsd_committer freebsd_triage 2010-12-04 03:50:17 UTC
Responsible Changed
From-To: freebsd-ports-bugs->des

Over to maintainer (via the GNATS Auto Assign Tool)
Comment 2 Dag-Erling Smørgrav freebsd_committer freebsd_triage 2010-12-07 14:53:41 UTC
State Changed
From-To: open->feedback

Patch submitted upstream
Comment 3 Baptiste Daroussin freebsd_committer freebsd_triage 2011-02-28 10:36:12 UTC
Responsible Changed
From-To: des->bapt

I'll take it.
Comment 4 Pan Tsu 2011-07-11 19:00:59 UTC
This should also work when _SC_CLK_TCK is not defined.

  http://www.zsh.org/mla/users/2010/msg00906.html

And for a value calculated using stathz see bin/78787.

--- a.diff begins here ---
Index: shells/zsh/files/patch-Src-jobs.c
===================================================================
RCS file: shells/zsh/files/patch-Src-jobs.c
diff -N shells/zsh/files/patch-Src-jobs.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ shells/zsh/files/patch-Src-jobs.c	19 Jun 2011 17:37:08 -0000
@@ -0,0 +1,47 @@
+diff --git a/Src/jobs.c b/Src/jobs.c
+index 9c9b12f..2da1d66 100644
+--- Src/jobs.c~
++++ Src/jobs.c
+@@ -586,7 +586,6 @@ setprevjob(void)
+ }
+ 
+ /**/
+-#ifndef HAVE_GETRUSAGE
+ static long clktck = 0;
+ 
+ /**/
+@@ -616,7 +615,6 @@ set_clktck(void)
+ #endif
+ }
+ /**/
+-#endif
+ 
+ /**/
+ static void
+@@ -659,14 +657,14 @@ printtime(struct timeval *real, child_times_t *ti, char *desc)
+     /* go ahead and compute these, since almost every TIMEFMT will have them */
+     elapsed_time = real->tv_sec + real->tv_usec / 1000000.0;
+ 
++    set_clktck();
+ #ifdef HAVE_GETRUSAGE
+     user_time = ti->ru_utime.tv_sec + ti->ru_utime.tv_usec / 1000000.0;
+     system_time = ti->ru_stime.tv_sec + ti->ru_stime.tv_usec / 1000000.0;
+     total_time = user_time + system_time;
+-    percent = 100.0 * total_time
+-	/ (real->tv_sec + real->tv_usec / 1000000.0);
++    percent = 100.0 * total_time / elapsed_time;
++    total_time *= (double) clktck;
+ #else
+-    set_clktck();
+     user_time    = ti->ut / (double) clktck;
+     system_time  = ti->st / (double) clktck;
+     percent      =  100.0 * (ti->ut + ti->st)
+@@ -752,7 +750,7 @@ printtime(struct timeval *real, child_times_t *ti, char *desc)
+ #endif
+ #ifdef HAVE_STRUCT_RUSAGE_RU_MAXRSS
+ 	    case 'M':
+-		fprintf(stderr, "%ld", ti->ru_maxrss / 1024);
++		fprintf(stderr, "%ld", ti->ru_maxrss);
+ 		break;
+ #endif
+ #ifdef HAVE_STRUCT_RUSAGE_RU_MAJFLT
--- a.diff ends here ---
Comment 5 dfilter service freebsd_committer freebsd_triage 2011-11-06 18:35:15 UTC
bapt        2011-11-06 18:35:06 UTC

  FreeBSD ports repository

  Modified files:
    shells/zsh           Makefile 
  Log:
  - split the zsh_mem option into zsh_mem and zsh_secure_free activate secure_free my default disable mem by default[1]
  - correct memory report for time builtin [2]
  - bump portrevision
  
  PR:             ports/143981 [1], ports/152820 [2]
  Submitted by:   Richard Kolkovich <sarumont@sigil.org> [1], Anonymous <swell.k@gmail.com> and Tsu <inyaoo@gmail.com> [2]
  Hurried by:     miwi :)
  
  Revision  Changes    Path
  1.129     +19 -8     ports/shells/zsh/Makefile
_______________________________________________
cvs-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/cvs-all
To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
Comment 6 Baptiste Daroussin freebsd_committer freebsd_triage 2011-11-06 18:36:19 UTC
State Changed
From-To: feedback->closed

Committed. Thanks!