aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick Ohly <patrick.ohly@intel.com>2016-11-16 08:39:19 +0100
committerPatrick Ohly <patrick.ohly@intel.com>2016-12-08 14:12:56 +0100
commit048b6b7aaa75eeac706073e300584b081fd42dc9 (patch)
tree7c86c09709bf1556976539dd097fe5ee762d24c0
parentafe7643a8f43c84273f88d86c42bbce767e97ec4 (diff)
downloadmeta-swupd-048b6b7aaa75eeac706073e300584b081fd42dc9.tar.gz
meta-swupd-048b6b7aaa75eeac706073e300584b081fd42dc9.tar.bz2
meta-swupd-048b6b7aaa75eeac706073e300584b081fd42dc9.zip
do_swupd_update: run swupd_make_pack in parallel
Internally, swupd_make_pack mostly just spends its time on a single CPU while compressing a large .tar archive. We can shorten the overall execution time by running swupd_make_pack invocations in parallel. The current approach just runs all of them at once. This might overload small machines or larger ones when the number of bundles increases, so some more intelligence might be needed. Depends on a fix for background processes in the bitbake shell parser (YOCTO #10668). Signed-off-by: Patrick Ohly <patrick.ohly@intel.com>
-rw-r--r--classes/swupd-image.bbclass26
1 files changed, 18 insertions, 8 deletions
diff --git a/classes/swupd-image.bbclass b/classes/swupd-image.bbclass
index 783aca9..ba6b98e 100644
--- a/classes/swupd-image.bbclass
+++ b/classes/swupd-image.bbclass
@@ -390,6 +390,14 @@ END
time env $PSEUDO "$@"
}
+ waitall () {
+ while [ $# -gt 0 ]; do
+ pid=$1
+ shift
+ wait $pid
+ done
+ }
+
${SWUPD_LOG_FN} "Generating update from $PREVREL to ${OS_VERSION}"
# env $PSEUDO bsdtar -acf ${DEPLOY_DIR}/swupd-before-create-update.tar.gz -C ${DEPLOY_DIR} swupd
invoke_swupd ${STAGING_BINDIR_NATIVE}/swupd_create_update --log-stdout -S ${DEPLOY_DIR_SWUPD} --osversion ${OS_VERSION} --format ${SWUPD_FORMAT}
@@ -406,15 +414,19 @@ END
${SWUPD_LOG_FN} "Generating zero packs, this can take some time."
# env $PSEUDO bsdtar -acf ${DEPLOY_DIR}/swupd-before-make-zero-pack.tar.gz -C ${DEPLOY_DIR} swupd
+ # Generating zero packs isn't parallelized internally. Mostly it just
+ # spends its time compressing a single tar archive. Therefore we parallelize
+ # by forking each command and then waiting for all of them to complete.
+ jobs=""
for bndl in ${ALL_BUNDLES}; do
${SWUPD_LOG_FN} "Generating zero pack for $bndl"
- invoke_swupd ${STAGING_BINDIR_NATIVE}/swupd_make_pack --log-stdout -S ${DEPLOY_DIR_SWUPD} 0 ${OS_VERSION} $bndl
# The zero packs are used by the swupd client when adding bundles.
# The zero pack for os-core is not needed by the swupd client itself;
# in Clear Linux OS it is used by the installer. We could use some
# space by skipping the os-core zero bundle, but for now it gets
# generated, just in case that it has some future use.
- invoke_swupd ${STAGING_BINDIR_NATIVE}/swupd_make_pack --log-stdout $content_url_parameter -S ${DEPLOY_DIR_SWUPD} 0 ${OS_VERSION} $bndl | sed -u -e "s/^/$bndl: /"
+ invoke_swupd ${STAGING_BINDIR_NATIVE}/swupd_make_pack --log-stdout $content_url_parameter -S ${DEPLOY_DIR_SWUPD} 0 ${OS_VERSION} $bndl &
+ jobs="$jobs $!"
done
# Generate delta-packs against previous versions chosen by our caller.
@@ -423,15 +435,13 @@ END
for bndl in ${ALL_BUNDLES}; do
bndlcnt=0
${SWUPD_LOG_FN} "Generating delta pack from $prevver to ${OS_VERSION} for $bndl"
- if [ "${SWUPD_CONTENT_URL}" ]; then
- content_url_parameter="--content-url ${SWUPD_CONTENT_URL}"
- else
- content_url_parameter=""
- fi
- invoke_swupd ${STAGING_BINDIR_NATIVE}/swupd_make_pack --log-stdout $content_url_parameter -S ${DEPLOY_DIR_SWUPD} $prevver ${OS_VERSION} $bndl
+ invoke_swupd ${STAGING_BINDIR_NATIVE}/swupd_make_pack --log-stdout $content_url_parameter -S ${DEPLOY_DIR_SWUPD} $prevver ${OS_VERSION} $bndl | sed -u -e "s/^/$prevver $bndl: /" &
+ jobs="$jobs $!"
done
done
+ waitall $jobs
+
# Write version to www/version/format${SWUPD_FORMAT}/latest and image/latest.version
bbdebug 2 "Writing latest file"
mkdir -p ${DEPLOY_DIR_SWUPD}/www/version/format${SWUPD_FORMAT}