From 6520c84685660fc995a405d7b7511a903fc12e18 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Sat, 18 Jun 2011 18:07:03 -0700 Subject: Add option to disable NORETURN Due to a bug in gcc 4.6+ it can crash when doing profile feedback with a noreturn function pointer (http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49299) This adds a Makefile variable to disable noreturns. [Patch by Junio, description by Andi Kleen] Signed-off-by: Andi Kleen Signed-off-by: Junio C Hamano diff --git a/Makefile b/Makefile index e40ac0c..03b4499 100644 --- a/Makefile +++ b/Makefile @@ -153,6 +153,9 @@ all:: # that tells runtime paths to dynamic libraries; # "-Wl,-rpath=/path/lib" is used instead. # +# Define NO_NORETURN if using buggy versions of gcc 4.6+ and profile feedback, +# as the compiler can crash (http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49299) +# # Define USE_NSEC below if you want git to care about sub-second file mtimes # and ctimes. Note that you need recent glibc (at least 2.2.4) for this, and # it will BREAK YOUR LOCAL DIFFS! show-diff and anything using it will likely @@ -1374,6 +1377,9 @@ endif ifdef USE_ST_TIMESPEC BASIC_CFLAGS += -DUSE_ST_TIMESPEC endif +ifdef NO_NORETURN + BASIC_CFLAGS += -DNO_NORETURN +endif ifdef NO_NSEC BASIC_CFLAGS += -DNO_NSEC endif diff --git a/git-compat-util.h b/git-compat-util.h index e0bb81e..9925cf0 100644 --- a/git-compat-util.h +++ b/git-compat-util.h @@ -218,7 +218,7 @@ extern char *gitbasename(char *); #if __HP_cc >= 61000 #define NORETURN __attribute__((noreturn)) #define NORETURN_PTR -#elif defined(__GNUC__) +#elif defined(__GNUC__) && !defined(NO_NORETURN) #define NORETURN __attribute__((__noreturn__)) #define NORETURN_PTR __attribute__((__noreturn__)) #elif defined(_MSC_VER) -- cgit v0.10.2-6-g49f6 From 7ddc2710b97f223a13d9ff757948cdf9c8a22f66 Mon Sep 17 00:00:00 2001 From: Andi Kleen Date: Sat, 18 Jun 2011 18:07:05 -0700 Subject: Add profile feedback build to git Add a gcc profile feedback build option "profile-all" to the main Makefile. It simply runs the test suite to generate feedback data and the recompiles the main executables with that. The basic structure is similar to the existing gcov code. gcc is often able to generate better code with profile feedback data. The training load also doesn't need to be too similar to the actual load, it still gives benefits. The test suite run is unfortunately quite long. It would be good to find a suitable subset that runs faster and still gives reasonable feedback. For now the test suite runs single threaded (I had some trouble running the test suite with -jX) I tested it with git gc and git blame kernel/sched.c on a Linux kernel tree. For gc I get about 2.7% improvement in wall clock time by using the feedback build, for blame about 2.4%. That's not gigantic, but not shabby either for a very small patch. If anyone has any favourite CPU intensive git benchmarks feel free to try them too. I hope distributors will switch to use a feedback build in their packages. Signed-off-by: Andi Kleen Signed-off-by: Junio C Hamano diff --git a/Makefile b/Makefile index 03b4499..2d7f6ba 100644 --- a/Makefile +++ b/Makefile @@ -2492,3 +2492,19 @@ cover_db: coverage-report cover_db_html: cover_db cover -report html -outputdir cover_db_html cover_db + +### profile feedback build +# +.PHONY: profile-all profile-clean + +PROFILE_GEN_CFLAGS := $(CFLAGS) -fprofile-generate -DNO_NORETURN=1 +PROFILE_USE_CFLAGS := $(CFLAGS) -fprofile-use -fprofile-correction -DNO_NORETURN=1 + +profile-clean: + $(RM) $(addsuffix *.gcda,$(object_dirs)) + $(RM) $(addsuffix *.gcno,$(object_dirs)) + +profile-all: profile-clean + $(MAKE) CFLAGS="$(PROFILE_GEN_CFLAGS)" all + $(MAKE) CFLAGS="$(PROFILE_GEN_CFLAGS)" -j1 test + $(MAKE) CFLAGS="$(PROFILE_USE_CFLAGS)" all -- cgit v0.10.2-6-g49f6 From 39001007390a699265f16da47474d2b112118931 Mon Sep 17 00:00:00 2001 From: Andi Kleen Date: Mon, 20 Jun 2011 15:41:01 -0700 Subject: Add explanation of the profile feedback build to the README Also explains that the are additional warnings. Signed-off-by: Andi Kleen Signed-off-by: Junio C Hamano diff --git a/INSTALL b/INSTALL index 16e45f1..bbb9d4d 100644 --- a/INSTALL +++ b/INSTALL @@ -25,6 +25,19 @@ set up install paths (via config.mak.autogen), so you can write instead $ make all doc ;# as yourself # make install install-doc install-html;# as root +If you're willing to trade off (much) longer build time for a later +faster git you can also do a profile feedback build with + + $ make profile-all + # make prefix=... install + +This will run the complete test suite as training workload and then +rebuild git with the generated profile feedback. This results in a git +which is a few percent faster on CPU intensive workloads. This +may be a good tradeoff for distribution packagers. + +Note that the profile feedback build stage currently generates +a lot of additional compiler warnings. Issues of note: -- cgit v0.10.2-6-g49f6