Skip to content

Commit 4623765

Browse files
authored
Merge pull request #994 from casparvl/add_zstd_support_to_build_pipeline
Add zstd support for faster tarball creation or extraction in eessi_container.sh
2 parents 28cea37 + 1a41987 commit 4623765

2 files changed

Lines changed: 31 additions & 5 deletions

File tree

eessi_container.sh

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,19 @@ else
408408
echo "Using ${EESSI_HOST_STORAGE} as tmp directory (to resume session add '--resume ${EESSI_HOST_STORAGE}')."
409409
fi
410410

411+
# if ${RESUME} is a file, unpack it into ${EESSI_HOST_STORAGE}
412+
if [[ ! -z ${RESUME} && -f ${RESUME} ]]; then
413+
if [[ "${RESUME}" == *.tgz ]]; then
414+
tar xf ${RESUME} -C ${EESSI_HOST_STORAGE}
415+
# Add support for resuming from zstd-compressed tarballs
416+
elif [[ "${RESUME}" == *.zst && -x "$(command -v zstd)" ]]; then
417+
zstd -dc ${RESUME} | tar -xf - -C ${EESSI_HOST_STORAGE}
418+
elif [[ "${RESUME}" == *.zst && ! -x "$(command -v zstd)" ]]; then
419+
fatal_error "Trying to resume from tarball ${RESUME} which was compressed using zstd, but zstd command not found"
420+
fi
421+
echo "Resuming from previous run using temporary storage ${RESUME} unpacked into ${EESSI_HOST_STORAGE}"
422+
fi
423+
411424
# if ${RESUME} is a file (assume a tgz), unpack it into ${EESSI_HOST_STORAGE}
412425
if [[ ! -z ${RESUME} && -f ${RESUME} ]]; then
413426
tar xf ${RESUME} -C ${EESSI_HOST_STORAGE}
@@ -865,17 +878,30 @@ if [[ ! -z ${SAVE} ]]; then
865878
# ARCH which might have been used internally, eg, when software packages
866879
# were built ... we rather keep the script here "stupid" and leave the handling
867880
# of these aspects to where the script is used
881+
# Compression with zlib may be quite slow. On some systems, the pipeline takes ~20 mins for a 2 min build because of this.
882+
# Check if zstd is present for faster compression and decompression
868883
if [[ -d ${SAVE} ]]; then
869884
# assume SAVE is name of a directory to which tarball shall be written to
870885
# name format: tmp_storage-{TIMESTAMP}.tgz
871886
ts=$(date +%s)
872-
TGZ=${SAVE}/tmp_storage-${ts}.tgz
887+
if [[ -x "$(command -v zstd)" ]]; then
888+
TARBALL=${SAVE}/tmp_storage-${ts}.zst
889+
tar -cf - -C ${EESSI_TMPDIR} . | zstd -T0 > ${TARBALL}
890+
else
891+
TARBALL=${SAVE}/tmp_storage-${ts}.tgz
892+
tar czf ${TARBALL} -C ${EESSI_TMPDIR} .
893+
fi
873894
else
874895
# assume SAVE is the full path to a tarball's name
875-
TGZ=${SAVE}
896+
TARBALL=${SAVE}
897+
# if zstd is present and a .zst extension is asked for, use it
898+
if [[ "${SAVE}" == *.zst && -x "$(command -v zstd)" ]]; then
899+
tar -cf - -C ${EESSI_TMPDIR} . | zstd -T0 > ${TARBALL}
900+
else
901+
tar czf ${TARBALL} -C ${EESSI_TMPDIR}
902+
fi
876903
fi
877-
tar czf ${TGZ} -C ${EESSI_TMPDIR} .
878-
echo "Saved contents of tmp directory '${EESSI_TMPDIR}' to tarball '${TGZ}' (to resume session add '--resume ${TGZ}')"
904+
echo "Saved contents of tmp directory '${EESSI_TMPDIR}' to tarball '${TARBALL}' (to resume session add '--resume ${TARBALL}')"
879905
fi
880906

881907
# TODO clean up tmp by default? only retain if another option provided (--retain-tmp)

test_suite.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ else
203203
fatal_error "Failed to extract names of tests to run: ${REFRAME_NAME_ARGS}"
204204
exit ${test_selection_exit_code}
205205
fi
206-
# Allow people deploying the bot to overrwide this
206+
# Allow people deploying the bot to override this
207207
if [ -z "$REFRAME_SCALE_TAG" ]; then
208208
REFRAME_SCALE_TAG="--tag 1_node"
209209
fi

0 commit comments

Comments
 (0)