diff options
author | dim <dim@FreeBSD.org> | 2014-04-09 18:16:58 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2014-04-09 18:16:58 +0000 |
commit | b4a5074609596d4c75b32b490d963dc14253a22c (patch) | |
tree | 4b992e8161752c70ae2b6d92e7d5fdbf5ce3e021 | |
parent | fa4bb9196626b91d892d8087912e76ef97bd6f81 (diff) | |
download | FreeBSD-src-b4a5074609596d4c75b32b490d963dc14253a22c.zip FreeBSD-src-b4a5074609596d4c75b32b490d963dc14253a22c.tar.gz |
MFC r263778:
Add a SUBDIR_PARALLEL option to bsd.subdir.mk, to allow make to process
all the SUBDIR entries in parallel, instead of serially. Apply this
option to a selected number of Makefiles, which can greatly speed up the
build on multi-core machines, when using make -j.
This can be extended to more Makefiles later on, whenever they are
verified to work correctly with parallel building.
I tested this on a 24-core machine, with make -j48 buildworld (N = 6):
before stddev after stddev
======= ====== ======= ======
real time 1741.1 16.5 959.8 2.7
user time 12468.7 16.4 14393.0 16.8
sys time 1825.0 54.8 2110.6 22.8
(user+sys)/real 8.2 17.1
E.g. the build was approximately 45% faster in real time. On machines
with less cores, or with lower -j settings, the speedup will not be as
impressive. But at least you can now almost max out a machine with
buildworld!
Submitted by: jilles
MFC r263833:
Enable parallel building for gnu/usr.bin and usr.bin/clang too.
-rw-r--r-- | bin/Makefile | 2 | ||||
-rw-r--r-- | gnu/usr.bin/Makefile | 2 | ||||
-rw-r--r-- | lib/Makefile | 4 | ||||
-rw-r--r-- | lib/clang/Makefile | 2 | ||||
-rw-r--r-- | sbin/Makefile | 2 | ||||
-rw-r--r-- | share/mk/bsd.subdir.mk | 19 | ||||
-rw-r--r-- | usr.bin/Makefile | 2 | ||||
-rw-r--r-- | usr.bin/clang/Makefile | 2 | ||||
-rw-r--r-- | usr.sbin/Makefile | 2 |
9 files changed, 37 insertions, 0 deletions
diff --git a/bin/Makefile b/bin/Makefile index e4bc281..63d96fe 100644 --- a/bin/Makefile +++ b/bin/Makefile @@ -60,4 +60,6 @@ SUBDIR+= tests SUBDIR:= ${SUBDIR:O} +SUBDIR_PARALLEL= + .include <bsd.subdir.mk> diff --git a/gnu/usr.bin/Makefile b/gnu/usr.bin/Makefile index 663107c..02d0b2a 100644 --- a/gnu/usr.bin/Makefile +++ b/gnu/usr.bin/Makefile @@ -46,4 +46,6 @@ _cc= cc _gdb= gdb .endif +SUBDIR_PARALLEL= + .include <bsd.subdir.mk> diff --git a/lib/Makefile b/lib/Makefile index 22f3414..ab6c579 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -271,4 +271,8 @@ afterinstall: ${INSTALL_SYMLINK} ../include ${DESTDIR}/usr/lib/include .endif +.if !make(install) +SUBDIR_PARALLEL= +.endif + .include <bsd.subdir.mk> diff --git a/lib/clang/Makefile b/lib/clang/Makefile index 8b6f385..d335d80 100644 --- a/lib/clang/Makefile +++ b/lib/clang/Makefile @@ -147,4 +147,6 @@ SUBDIR+=liblldb \ SUBDIR+= include +SUBDIR_PARALLEL= + .include <bsd.subdir.mk> diff --git a/sbin/Makefile b/sbin/Makefile index 4772844..c6c3786 100644 --- a/sbin/Makefile +++ b/sbin/Makefile @@ -118,4 +118,6 @@ SUBDIR+= routed SUBDIR:= ${SUBDIR:O} +SUBDIR_PARALLEL= + .include <bsd.subdir.mk> diff --git a/share/mk/bsd.subdir.mk b/share/mk/bsd.subdir.mk index 12dd4de..0ceda56 100644 --- a/share/mk/bsd.subdir.mk +++ b/share/mk/bsd.subdir.mk @@ -71,7 +71,26 @@ ${SUBDIR}: .PHONY .MAKE .for __target in all all-man checkdpadd clean cleandepend cleandir \ cleanilinks depend distribute lint maninstall manlint obj objlink \ realinstall regress tags ${SUBDIR_TARGETS} +.ifdef SUBDIR_PARALLEL +.for __dir in ${SUBDIR} +${__target}: ${__target}_subdir_${__dir} +${__target}_subdir_${__dir}: .MAKE + @${_+_}set -e; \ + if test -d ${.CURDIR}/${__dir}.${MACHINE_ARCH}; then \ + ${ECHODIR} "===> ${DIRPRFX}${__dir}.${MACHINE_ARCH} (${__target:realinstall=install})"; \ + edir=${__dir}.${MACHINE_ARCH}; \ + cd ${.CURDIR}/$${edir}; \ + else \ + ${ECHODIR} "===> ${DIRPRFX}${__dir} (${__target:realinstall=install})"; \ + edir=${__dir}; \ + cd ${.CURDIR}/$${edir}; \ + fi; \ + ${MAKE} ${__target:realinstall=install} \ + DIRPRFX=${DIRPRFX}$$edir/ +.endfor +.else ${__target}: _SUBDIR +.endif .endfor .for __target in files includes diff --git a/usr.bin/Makefile b/usr.bin/Makefile index 0a6145b..be3f95b 100644 --- a/usr.bin/Makefile +++ b/usr.bin/Makefile @@ -376,4 +376,6 @@ SUBDIR+= svn SUBDIR:= ${SUBDIR:O} +SUBDIR_PARALLEL= + .include <bsd.subdir.mk> diff --git a/usr.bin/clang/Makefile b/usr.bin/clang/Makefile index f0ab065..f3e2957 100644 --- a/usr.bin/clang/Makefile +++ b/usr.bin/clang/Makefile @@ -29,4 +29,6 @@ SUBDIR+=lldb .endif .endif # TOOLS_PREFIX +SUBDIR_PARALLEL= + .include <bsd.subdir.mk> diff --git a/usr.sbin/Makefile b/usr.sbin/Makefile index 5f275a6..f809688 100644 --- a/usr.sbin/Makefile +++ b/usr.sbin/Makefile @@ -324,4 +324,6 @@ SUBDIR+= wpa SUBDIR:= ${SUBDIR:O} +SUBDIR_PARALLEL= + .include <bsd.subdir.mk> |