summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam James <sam@gentoo.org>2024-04-16 02:21:09 +0100
committerSam James <sam@gentoo.org>2024-04-16 02:24:25 +0100
commit83a27ac5162cf15e1dca6de92f2debe452024d24 (patch)
tree496e262e5ba3d7658194e04d4fff8a68b8bf5775 /app-arch
parentnet-analyzer/nagios-check_mysql_health: EAPI8 bump (diff)
downloadgentoo-83a27ac5162cf15e1dca6de92f2debe452024d24.tar.gz
gentoo-83a27ac5162cf15e1dca6de92f2debe452024d24.tar.bz2
gentoo-83a27ac5162cf15e1dca6de92f2debe452024d24.zip
app-arch/xz-utils: improve USE=pgo for 9999
Takes a lot of inspiration from https://packages.altlinux.org/en/sisyphus/srpms/xz/specfiles/#line-80. IIRC at least one other distro does this for xz or gzip (was it Clear Linux?) The testsuite could do with better coverage so supplement it by creating a tar archive of a bunch of files made during the build, then repeatedly compress/decompress it to gather profiling data. That said, I don't get any binary differences at all for liblzma and xz for my usual flags (-O3 -march=znver2 ...). I do get some small differences for just -O2. Both tests were done with GCC 14.0.1 20240415. It would be nice if we could drop -fprofile-partial-training and that's perhaps the thing to try next. I see this commit as mostly a step towards being able to do that which should let PGO give smaller binaries with -O2 at least. Signed-off-by: Sam James <sam@gentoo.org>
Diffstat (limited to 'app-arch')
-rw-r--r--app-arch/xz-utils/xz-utils-9999.ebuild38
1 files changed, 38 insertions, 0 deletions
diff --git a/app-arch/xz-utils/xz-utils-9999.ebuild b/app-arch/xz-utils/xz-utils-9999.ebuild
index ec5227371390..d2e98e50e15a 100644
--- a/app-arch/xz-utils/xz-utils-9999.ebuild
+++ b/app-arch/xz-utils/xz-utils-9999.ebuild
@@ -106,6 +106,7 @@ multilib_src_configure() {
multilib_src_compile() {
# -fprofile-partial-training because upstream note the test suite isn't super comprehensive
+ # TODO: revisit that now we have the tar/xz loop below?
# See https://documentation.suse.com/sbp/all/html/SBP-GCC-10/index.html#sec-gcc10-pgo
local pgo_generate_flags=$(usev pgo "-fprofile-update=atomic -fprofile-dir=${T}/${ABI}-pgo -fprofile-generate=${T}/${ABI}-pgo $(test-flags-CC -fprofile-partial-training)")
local pgo_use_flags=$(usev pgo "-fprofile-use=${T}/${ABI}-pgo -fprofile-dir=${T}/${ABI}-pgo $(test-flags-CC -fprofile-partial-training)")
@@ -115,6 +116,43 @@ multilib_src_compile() {
if use pgo ; then
emake CFLAGS="${CFLAGS} ${pgo_generate_flags}" -k check
+ if multilib_is_native_abi ; then
+ (
+ shopt -s globstar
+
+ tar \
+ --sort=name --mtime=@2718281828 \
+ -cf xz-pgo-test-01.tar \
+ {"${S}","${BUILD_DIR}"}/**/*.[cho] \
+ {"${S}","${BUILD_DIR}"}/**/*.so* \
+ {"${S}","${BUILD_DIR}"}/**/**.txt \
+ {"${S}","${BUILD_DIR}"}/tests/files \
+
+ stat --printf="xz-pgo-test-01.tar.tar size: %s\n" xz-pgo-test-01.tar
+ md5sum xz-pgo-test-01.tar
+ )
+
+ local test_variants=(
+ # Borrowed from ALT Linux
+ # https://packages.altlinux.org/en/sisyphus/srpms/xz/specfiles/#line-80
+ '-0 -C none'
+ '-2 -C crc32'
+ '-6 --arm --lzma2 -C crc64'
+ '-6 --x86 --lzma2=lc=4 -C sha256'
+ '-7e --format=lzma'
+
+ # Our own variants
+ ''
+ '-9e'
+ '--x86 --lzma2=preset=9e'
+ )
+ local test_variant
+ for test_variant in "${test_variants[@]}" ; do
+ "${BUILD_DIR}"/src/xz/xz -c ${test_variant} xz-pgo-test-01.tar | "${BUILD_DIR}"/src/xz/xz -c -d - > /dev/null
+ assert "Testing '${test_variant}' variant failed"
+ done
+ fi
+
if tc-is-clang; then
llvm-profdata merge "${T}"/${ABI}-pgo --output="${T}"/${ABI}-pgo/default.profdata || die
fi