Date: Thu, 14 Dec 2006 13:52:05 -0500 From: "Kurt J. Lidl" <lidl@pix.net> To: freebsd-hackers@freebsd.org Subject: Re: [PATCH] "automated" make -j value Message-ID: <20061214185203.GA9701@pix.net> In-Reply-To: <20061214041952.GA7513@dragon.NUXI.org> References: <20061214041952.GA7513@dragon.NUXI.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, Dec 13, 2006 at 08:19:52PM -0800, David O'Brien wrote: > 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. > > comments? (redirected back to list) I think you can do it better than this, by just support setting the concurrancy level via reading a environmental variable. Like say "NPROC", which is what CrayOS used, and also appeared in the BSD/OS pmake varient several years ago. Then you can just do this: export NPROC=`/sbin/sysctl hw.ncpu | awk '{print $3*2}'` or this: export NPROC=`/sbin/sysctl hw.ncpu | awk '{print $3}'` in your shells .rc files. (Obviously, change the sysctl node as appropriate for your OS.) I found this really useful when compiling a large tree of sources, where some of the Makefiles didn't have their dependencies written correctly, sucht that a parallel make wouldn't work properly. It's easy to turn off, just by unsetting the environmental variable. It's also easy to iterate over a set of values to figure out which one will compile a tree the fastest. (FYI -- setting 3*hw.ncpu was optimal for BSD/OS.) If you hack on make to put in automagic around -j, you should add the environmental variable support too. It's actually more useful in a lot of cases. (Mostly cause you don't have to touch any Makefile to turn it on, it just works...) -Kurt
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20061214185203.GA9701>