Browse Source

OS-8385 smartos-live should be smarter about setting MAX_JOBS and friends

Reviewed by: Brian Bennett <brian.bennett@mnx.io>
Reviewed by: Nick Wilkens <nick.wilkens@mnxsolutions.com>
Approved by: Brian Bennett <brian.bennett@mnx.io>
pull/1044/head
Dan McDonald 7 months ago committed by GitHub
parent
commit
70fcd75c52
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      Makefile
  2. 12
      configure
  3. 3
      src/Makefile.defs
  4. 3
      tools/build_strap
  5. 41
      tools/optimize_jobs

3
Makefile

@ -11,6 +11,7 @@
#
# Copyright 2022 Joyent, Inc.
# Copyright 2022 MNX Cloud, Inc.
#
#
@ -58,7 +59,7 @@ CRIPPLED_HOST := $(shell [[ `prtconf -m 2>/dev/null || echo 999999` -lt \
ifeq ($(CRIPPLED_HOST),yes)
MAX_JOBS ?= 8
else
MAX_JOBS ?= 128
MAX_JOBS ?= $(shell tools/optimize_jobs)
endif
#

12
configure vendored

@ -13,6 +13,7 @@
#
# Copyright 2021 Joyent, Inc.
# Copyright 2022 MNX Cloud, Inc.
#
shopt -s xpg_echo
unalias -a
@ -322,10 +323,19 @@ cat > "projects/illumos/illumos.sh" <<EOF
NIGHTLY_OPTIONS="$nopts"; export NIGHTLY_OPTIONS
GATE="${RELEASE_VER}"; export GATE
CODEMGR_WS="$conf_root/projects/illumos"; export CODEMGR_WS
# NOTE: build_illumos modifies this initial constant
MAX_JOBS=128
maxjobs() {
ncpu=\`kstat -p cpu_info:::state | grep -c on-line\`
if [[ \$(( \$ncpu + 2 )) -lt \${MAX_JOBS} ]]; then
zcpucap=\`pfexec mdata-get sdc:cpu_cap\`
if [[ \$zcpucap -eq 0 || \$zcpucap == "" ]]; then
zcpu=\${MAX_JOBS}
else
zcpu=\`expr \$zcpucap / 100\`
fi
if [[ \$zcpu -lt \$ncpu ]]; then
expr \$zcpu + 2
elif [[ \$(( \$ncpu + 2 )) -lt \${MAX_JOBS} ]]; then
expr \$ncpu + 2
else
printf "%d\n" \${MAX_JOBS}

3
src/Makefile.defs

@ -19,6 +19,7 @@
# CDDL HEADER END
#
# Copyright 2020 Joyent, Inc.
# Copyright 2022 MNX Cloud, Inc.
#
#
@ -44,7 +45,7 @@ MAKE = gmake
PATH = $(NATIVEDIR)/usr/bin:/usr/bin:/usr/sbin:/sbin:/opt/local/bin
endif
MAX_JOBS = 128
MAX_JOBS ?= 128
PARALLEL = -j$(MAX_JOBS)
CSTYLE = $(BASE)/../tools/cstyle
GCC = $(NATIVEDIR)/usr/bin/gcc

3
tools/build_strap

@ -10,6 +10,7 @@
# http://www.illumos.org/license/CDDL.
#
# Copyright 2020 Joyent, Inc.
# Copyright 2022 MNX Cloud, Inc.
#
#
@ -41,7 +42,7 @@ cache_base="/opt/SmartOS/build-cache/"
srcdir="$wsroot/projects/illumos-extra"
adjunct=""
protodir=""
max_jobs="128"
max_jobs=$($wsroot/tools/optimize_jobs)
force_build="no"
tarfile=""

41
tools/optimize_jobs

@ -0,0 +1,41 @@
#!/usr/bin/bash
#
# This file and its contents are supplied under the terms of the
# Common Development and Distribution License ("CDDL"), version 1.0.
# You may only use this file in accordance with the terms of version
# 1.0 of the CDDL.
#
# A full copy of the text of the CDDL should have accompanied this
# source. A copy of the CDDL is also available via the Internet at
# http://www.illumos.org/license/CDDL.
#
#
# Copyright 2022 MNX Cloud, Inc.
#
# Start with the oldie-but-goodie 128 if it's not in the environment already.
MAX_JOBS=${MAX_JOBS:-128}
# Then let's count CPUs
ncpu=$(kstat -p cpu_info:::state | grep -c on-line)
# And our zone's cpu_cap
zcpucap=$(pfexec mdata-get sdc:cpu_cap)
if [[ $zcpucap == 0 || "$zcpucap" == "" ]]; then
# 0 cpu_cap means NO LIMIT so make it the same as MAX_JOBS.
zcpu=${MAX_JOBS}
else
zcpu=$(( $zcpucap / 100 ))
fi
if [[ $zcpu -lt $ncpu ]]; then
expr $zcpu + 2
elif [[ $(( $ncpu + 2 )) -lt ${MAX_JOBS} ]]; then
expr $ncpu + 2
else
printf "%d\n" ${MAX_JOBS}
fi
exit 0
Loading…
Cancel
Save