From 87e169d05d75db5112df20361de33f7398ef27d5 Mon Sep 17 00:00:00 2001 From: "W. Felix Handte" Date: Fri, 20 Jan 2023 17:32:49 -0500 Subject: [PATCH 1/2] Add Additional Flags to PGO Build In GCC, we can add a couple more flags to give us confidence that the profile data is actually being found and used. Also, my system for example doesn't have a binary installed under the name `llvm-profdata`, but it does have, e.g., `llvm-profdata-13`, etc. So this commit adds a variable that can be overridden. --- programs/Makefile | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/programs/Makefile b/programs/Makefile index b79b60b4fb2..fcff41dc1b3 100644 --- a/programs/Makefile +++ b/programs/Makefile @@ -231,9 +231,12 @@ zstd-dll : zstd ## zstd-pgo: zstd executable optimized with PGO. .PHONY: zstd-pgo +zstd-pgo : LLVM_PROFDATA?=llvm-profdata +zstd-pgo : PROF_GENERATE_FLAGS=-fprofile-generate $(if $(findstring gcc,$(CC)),-fprofile-dir=.) +zstd-pgo : PROF_USE_FLAGS=-fprofile-use $(if $(findstring gcc,$(CC)),-fprofile-dir=. -Werror=missing-profile -Wno-error=coverage-mismatch) zstd-pgo : $(MAKE) clean HASH_DIR=$(HASH_DIR) - $(MAKE) zstd HASH_DIR=$(HASH_DIR) MOREFLAGS=-fprofile-generate + $(MAKE) zstd HASH_DIR=$(HASH_DIR) MOREFLAGS="$(PROF_GENERATE_FLAGS)" ./zstd -b19i1 $(PROFILE_WITH) ./zstd -b16i1 $(PROFILE_WITH) ./zstd -b9i2 $(PROFILE_WITH) @@ -245,8 +248,8 @@ ifndef BUILD_DIR else $(RM) zstd $(BUILD_DIR)/zstd $(BUILD_DIR)/*.o endif - case $(CC) in *clang*) if ! [ -e default.profdata ]; then llvm-profdata merge -output=default.profdata default*.profraw; fi ;; esac - $(MAKE) zstd HASH_DIR=$(HASH_DIR) MOREFLAGS=-fprofile-use + case $(CC) in *clang*) if ! [ -e default.profdata ]; then $(LLVM_PROFDATA) merge -output=default.profdata default*.profraw; fi ;; esac + $(MAKE) zstd HASH_DIR=$(HASH_DIR) MOREFLAGS="$(PROF_USE_FLAGS)" ## zstd-small: minimal target, supporting only zstd compression and decompression. no bench. no legacy. no other format. CLEAN += zstd-small zstd-frugal From aab3dd4312d98b2eff868012a50b1523f41a1a9a Mon Sep 17 00:00:00 2001 From: "W. Felix Handte" Date: Fri, 20 Jan 2023 17:36:24 -0500 Subject: [PATCH 2/2] Add PGO Build Jobs to CI --- .github/workflows/dev-short-tests.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/.github/workflows/dev-short-tests.yml b/.github/workflows/dev-short-tests.yml index 5a29789f907..3f6675f0d73 100644 --- a/.github/workflows/dev-short-tests.yml +++ b/.github/workflows/dev-short-tests.yml @@ -500,6 +500,29 @@ jobs: run: | make clangbuild + clang-pgo: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # tag=v3 + - name: Build PGO Zstd with Clang + env: + CC: clang-14 + LLVM_PROFDATA: llvm-profdata-14 + run: | + make -C programs zstd-pgo + ./programs/zstd -b + + gcc-pgo: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # tag=v3 + - name: Build PGO Zstd with GCC + env: + CC: gcc + run: | + make -C programs zstd-pgo + ./programs/zstd -b + # For reference : icc tests # icc tests are currently failing on Github Actions, likely to issues during installation stage