Update jobs.mk to leverage -jC

With bmake-20230909 we can use -j1.5C to use 1.5*ncpu
bmake will set .MAKE.JOBS.C=yes if this is supported,
and in that case jobs.mk will use JOB_MAX_C as default for JOB_MAX.

Remove logic from local.sys.mk which is now handled by jobs.mk

Also use latest dirdeps-targets.mk and meta.{autodep,subdir}.mk
This commit is contained in:
Simon J. Gerraty 2023-09-18 11:40:07 -07:00
parent b57df6fbcc
commit 40b9b2995f
5 changed files with 32 additions and 38 deletions

View file

@ -1,5 +1,5 @@
# RCSid:
# $Id: dirdeps-targets.mk,v 1.24 2020/12/11 18:15:43 sjg Exp $
# $Id: dirdeps-targets.mk,v 1.25 2023/05/11 05:07:28 sjg Exp $
#
# @(#) Copyright (c) 2019-2020 Simon J. Gerraty
#
@ -113,16 +113,17 @@ tqtdeps := ${DIRDEPS_TARGETS_MACHINE_LIST:@m@${tdeps:M*.$m,*}@:S,/${.MAKE.DEPEND
.endif
# now work out what we want in DIRDEPS
DIRDEPS = ${ptdeps}
.if empty(REQUESTED_MACHINE)
# we want them all just as found
DIRDEPS = ${ptdeps} ${mqtdeps} ${tqtdeps}
DIRDEPS += ${mqtdeps} ${tqtdeps}
.else
# we only want those that match REQUESTED_MACHINE/REQUESTED_TARGET_SPEC
# or REQUESTED_TARGET_SPEC (TARGET_SPEC)
DIRDEPS = \
${ptdeps:@d@$d.${REQUESTED_TARGET_SPEC:U${TARGET_SPEC:U${REQUESTED_MACHINE}}}@} \
DIRDEPS += \
${mqtdeps:M*.${REQUESTED_MACHINE}} \
${tqtdeps:M*.${REQUESTED_TARGET_SPEC:U${TARGET_SPEC}}}
${tqtdeps:M*.${REQUESTED_TARGET_SPEC:U${TARGET_SPEC}}} \
.endif
# clean up
DIRDEPS := ${DIRDEPS:O:u}

View file

@ -1,4 +1,4 @@
# $Id: jobs.mk,v 1.9 2023/04/27 18:10:27 sjg Exp $
# $Id: jobs.mk,v 1.14 2023/09/11 16:52:44 sjg Exp $
#
# @(#) Copyright (c) 2012-2023, Simon J. Gerraty
#
@ -29,11 +29,14 @@
#
# ${MAKE} -j${JOB_MAX} target > ${JOB_LOGDIR}/target.log 2>&1
#
# JOB_MAX defaults to 8 but should normally be derrived based on the
# number of cpus available. The wrapper script 'mk' makes that easy.
# JOB_MAX should be something like 1.2 - 1.5 times the number of
# available CPUs.
# If bmake sets .MAKE.JOBS.C=yes we can use -jC and
# JOB_MAX defaults to JOB_MAX_C (default 1.33C).
# Otherwise we use 8.
#
now_utc ?= ${%s:L:gmtime}
now_utc ?= ${%s:L:localtime}
.if !defined(start_utc)
start_utc := ${now_utc}
.endif
@ -70,14 +73,19 @@ NEWLOG = :
.endif
.if ${.MAKE.JOBS:U0} > 0
JOB_MAX= ${.MAKE.JOBS}
JOB_MAX = ${.MAKE.JOBS}
.else
# This should be derrived from number of cpu's
JOB_MAX?= 8
JOB_ARGS+= -j${JOB_MAX}
.if ${.MAKE.JOBS.C:Uno} == "yes"
# 1.2 - 1.5 times nCPU works well on most machines that support -jC
JOB_MAX_C ?= 1.33C
JOB_MAX ?= ${JOB_MAX_C}
.endif
JOB_MAX ?= 8
JOB_ARGS += -j${JOB_MAX}
.endif
# we need to reset .MAKE.LEVEL to 0 do that
# we need to reset .MAKE.LEVEL to 0 so that
# build orchestration works as expected (DIRDEPS_BUILD)
${.TARGETS:M*-jobs}:
@${NEWLOG} ${JOB_NEWLOG_ARGS} ${JOB_LOG}

View file

@ -58,26 +58,6 @@ _PREMK_LIBDIR:= ${LIBDIR}
.include "src.sys.mk"
.-include <site.sys.mk>
.if make(*-jobs) && empty(JOB_MAX)
# provide a reasonable? default for JOB_MAX based on ncpu
JOB_MAX_FACTOR?= 1.33
NPROC?= ${(type nproc || true) 2> /dev/null:L:sh:M/*:[1]}
NPROC:= ${NPROC}
.if !empty(NPROC)
ncpu!= ${NPROC}
.elif ${.MAKE.OS:NDarwin:NFreeBSD} == ""
ncpu!= sysctl -n hw.ncpu
.endif
.if ${ncpu:U0} > 1
.if ${JOB_MAX_FACTOR} == 1
JOB_MAX:= ${ncpu}
.else
jm!= echo ${ncpu} \* ${JOB_MAX_FACTOR} | bc
JOB_MAX:= ${jm:R}
.endif
.endif
.endif
# this will be set via local.meta.sys.env.mk if appropriate
MK_host_egacy?= no

View file

@ -1,4 +1,4 @@
# $Id: meta.autodep.mk,v 1.56 2022/09/09 17:44:29 sjg Exp $
# $Id: meta.autodep.mk,v 1.59 2023/08/19 17:35:32 sjg Exp $
#
# @(#) Copyright (c) 2010, Simon J. Gerraty
@ -139,6 +139,10 @@ FORCE_DPADD += ${_nonlibs:@x@${DPADD:M*/$x}@}
.END: gendirdeps
.endif
.if ${LOCAL_DEPENDS_GUARD:U} == "no"
.depend:
.endif
# if we don't have OBJS, then .depend isn't useful
.if !target(.depend) && (!empty(OBJS) || ${.ALLTARGETS:M*.o} != "")
# some makefiles and/or targets contain
@ -206,7 +210,8 @@ _depend =
.endif
.if ${UPDATE_DEPENDFILE} == "yes"
gendirdeps: ${_DEPENDFILE}
gendirdeps: beforegendirdeps .WAIT ${_DEPENDFILE}
beforegendirdeps:
.endif
.if !target(${_DEPENDFILE})
@ -300,7 +305,7 @@ ${_DEPENDFILE}: .PRECIOUS
CLEANFILES += *.meta filemon.* *.db
# these make it easy to gather some stats
now_utc = ${%s:L:gmtime}
now_utc = ${%s:L:localtime}
start_utc := ${now_utc}
meta_stats= meta=${empty(.MAKE.META.FILES):?0:${.MAKE.META.FILES:[#]}} \

View file

@ -1,4 +1,4 @@
# $Id: meta.subdir.mk,v 1.12 2020/08/19 17:51:53 sjg Exp $
# $Id: meta.subdir.mk,v 1.13 2021/01/05 22:24:37 sjg Exp $
#
# @(#) Copyright (c) 2010, Simon J. Gerraty
@ -17,7 +17,7 @@
.if !defined(NO_SUBDIR) && !empty(SUBDIR)
.if make(destroy*) || make(clean*)
.MAKE.MODE = compat
.if !commands(destroy)
.if !commands(obj)
.-include <bsd.obj.mk>
.endif
.elif ${.MAKE.LEVEL} == 0