From 6f073e6a806acd35df0064531e93c5c739afe7e0 Mon Sep 17 00:00:00 2001 From: Andy Fiddaman Date: Tue, 13 Feb 2024 16:28:14 +0000 Subject: [PATCH 1/2] buildctl would never find enough expensive slots at end of run --- build/buildctl | 49 ++++++++++++++++++++++++++++++------------------- 1 file changed, 30 insertions(+), 19 deletions(-) diff --git a/build/buildctl b/build/buildctl index 663e7fdcf..5c9b0f48a 100755 --- a/build/buildctl +++ b/build/buildctl @@ -465,30 +465,28 @@ clear_slots() { nextslot= wait_for_slot() { - # Check for any idle slots - for i in `seq 0 $threads`; do - [ -z "${slots[$i]}" ] && nextslot=$i && return - done - - typeset slot= typeset -i stat=0 + typeset slot= + typeset pid= # Wait for a slot to terminate while :; do wait -fn -p pid ${slots[*]} stat=$? - (( stat == 169 )) && continue # SIGINFO - (( stat == 141 )) && continue # SIGPIPE - (( stat == 144 )) && nextslot= && return # SIGUSR1 - if (( stat == 127 )); then # No jobs left - clear_slots $stat - nextslot=0 - return - fi + case $stat in + 169) continue ;; # SIGINFO + 141) continue ;; # SIGPIPE + 144) nextslot=; return ;; # SIGUSR1 + 127) # No jobs left + clear_slots $stat + nextslot=0 + return ;; + esac + [ -n "$pid" ] || continue slot=${slotpid[$pid]} [ -n "$slot" ] && break - logmsg -n "Unknown pid $pid terminated $s" + logmsg -n "Unknown pid $pid terminated $stat" done if reap_slot $slot $stat; then @@ -500,6 +498,21 @@ wait_for_slot() { fi } +find_slot() { + # Check for any idle slots + for i in `seq 0 $threads`; do + [ -z "${slots[$i]}" ] && nextslot=$i && return + done + + wait_for_slot +} + +wait_for_expensive_slot() { + while (( `count_expensive` > ETHROTTLE )); do + wait_for_slot + done +} + wait_for_jobs() { local msg="$1" @@ -676,9 +689,7 @@ parallel_build() { # number of expensive jobs has dropped low enough. if [ $newloc -le 0 -o ${#queue[@]} -le ${#expensive[@]} ]; then logmsg -n "-- $tgt, waiting for number of jobs to drop" - while [ `count_expensive` -gt $ETHROTTLE ]; do - wait_for_slot - done + wait_for_expensive_slot else logmsg -n "-- $tgt, relocating to $newloc/${#queue[@]}" _queue=("${queue[@]:0:newloc}") @@ -694,7 +705,7 @@ parallel_build() { if [ -z "$nextslot" ]; then logmsg "-- Waiting for spare job slot for $tgt" - wait_for_slot + find_slot [ -n "$nextslot" ] || break fi From 8036aa0a82bc75a5ff5099d92dc11de44234c14e Mon Sep 17 00:00:00 2001 From: Andy Fiddaman Date: Tue, 13 Feb 2024 17:29:43 +0000 Subject: [PATCH 2/2] Add support for a mirror cache directory to speed things up --- lib/functions.sh | 19 ++++++++++++++++--- lib/site.sh.template | 4 ++++ 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/lib/functions.sh b/lib/functions.sh index d1a9fd3fd..13a8bc37c 100644 --- a/lib/functions.sh +++ b/lib/functions.sh @@ -1321,11 +1321,24 @@ patch_source() { # $1 - resource to get # get_resource() { - local RESOURCE=$1 - case ${MIRROR:0:1} in - /) logcmd $CP $MIRROR/$RESOURCE . ;; + typeset RESOURCE="$1" + + if [ -n "$MIRRORCACHE" -a -f "$MIRRORCACHE/$RESOURCE" ]; then + logcmd $CP $MIRRORCACHE/$RESOURCE . && return + fi + + case $MIRROR in + /*) logcmd $CP $MIRROR/$RESOURCE . ;; *) $WGET -a $LOGFILE $MIRROR/$RESOURCE ;; esac + typeset -i stat=$? + + if ((stat == 0)) && [ -n "$MIRRORCACHE" ]; then + logcmd $MKDIR -p $MIRRORCACHE/${RESOURCE%/*} + logcmd $CP ${RESOURCE##*/} $MIRRORCACHE/${RESOURCE%/*} + fi + + return $stat } set_checksum() { diff --git a/lib/site.sh.template b/lib/site.sh.template index 96924ea53..cb0652aba 100644 --- a/lib/site.sh.template +++ b/lib/site.sh.template @@ -8,6 +8,10 @@ # The web server or local directory from which source files are fetched. #MIRROR=https://mirrors.omnios.org +# A directory used to cache files downloaded from the $MIRROR for use in +# subsequent builds. +#MIRRORCACHE=/tmp/mirror.cache + # Package publisher #PKGPUBLISHER=extra.omnios