From owner-svn-src-user@freebsd.org Sat Sep 12 23:04:14 2020 Return-Path: Delivered-To: svn-src-user@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 811833E5070 for ; Sat, 12 Sep 2020 23:04:14 +0000 (UTC) (envelope-from gordon@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Bpp8t2pbvz4d5J; Sat, 12 Sep 2020 23:04:14 +0000 (UTC) (envelope-from gordon@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 43C591CC08; Sat, 12 Sep 2020 23:04:14 +0000 (UTC) (envelope-from gordon@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 08CN4E7P019134; Sat, 12 Sep 2020 23:04:14 GMT (envelope-from gordon@FreeBSD.org) Received: (from gordon@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 08CN4EKj019133; Sat, 12 Sep 2020 23:04:14 GMT (envelope-from gordon@FreeBSD.org) Message-Id: <202009122304.08CN4EKj019133@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gordon set sender to gordon@FreeBSD.org using -f From: Gordon Tetlow Date: Sat, 12 Sep 2020 23:04:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r365674 - user/cperciva/freebsd-update-build X-SVN-Group: user X-SVN-Commit-Author: gordon X-SVN-Commit-Paths: user/cperciva/freebsd-update-build X-SVN-Commit-Revision: 365674 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 12 Sep 2020 23:04:14 -0000 Author: gordon Date: Sat Sep 12 23:04:13 2020 New Revision: 365674 URL: https://svnweb.freebsd.org/changeset/base/365674 Log: Add parallelization. Use a couple of simple shell constructs to monitor the number of jobs running at any given time and if we exceed the maximum (based on CPUs since this is a CPU bound process), we sleep and recheck if any of our children have finished. Modified: user/cperciva/freebsd-update-build/build-upgrade-patches.sh Modified: user/cperciva/freebsd-update-build/build-upgrade-patches.sh ============================================================================== --- user/cperciva/freebsd-update-build/build-upgrade-patches.sh Sat Sep 12 21:50:25 2020 (r365673) +++ user/cperciva/freebsd-update-build/build-upgrade-patches.sh Sat Sep 12 23:04:13 2020 (r365674) @@ -12,6 +12,21 @@ OLDRELS=$3 WWWDIR=${BASEDIR}/pub +MAXJOBS=$(( $(sysctl -n hw.ncpu) - 2 )) +if [ $MAXJOBS -lt 1 ]; then + MAXJOBS=1 +fi + +genpatch() { + tempdir=$(mktemp -d -t genpatch) + + gunzip < ${WWWDIR}/${OR}/${ARCH}/f/${OH}.gz > ${tempdir}/${OH} + gunzip < ${WWWDIR}/${NR}/${ARCH}/f/${NH}.gz > ${tempdir}/${NH} + bsdiff ${tempdir}/${OH} ${tempdir}/${NH} ${WWWDIR}/to-${TARGETREL}/${ARCH}/bp/${OH}-${NH} + rm ${tempdir}/${OH} ${tempdir}/${NH} + rmdir ${tempdir} +} + mkdir -p ${WWWDIR}/to-${TARGETREL}/${ARCH}/bp/ for V in ${OLDRELS}; do zcat ${WWWDIR}/${V}/${ARCH}/m/* | @@ -43,10 +58,17 @@ zcat ${WWWDIR}/${TARGETREL}/${ARCH}/m/* | if [ ${OH} = ${NH} ]; then continue fi - gunzip < ${WWWDIR}/${OR}/${ARCH}/f/${OH}.gz > ${OH} - gunzip < ${WWWDIR}/${NR}/${ARCH}/f/${NH}.gz > ${NH} - bsdiff ${OH} ${NH} ${WWWDIR}/to-${TARGETREL}/${ARCH}/bp/${OH}-${NH} - rm ${OH} ${NH} + + genpatch & + + jobs="$(jobs)" + numjobs=$(echo "$jobs" | wc -l) + while [ $numjobs -ge $MAXJOBS ]; do + sleep 2 + + jobs="$(jobs)" + numjobs=$(echo "$jobs" | wc -l) + done done rm hashtab