NetBSD Problem Report #18895

Received: (qmail 17588 invoked by uid 605); 2 Nov 2002 18:22:45 -0000
Message-Id: <200211021822.gA2IMgd01760@guava.araneus.fi>
Date: Sat, 2 Nov 2002 10:22:42 -0800 (PST)
From: gson@gson.org
Sender: gnats-bugs-owner@netbsd.org
Reply-To: gson@gson.org
To: gnats-bugs@gnats.netbsd.org
Cc: Julio Merino <jmmv@menta.net>, David Laight <david@l8s.co.uk>
Subject: make -j pauses between jobs
X-Send-Pr-Version: 3.95

>Number:         18895
>Category:       bin
>Synopsis:       make -j pauses between jobs
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Nov 02 18:23:00 +0000 2002
>Closed-Date:    Sat Nov 16 22:28:46 +0000 2002
>Last-Modified:  Sat Nov 16 22:28:46 +0000 2002
>Originator:     Andreas Gustafsson
>Release:        NetBSD 1.6I (-current as of Oct 20, 2002)
>Organization:
Speaking for myself
>Environment:
System: NetBSD guava.araneus.fi 1.6I NetBSD 1.6I (GUAVAMP) #1: Sun Oct 6 19:38:50 PDT 2002 gson@guava.araneus.fi:/usr/src/sys/arch/i386.sp/compile/GUAVAMP i386
Architecture: i386
Machine: i386
>Description:

When running build.sh -j N where N >= 2, the build sometimes pauses
for several seconds, leaving the CPU(s) idle.

I am seeing this behavior on a dual AMD Athlon 1800 with "-j 2", and
Julio Merino <jmmv@menta.net> reported seeing similar behavior on a
uniprocessor with "-j 4".  See the discussion under the subject
"Strange behavior with build.sh -j 4" on current-users.

When this happens, the make process is sleeping in the poll() call in
/usr/src/usr.bin/make/job.c, and the poll() only returns when its
timeout expires after five seconds.

My theory as to the cause of this problem is that there is a race
condition in make where it fails to detect a job exiting if it happens
so quickly that the SIGCHLD gets delivered before it enters poll().
It is also possible that kern/17517 could have something to do with
this.

>How-To-Repeat:

Run "build.sh -j 2" on a fast machine.  Observe the pauses in the make
output, or run "vmstat 1" in a different windows and observe periods
of 100% idle.  Optionally, increase the value of POLL_MSEC in
/usr/src/usr.bin/make/job.h to 60000 or so first to make the pauses
even more noticeable.

>Fix:

Make the SIGCHLD signal handler write a message to a pipe which is
included in the poll(), and/or fix kern/17517.
>Release-Note:
>Audit-Trail:

From: gson@gson.org (Andreas Gustafsson)
To: Julio Merino <jmmv@menta.net>, David Laight <david@l8s.co.uk>
Cc: gnats-bugs@gnats.netbsd.org
Subject: Re: bin/18895: make -j pauses between jobs
Date: Sun, 3 Nov 2002 18:49:43 -0800 (PST)

 I now have a tentative patch at
 http://www.araneus.fi/gson/netbsd/bugs/18895/job.c.diff.
 Julio, could you try it and see if it helps?

 It seems to work fine on my system but currently requires poll() (it
 will not work with -DUSE_SELECT).  I plan to fix that by adding code
 to emulate poll() in terms of select() on systems that lack poll().

 Here are some numbers on how long it takes to build a NetBSD/i386
 release on a dual AMD Athlon 1800+ with different versions of make
 and -j options:

   without patch, without -j	 6584 s
   without patch, -j 2		 9051 s (!)
   with patch, -j 2		 4024 s
   with patch, -j 3		 3970 s

 -- 
 Andreas Gustafsson, gson@gson.org

From: gson@gson.org (Andreas Gustafsson)
To: Julio Merino <jmmv@menta.net>, David Laight <david@l8s.co.uk>
Cc: gnats-bugs@gnats.netbsd.org
Subject: Re: bin/18895: make -j pauses between jobs
Date: Sun, 10 Nov 2002 09:23:02 -0800 (PST)

 A new patch which restores the -DUSE_SELECT functionality is now at
 <http://www.araneus.fi/gson/netbsd/bugs/18895/diff2>.  If no one
 objects, I will commit it.
 -- 
 Andreas Gustafsson, gson@gson.org
State-Changed-From-To: open->closed 
State-Changed-By: gson 
State-Changed-When: Sat Nov 16 14:27:29 PST 2002 
State-Changed-Why:  
Patch committed (job.c 1.73, job.h 1.17). 
>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.