git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 2/2] Add profile feedback build to git

From
AKAndi Kleen <andi@firstfloor.org>
Date
Jun 8, 2011, 21:43 UTC
Message-ID
<1307569417-8924-2-git-send-email-andi@firstfloor.org>
In-Reply-To
<1307569417-8924-1-git-send-email-andi@firstfloor.org>
From: Andi Kleen <ak@linux.intel.com>

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 <ak@linux.intel.com>
---
 Makefile |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)
diff --git a/Makefile b/Makefile
index e40ac0c..85e2679 100644
--- a/Makefile
+++ b/Makefile
@@ -2486,3 +2486,20 @@ 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
+PROFILE_USE_CFLAGS := $(CFLAGS) -fprofile-use -fprofile-correction
+
+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
+	
-- 
1.7.4.4
Previous: Andi KleenNext: Junio C Hamano
Message 2 of 7 in “Remove noreturn function pointers in usage.c”
  1. 1/2 Remove noreturn function pointers in usage.cAndi Kleen, Jun 8, 2011
  2. 2/2 Add profile feedback build to gitAndi Kleen, Jun 8, 2011
  3. Junio C HamanoJun 9, 2011
  4. Andi KleenJun 9, 2011
  5. Jeff KingJun 9, 2011
  6. Andi KleenJun 9, 2011
  7. Erik Faye-LundJun 9, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.