Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/make Skip setting wantToken.



details:   https://anonhg.NetBSD.org/src/rev/0768bdd4abfe
branches:  trunk
changeset: 322694:0768bdd4abfe
user:      sjg <sjg%NetBSD.org@localhost>
date:      Sat May 12 18:17:04 2018 +0000

description:
Skip setting wantToken.

polling the job token pipe adds a lot of overhead
for little gain.
For now, just leave wantToken=0

And avoid busy waiting when no tokens are available and
no jobs are running.

Reviewed by: christos

diffstat:

 usr.bin/make/job.c |  13 +++++++------
 1 files changed, 7 insertions(+), 6 deletions(-)

diffs (45 lines):

diff -r 62b2987d2ab4 -r 0768bdd4abfe usr.bin/make/job.c
--- a/usr.bin/make/job.c        Sat May 12 15:14:49 2018 +0000
+++ b/usr.bin/make/job.c        Sat May 12 18:17:04 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: job.c,v 1.192 2018/02/08 09:05:21 dholland Exp $       */
+/*     $NetBSD: job.c,v 1.193 2018/05/12 18:17:04 sjg Exp $    */
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -70,14 +70,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: job.c,v 1.192 2018/02/08 09:05:21 dholland Exp $";
+static char rcsid[] = "$NetBSD: job.c,v 1.193 2018/05/12 18:17:04 sjg Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)job.c      8.2 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: job.c,v 1.192 2018/02/08 09:05:21 dholland Exp $");
+__RCSID("$NetBSD: job.c,v 1.193 2018/05/12 18:17:04 sjg Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -2944,14 +2944,15 @@
     count = read(tokenWaitJob.inPipe, &tok, 1);
     if (count == 0)
        Fatal("eof on job pipe!");
-    if (count < 0 && jobTokensRunning != 0) {
+    if (count < 0) {
        if (errno != EAGAIN) {
            Fatal("job pipe read: %s", strerror(errno));
        }
        if (DEBUG(JOB))
            fprintf(debug_file, "(%d) blocked for token\n", getpid());
-       wantToken = 1;
-       return FALSE;
+       if (jobTokensRunning)
+           return FALSE;
+       sleep(1);                       /* avoid busy wait */
     }
 
     if (count == 1 && tok != '+') {



Home | Main Index | Thread Index | Old Index