From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id EC3B8158043 for ; Tue, 16 Apr 2024 01:24:56 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 0F499E29ED; Tue, 16 Apr 2024 01:24:56 +0000 (UTC) Received: from smtp.gentoo.org (mail.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (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) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id DF696E29ED for ; Tue, 16 Apr 2024 01:24:55 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (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) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 0297C3433F1 for ; Tue, 16 Apr 2024 01:24:55 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 59EA416E1 for ; Tue, 16 Apr 2024 01:24:53 +0000 (UTC) From: "Sam James" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Sam James" Message-ID: <1713230665.83a27ac5162cf15e1dca6de92f2debe452024d24.sam@gentoo> Subject: [gentoo-commits] repo/gentoo:master commit in: app-arch/xz-utils/ X-VCS-Repository: repo/gentoo X-VCS-Files: app-arch/xz-utils/xz-utils-9999.ebuild X-VCS-Directories: app-arch/xz-utils/ X-VCS-Committer: sam X-VCS-Committer-Name: Sam James X-VCS-Revision: 83a27ac5162cf15e1dca6de92f2debe452024d24 X-VCS-Branch: master Date: Tue, 16 Apr 2024 01:24:53 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 890ce450-4ca9-49d9-9b3f-6cffa689ee19 X-Archives-Hash: 18ccff47746b4eab7f35668647a6fc9f commit: 83a27ac5162cf15e1dca6de92f2debe452024d24 Author: Sam James gentoo org> AuthorDate: Tue Apr 16 01:21:09 2024 +0000 Commit: Sam James gentoo org> CommitDate: Tue Apr 16 01:24:25 2024 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=83a27ac5 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 gentoo.org> app-arch/xz-utils/xz-utils-9999.ebuild | 38 ++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) 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