Skip to content

build: PGO-enabled release builds #1409

Closed
@bnoordhuis

Description

@bnoordhuis

This is something that has been at the bottom of my TODO list for some time now. I don't seem to get around to it so I thought I'd file this issue in the hope that someone else might. :-)

I'd like to investigate doing release builds with profile-guided optimizations enabled. Strawman Makefile change:

diff --git a/Makefile b/Makefile
index e93e817..2deffda 100644
--- a/Makefile
+++ b/Makefile
@@ -257,6 +257,13 @@ release-only:
                exit 1 ; \
        fi

+.PHONY: pgo
+pgo:   BUILDTYPE=Release
+pgo:
+       $(MAKE) CFLAGS+="-fprofile-generate" CXXFLAGS+="-fprofile-generate"
+       $(MAKE) bench-all
+       $(MAKE) CFLAGS+="-fprofile-use" CXXFLAGS+="-fprofile-use"
+
 pkg: $(PKG)

 $(PKG): release-only

The idea is to build an instrumented binary first, run the benchmarks to collect profile data that tell the compiler where and what to optimize, then build the final binary using the data from the previous step.

Open questions / unresolved issues:

  • The benchmark suite consists primarily of micro-benchmarks. It's not very representative of real-world applications. We would need something better for PGO.
  • It would make the release process a lot slower, particularly on the ARM buildbots. We could of course do non-PGO builds on slow machines.
  • I couldn't get the 32 bits build to link when PGO and LTO are enabled, at least not with a 32 bits toolchain: it runs out of memory. Could be resolved for the ia32 buildbots by using a 64 bits toolchain (I suspect that's already the case) but for ARM, the only option is to cross-compile and that sucks.
  • PGO may penalize the uncommon case, i.e., it may regress performance for use cases that are not covered by our benchmarks.
  • PGO's net effect may be zero.

Metadata

Metadata

Assignees

No one assigned

    Labels

    benchmarkIssues and PRs related to the benchmark subsystem.buildIssues and PRs related to build files or the CI.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions