diff options
author | Henry Kleynhans <hkleynhans@fb.com> | 2021-10-12 09:56:16 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2021-10-14 22:37:43 +0100 |
commit | 3579782a4415685063b28ba00e39271309106917 (patch) | |
tree | 853a7ee5a9f097405e82940e2ed800dce91795e8 /meta/classes | |
parent | ca8ef6bc38b8bfd772ff19931b49a076de5c1ec4 (diff) | |
download | poky-3579782a4415685063b28ba00e39271309106917.tar.gz |
sstate: Switch to ZStandard compressor support
This patch switches the compressor from Gzip to ZStandard for ssate cache
files.
Zstandard compression provides a significant improvement in
decompression speed as well as improvement in compression speed and disk
usage over the 'tgz' format in use. Furthermore, its configurable
compression level offers a trade-off between time spent compressing
sstate cache files and disk space used by those files. The reduced disk
usage also contributes to saving network traffic for those sharing their
sstate cache with others.
Zstandard should therefore be a good choice when:
* disk space is at a premium
* network speed / resources are limited
* the CI server can sstate packages can be created at high compression
* less CPU on the build server should be used for sstate decompression
(From OE-Core rev: 0710e98f40ec7394567ede1f88f7c7bae306b925)
Signed-off-by: Henry Kleynhans <hkleynhans@fb.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes')
-rw-r--r-- | meta/classes/sstate.bbclass | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/meta/classes/sstate.bbclass b/meta/classes/sstate.bbclass index 701a19bc61..c125286f74 100644 --- a/meta/classes/sstate.bbclass +++ b/meta/classes/sstate.bbclass | |||
@@ -1,17 +1,19 @@ | |||
1 | SSTATE_VERSION = "7" | 1 | SSTATE_VERSION = "7" |
2 | 2 | ||
3 | SSTATE_ZSTD_CLEVEL ??= "8" | ||
4 | |||
3 | SSTATE_MANIFESTS ?= "${TMPDIR}/sstate-control" | 5 | SSTATE_MANIFESTS ?= "${TMPDIR}/sstate-control" |
4 | SSTATE_MANFILEPREFIX = "${SSTATE_MANIFESTS}/manifest-${SSTATE_MANMACH}-${PN}" | 6 | SSTATE_MANFILEPREFIX = "${SSTATE_MANIFESTS}/manifest-${SSTATE_MANMACH}-${PN}" |
5 | 7 | ||
6 | def generate_sstatefn(spec, hash, taskname, siginfo, d): | 8 | def generate_sstatefn(spec, hash, taskname, siginfo, d): |
7 | if taskname is None: | 9 | if taskname is None: |
8 | return "" | 10 | return "" |
9 | extension = ".tgz" | 11 | extension = ".tar.zst" |
10 | # 8 chars reserved for siginfo | 12 | # 8 chars reserved for siginfo |
11 | limit = 254 - 8 | 13 | limit = 254 - 8 |
12 | if siginfo: | 14 | if siginfo: |
13 | limit = 254 | 15 | limit = 254 |
14 | extension = ".tgz.siginfo" | 16 | extension = ".tar.zst.siginfo" |
15 | if not hash: | 17 | if not hash: |
16 | hash = "INVALID" | 18 | hash = "INVALID" |
17 | fn = spec + hash + "_" + taskname + extension | 19 | fn = spec + hash + "_" + taskname + extension |
@@ -37,7 +39,7 @@ SSTATE_PKGNAME = "${SSTATE_EXTRAPATH}${@generate_sstatefn(d.getVar('SSTATE_PK | |||
37 | SSTATE_PKG = "${SSTATE_DIR}/${SSTATE_PKGNAME}" | 39 | SSTATE_PKG = "${SSTATE_DIR}/${SSTATE_PKGNAME}" |
38 | SSTATE_EXTRAPATH = "" | 40 | SSTATE_EXTRAPATH = "" |
39 | SSTATE_EXTRAPATHWILDCARD = "" | 41 | SSTATE_EXTRAPATHWILDCARD = "" |
40 | SSTATE_PATHSPEC = "${SSTATE_DIR}/${SSTATE_EXTRAPATHWILDCARD}*/*/${SSTATE_PKGSPEC}*_${SSTATE_PATH_CURRTASK}.tgz*" | 42 | SSTATE_PATHSPEC = "${SSTATE_DIR}/${SSTATE_EXTRAPATHWILDCARD}*/*/${SSTATE_PKGSPEC}*_${SSTATE_PATH_CURRTASK}.tar.zst*" |
41 | 43 | ||
42 | # explicitly make PV to depend on evaluated value of PV variable | 44 | # explicitly make PV to depend on evaluated value of PV variable |
43 | PV[vardepvalue] = "${PV}" | 45 | PV[vardepvalue] = "${PV}" |
@@ -832,23 +834,24 @@ sstate_create_package () { | |||
832 | mkdir --mode=0775 -p `dirname ${SSTATE_PKG}` | 834 | mkdir --mode=0775 -p `dirname ${SSTATE_PKG}` |
833 | TFILE=`mktemp ${SSTATE_PKG}.XXXXXXXX` | 835 | TFILE=`mktemp ${SSTATE_PKG}.XXXXXXXX` |
834 | 836 | ||
835 | # Use pigz if available | 837 | OPT="-cS" |
836 | OPT="-czS" | 838 | ZSTD="zstd -${SSTATE_ZSTD_CLEVEL} -T${ZSTD_THREADS}" |
837 | if [ -x "$(command -v pigz)" ]; then | 839 | # Use pzstd if available |
838 | OPT="-I pigz -cS" | 840 | if [ -x "$(command -v pzstd)" ]; then |
841 | ZSTD="pzstd -${SSTATE_ZSTD_CLEVEL} -p ${ZSTD_THREADS}" | ||
839 | fi | 842 | fi |
840 | 843 | ||
841 | # Need to handle empty directories | 844 | # Need to handle empty directories |
842 | if [ "$(ls -A)" ]; then | 845 | if [ "$(ls -A)" ]; then |
843 | set +e | 846 | set +e |
844 | tar $OPT -f $TFILE * | 847 | tar -I "$ZSTD" $OPT -f $TFILE * |
845 | ret=$? | 848 | ret=$? |
846 | if [ $ret -ne 0 ] && [ $ret -ne 1 ]; then | 849 | if [ $ret -ne 0 ] && [ $ret -ne 1 ]; then |
847 | exit 1 | 850 | exit 1 |
848 | fi | 851 | fi |
849 | set -e | 852 | set -e |
850 | else | 853 | else |
851 | tar $OPT --file=$TFILE --files-from=/dev/null | 854 | tar -I "$ZSTD" $OPT --file=$TFILE --files-from=/dev/null |
852 | fi | 855 | fi |
853 | chmod 0664 $TFILE | 856 | chmod 0664 $TFILE |
854 | # Skip if it was already created by some other process | 857 | # Skip if it was already created by some other process |
@@ -887,7 +890,13 @@ python sstate_report_unihash() { | |||
887 | # Will be run from within SSTATE_INSTDIR. | 890 | # Will be run from within SSTATE_INSTDIR. |
888 | # | 891 | # |
889 | sstate_unpack_package () { | 892 | sstate_unpack_package () { |
890 | tar -xvzf ${SSTATE_PKG} | 893 | ZSTD="zstd -T${ZSTD_THREADS}" |
894 | # Use pzstd if available | ||
895 | if [ -x "$(command -v pzstd)" ]; then | ||
896 | ZSTD="pzstd -p ${ZSTD_THREADS}" | ||
897 | fi | ||
898 | |||
899 | tar -I "$ZSTD" -xvf ${SSTATE_PKG} | ||
891 | # update .siginfo atime on local/NFS mirror | 900 | # update .siginfo atime on local/NFS mirror |
892 | [ -O ${SSTATE_PKG}.siginfo ] && [ -w ${SSTATE_PKG}.siginfo ] && [ -h ${SSTATE_PKG}.siginfo ] && touch -a ${SSTATE_PKG}.siginfo | 901 | [ -O ${SSTATE_PKG}.siginfo ] && [ -w ${SSTATE_PKG}.siginfo ] && [ -h ${SSTATE_PKG}.siginfo ] && touch -a ${SSTATE_PKG}.siginfo |
893 | # Use "! -w ||" to return true for read only files | 902 | # Use "! -w ||" to return true for read only files |