From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from feline.systems ([99.23.220.214]) by ewsd; Sun Aug 12 14:21:20 EDT 2018 Date: Sun, 12 Aug 2018 18:21:04 +0000 From: BurnZeZ@feline.systems To: 9front@9front.org Subject: Re: [9front] time v4 Message-ID: In-Reply-To: <25405F882655D51BF0CC6F4729653B4F@musolino.id.au> References: <25405F882655D51BF0CC6F4729653B4F@musolino.id.au> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="upas-niptfqqzxvbavyzqtvshewmfsa" List-ID: <9front.9front.org> List-Help: X-Glyph: ➈ X-Bullshit: NoSQL hardware-scale element blockchain This is a multi-part message in MIME format. --upas-niptfqqzxvbavyzqtvshewmfsa Content-Disposition: inline Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit On Sun Aug 12 05:40:12 GMT 2018, alex@musolino.id.au wrote: > What's the point of the segattach? Can you not just add RFMEM to the > rfork flags? char output[4096]; output would be shared, and the child process uses it for the exec path stuff. I thought about using RFMEM at first, but it ended up being simpler this way. > Also, you probably ought to be setting t0 again before the second call > to exec. You would miss out on accounting for 9p latency for the first exec() attempt, but I think you’re right, since the fact that t0 is set after the fork() indicates we’re not worried about absolute time from the parent process’ perspective. Attached diff contains that change. --upas-niptfqqzxvbavyzqtvshewmfsa Content-Disposition: inline Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit diff -r 5c5acc9ab7a5 sys/src/cmd/time.c --- a/sys/src/cmd/time.c Sat Aug 11 16:19:32 2018 +0200 +++ b/sys/src/cmd/time.c Sun Aug 12 18:17:11 2018 +0000 @@ -14,20 +14,27 @@ long l; char *p; char err[ERRMAX]; + vlong *t0, t1; + enum { SEC = 1000000000ULL }; if(argc <= 1){ fprint(2, "usage: time command\n"); exits("usage"); } + if((t0 = segattach(SG_CEXEC, "shared", nil, sizeof(*t0))) == (void*)-1) + sysfatal("segattach: %r"); + *t0 = 0; switch(fork()){ case -1: error("fork"); case 0: + *t0 = nsec(); exec(argv[1], &argv[1]); if(argv[1][0] != '/' && strncmp(argv[1], "./", 2) && strncmp(argv[1], "../", 3)){ sprint(output, "/bin/%s", argv[1]); + *t0 = nsec(); exec(output, &argv[1]); } error(argv[1]); @@ -43,12 +50,14 @@ goto loop; error("wait"); } + t1 = nsec(); l = w->time[0]; add("%ld.%.2ldu", l/1000, (l%1000)/10); l = w->time[1]; add("%ld.%.2lds", l/1000, (l%1000)/10); l = w->time[2]; add("%ld.%.2ldr", l/1000, (l%1000)/10); + add("%lld.%.9lldt", (t1-*t0)/SEC, (t1-*t0)%SEC); add("\t"); for(i=1; i