Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/make correct performance regression of recent change...



details:   https://anonhg.NetBSD.org/src/rev/27f198b39505
branches:  trunk
changeset: 500100:27f198b39505
user:      sommerfeld <sommerfeld%NetBSD.org@localhost>
date:      Tue Dec 05 15:20:10 2000 +0000

description:
correct performance regression of recent change from select() to
poll() for parallel make:
 - Make the poll() code behave more like the select() code: sleep for
a bit waiting for output rather than busy-wait (eww).
 - Install a no-op SIGCHLD handler so that poll/select wake up early
(with -1/EINTR) when a child exits.
 - Change the default sleep time from 500ms to 5 seconds since we now
wake up promptly when a child exits.

diffstat:

 usr.bin/make/job.c |  39 +++++++++++++++++++++++++++++++++++----
 usr.bin/make/job.h |  14 +++++++++++---
 2 files changed, 46 insertions(+), 7 deletions(-)

diffs (120 lines):

diff -r edc8d31d5d2a -r 27f198b39505 usr.bin/make/job.c
--- a/usr.bin/make/job.c        Tue Dec 05 15:09:38 2000 +0000
+++ b/usr.bin/make/job.c        Tue Dec 05 15:20:10 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: job.c,v 1.36 2000/12/04 17:45:17 christos Exp $        */
+/*     $NetBSD: job.c,v 1.37 2000/12/05 15:20:10 sommerfeld Exp $      */
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -39,14 +39,14 @@
  */
 
 #ifdef MAKE_BOOTSTRAP
-static char rcsid[] = "$NetBSD: job.c,v 1.36 2000/12/04 17:45:17 christos Exp $";
+static char rcsid[] = "$NetBSD: job.c,v 1.37 2000/12/05 15:20:10 sommerfeld 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.36 2000/12/04 17:45:17 christos Exp $");
+__RCSID("$NetBSD: job.c,v 1.37 2000/12/05 15:20:10 sommerfeld Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -309,6 +309,7 @@
 
 static int JobCondPassSig __P((ClientData, ClientData));
 static void JobPassSig __P((int));
+static void JobIgnoreSig __P((int));
 static int JobCmpPid __P((ClientData, ClientData));
 static int JobPrintCommand __P((ClientData, ClientData));
 static int JobSaveCommand __P((ClientData, ClientData));
@@ -376,6 +377,31 @@
 
 /*-
  *-----------------------------------------------------------------------
+ * JobIgnoreSig --
+ *     No-op signal handler so we wake up from poll.
+ *
+ * Results:
+ *     None.
+ *
+ * Side Effects:
+ *     None.
+ *
+ *-----------------------------------------------------------------------
+ */
+static void
+JobIgnoreSig(signo)
+    int            signo;      /* The signal number we've received */
+{
+       /*
+        * Do nothing.  The mere fact that we've been called will cause
+        * poll/select in Job_CatchOutput() to return early.
+        */
+}
+
+
+
+/*-
+ *-----------------------------------------------------------------------
  * JobPassSig --
  *     Pass a signal on to all remote jobs and to all local jobs if
  *     USE_PGRP is defined, then die ourselves.
@@ -2412,7 +2438,7 @@
                           (fd_set *) 0, &timeout)) <= 0)
            return;
 #else
-       if ((nready = poll(fds, nfds, 0)) <= 0)
+       if ((nready = poll(fds, nfds, POLL_MSEC)) <= 0)
            return;
 #endif
        else {
@@ -2543,6 +2569,11 @@
        (void) signal(SIGTERM, JobPassSig);
     }
     /*
+     * Install a NOOP  SIGCHLD handler so we are woken up if we're blocked.
+     */
+    signal(SIGCHLD, JobIgnoreSig);
+    
+    /*
      * There are additional signals that need to be caught and passed if
      * either the export system wants to be told directly of signals or if
      * we're giving each job its own process group (since then it won't get
diff -r edc8d31d5d2a -r 27f198b39505 usr.bin/make/job.h
--- a/usr.bin/make/job.h        Tue Dec 05 15:09:38 2000 +0000
+++ b/usr.bin/make/job.h        Tue Dec 05 15:20:10 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: job.h,v 1.9 2000/12/04 20:13:29 christos Exp $ */
+/*     $NetBSD: job.h,v 1.10 2000/12/05 15:20:10 sommerfeld Exp $      */
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -50,13 +50,21 @@
 
 #define TMPPAT "/tmp/makeXXXXXX"
 
+#ifdef USE_SELECT
 /*
  * The SEL_ constants determine the maximum amount of time spent in select
  * before coming out to see if a child has finished. SEL_SEC is the number of
  * seconds and SEL_USEC is the number of micro-seconds
  */
-#define SEL_SEC                0
-#define SEL_USEC       500000
+#define SEL_SEC                5
+#define SEL_USEC       0
+#else
+/*
+ * The POLL_MSEC constant determines the maximum number of milliseconds spent
+ * in poll before coming out to see if a child has finished. 
+ */
+#define POLL_MSEC      5000
+#endif
 
 
 /*-



Home | Main Index | Thread Index | Old Index