Skip to content

Commit 7ddc271

Browse files
Andi Kleengitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 6520c84 commit 7ddc271

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

Makefile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2492,3 +2492,19 @@ cover_db: coverage-report
24922492

24932493
cover_db_html: cover_db
24942494
cover -report html -outputdir cover_db_html cover_db
2495+
2496+
### profile feedback build
2497+
#
2498+
.PHONY: profile-all profile-clean
2499+
2500+
PROFILE_GEN_CFLAGS := $(CFLAGS) -fprofile-generate -DNO_NORETURN=1
2501+
PROFILE_USE_CFLAGS := $(CFLAGS) -fprofile-use -fprofile-correction -DNO_NORETURN=1
2502+
2503+
profile-clean:
2504+
$(RM) $(addsuffix *.gcda,$(object_dirs))
2505+
$(RM) $(addsuffix *.gcno,$(object_dirs))
2506+
2507+
profile-all: profile-clean
2508+
$(MAKE) CFLAGS="$(PROFILE_GEN_CFLAGS)" all
2509+
$(MAKE) CFLAGS="$(PROFILE_GEN_CFLAGS)" -j1 test
2510+
$(MAKE) CFLAGS="$(PROFILE_USE_CFLAGS)" all

0 commit comments

Comments
 (0)