From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from feline.systems ([99.23.220.214]) by ewsd; Sun Aug 12 16:49:10 EDT 2018 Date: Sun, 12 Aug 2018 20:49:02 +0000 From: BurnZeZ@feline.systems To: 9front@9front.org Subject: Re: [9front] time Message-ID: In-Reply-To: References: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="upas-dzvlzqgjjyomjlnjjwcsuttdzz" List-ID: <9front.9front.org> List-Help: X-Glyph: ➈ X-Bullshit: extension-based base firewall-scale optimizer This is a multi-part message in MIME format. --upas-dzvlzqgjjyomjlnjjwcsuttdzz Content-Disposition: inline Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit On Sun Aug 12 19:11:59 GMT 2018, cinap_lenrek@felloff.net wrote: > this sucks. burnzez talked to me explaining the lack of > resolution of kernel process time accounting but no context > has been given in this patch. This patch is unrelated to the accounting resolution issues. Process-level accounting will never consider the time it takes to exec(), which ends up being important when the latency itself can unexpectedly (even sporadically) be an order of magnitude higher than the accounted execution time of the program. > as for the patch... no. i dont like it. its a kludgy work > arround, not addressing the problem. and i dont see why you > need segattach() at all. Yeah, segattach isn’t necessary, but seemed the most straightforward thing. The child process also makes use of that ‘output’ array. sprint(output, "/bin/%s", argv[1]); If RFMEM is used when rfork is called, then would it make sense to: ∙ define another array ∙ use smprint() instead of sprint ∙ set output[0] to NUL and proceed The last one makes the most sense to me, but that doesn’t mean it’s not retarded for some reason. Attached diff shows how I would do it without segattach(), but I’m not confident it’s correct. (also removed the 2nd t0 assignment, as I realized that a latency spike during the first exec() would be overlooked) --upas-dzvlzqgjjyomjlnjjwcsuttdzz 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 20:40:19 2018 +0000 @@ -2,6 +2,7 @@ #include char output[4096]; +vlong t0, t1; void add(char*, ...); void error(char*); void notifyf(void*, char*); @@ -14,16 +15,18 @@ long l; char *p; char err[ERRMAX]; + enum { SEC = 1000000000ULL }; if(argc <= 1){ fprint(2, "usage: time command\n"); exits("usage"); } - switch(fork()){ + switch(rfork(RFFDG|RFREND|RFPROC|RFMEM)){ 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)){ @@ -43,12 +46,15 @@ goto loop; error("wait"); } + t1 = nsec(); + output[0] = '\0'; 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