build: Add support for profile guided optimization

./configure --enable-pgo-capture
make

<Run sample workload>

./configure --enable-pgo-use
make

Output has used the captured profile from the sample workload to improve
performance.

Change-Id: Ie5690b873b05d11b4ea6c7d44021e564d4e4d170
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/c/444110
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
Ben Walker 2019-02-11 11:19:32 -07:00 committed by Darek Stojaczyk
parent 8ad0935b81
commit 995d60f493
3 changed files with 36 additions and 0 deletions

6
CONFIG
View File

@ -46,6 +46,12 @@ CONFIG_WERROR=n
# Build with link-time optimization.
CONFIG_LTO=n
# Generate profile guided optimization data.
CONFIG_PGO_CAPTURE=n
# Use profile guided optimization data.
CONFIG_PGO_USE=n
# Build with code coverage instrumentation.
CONFIG_COVERAGE=n

20
configure vendored
View File

@ -24,6 +24,8 @@ function usage()
echo " --enable-ubsan Enable undefined behavior sanitizer"
echo " --enable-coverage Enable code coverage tracking"
echo " --enable-lto Enable link-time optimization"
echo " --enable-pgo-capture Enable generation of profile guided optimization data"
echo " --enable-pgo-use Use previously captured profile guided optimization data"
echo " --disable-tests Disable building of tests"
echo " --with-env=path Use an alternate environment implementation"
echo ""
@ -146,6 +148,18 @@ for i in "$@"; do
--disable-lto)
CONFIG[LTO]=n
;;
--enable-pgo-capture)
CONFIG[PGO_CAPTURE]=y
;;
--disable-pgo-capture)
CONFIG[PGO_CAPTURE]=n
;;
--enable-pgo-use)
CONFIG[PGO_USE]=y
;;
--disable-pgo-use)
CONFIG[PGO_USE]=n
;;
--enable-tests)
CONFIG[TESTS]=y
;;
@ -466,6 +480,12 @@ if [[ "${CONFIG[OCF]}" = "y" ]]; then
fi
fi
if [[ "${CONFIG[PGO_CAPTURE]}" = "y" && "${CONFIG[PGO_USE]}" = "y" ]]; then
echo "ERROR: --enable-pgo-capture and --enable-pgo-use are mutually exclusive."
exit 1
fi
# We are now ready to generate final configuration. But first do sanity
# check to see if all keys in CONFIG array have its reflection in CONFIG file.
if [ $(egrep -c "^\s*CONFIG_[[:alnum:]_]+=" CONFIG) -ne ${#CONFIG[@]} ]; then

View File

@ -94,6 +94,16 @@ COMMON_CFLAGS += -flto
LDFLAGS += -flto
endif
ifeq ($(CONFIG_PGO_CAPTURE),y)
COMMON_CFLAGS += -fprofile-generate=$(SPDK_ROOT_DIR)/build/pgo
LDFLAGS += -fprofile-generate=$(SPDK_ROOT_DIR)/build/pgo
endif
ifeq ($(CONFIG_PGO_USE),y)
COMMON_CFLAGS += -fprofile-use=$(SPDK_ROOT_DIR)/build/pgo
LDFLAGS += -fprofile-use=$(SPDK_ROOT_DIR)/build/pgo
endif
COMMON_CFLAGS += -Wformat -Wformat-security
COMMON_CFLAGS += -D_GNU_SOURCE