From owner-freebsd-hackers@FreeBSD.ORG Thu Dec 14 04:19:54 2006 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 0D4F716A407 for ; Thu, 14 Dec 2006 04:19:54 +0000 (UTC) (envelope-from obrien@NUXI.org) Received: from dragon.NUXI.org (trang.nuxi.org [66.93.134.19]) by mx1.FreeBSD.org (Postfix) with ESMTP id B025443C9E for ; Thu, 14 Dec 2006 04:18:20 +0000 (GMT) (envelope-from obrien@NUXI.org) Received: from dragon.NUXI.org (obrien@localhost [127.0.0.1]) by dragon.NUXI.org (8.13.8/8.13.8) with ESMTP id kBE4Jqfe009334 for ; Wed, 13 Dec 2006 20:19:52 -0800 (PST) (envelope-from obrien@dragon.NUXI.org) Received: (from obrien@localhost) by dragon.NUXI.org (8.13.8/8.13.7/Submit) id kBE4Jqvq009333 for freebsd-hackers@freebsd.org; Wed, 13 Dec 2006 20:19:52 -0800 (PST) (envelope-from obrien) Date: Wed, 13 Dec 2006 20:19:52 -0800 From: "David O'Brien" To: freebsd-hackers@freebsd.org Message-ID: <20061214041952.GA7513@dragon.NUXI.org> Mail-Followup-To: freebsd-hackers@freebsd.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Operating-System: FreeBSD 7.0-CURRENT Organization: The NUXI BSD Group X-Pgp-Rsa-Fingerprint: B7 4D 3E E9 11 39 5F A3 90 76 5D 69 58 D9 98 7A X-Pgp-Rsa-Keyid: 1024/34F9F9D5 User-Agent: Mutt/1.5.11 Subject: [PATCH] "automated" make -j value X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: freebsd-hackers@freebsd.org List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Dec 2006 04:19:54 -0000 With multi-socket systems becoming more prevalent, and the continued increase in cores per processors, I thought it would be nice for 'make -j' to gain some automation. Attached is a patch that makes "-j-" be the same as "-j `sysctl -n kern.smp.cpus`" and "-j=" be twice that. I've also thought that maybe just supporting "-j-" would be better - with a definition of num_core = `sysctl -n kern.smp.cpus` -j => MAX(num_core * 5 / 4, num_core + 1) the idea being one would want a few more jobs than cores, but not a whole lot more. comments? (redirected back to list) -- -- David (obrien@FreeBSD.org) Index: main.c =================================================================== RCS file: /home/ncvs/src/usr.bin/make/main.c,v retrieving revision 1.160 diff -u -p -r1.160 main.c --- main.c 17 Jul 2006 19:16:12 -0000 1.160 +++ main.c 14 Dec 2006 02:26:15 -0000 @@ -456,11 +456,20 @@ rearg: char *endptr; forceJobs = TRUE; + size_t jLlen = sizeof(jobLimit); jobLimit = strtol(optarg, &endptr, 10); - if (jobLimit <= 0 || *endptr != '\0') { - warnx("illegal number, -j argument -- %s", - optarg); - usage(); + if ((*optarg == '-' || *optarg == '=') && + *endptr != '\0') { + sysctlbyname("kern.smp.cpus", &jobLimit, &jLlen, + NULL, 0); + if (*optarg == '=') + jobLimit *= 2; + } else { + if (jobLimit <= 0 || *endptr != '\0') { + warnx("illegal number, -j argument -- %s", + optarg); + usage(); + } } MFLAGS_append("-j", optarg); break; Index: make.1 =================================================================== RCS file: /home/ncvs/src/usr.bin/make/make.1,v retrieving revision 1.99 diff -u -p -r1.99 make.1 --- make.1 29 Sep 2006 21:17:10 -0000 1.99 +++ make.1 14 Dec 2006 04:19:22 -0000 @@ -218,6 +218,14 @@ may have running at any one time. Turns compatibility mode off, unless the .Fl B flag is also specified. +The special values +.It Ar - +and +.It Ar = +causes +.It Ar max_jobs +to be set to the value returned from the kern.smp.cpus sysctl and twice +kern.smp.cpus respectively. .It Fl k Continue processing after errors are encountered, but only on those targets that do not depend on the target whose creation caused the error.