profile-guided opt. w/ GCC - Mailing list pgsql-hackers

From Neil Conway
Subject profile-guided opt. w/ GCC
Date
Msg-id 1096534684.25277.323.camel@localhost.localdomain
Whole thread Raw
Responses Re: profile-guided opt. w/ GCC  (Peter Eisentraut <peter_e@gmx.net>)
Re: profile-guided opt. w/ GCC  ("Jeroen T. Vermeulen" <jtv@xs4all.nl>)
List pgsql-hackers
Profile-guided optimization is a relatively new GCC feature that
improves the quality of generated code by:

- compiling a copy of the source program with some profiling hooks
- running this copy of the program on some representative input data
- recompiling the program using the profiling data produced by the
previous stage; the profiling data lets GCC's optimizer generate more
efficient code

I think it would be cool to add support for PGO to PostgreSQL's build
system (for 8.1). There are a lot of situations where PostgreSQL is
compiled once, and then used for weeks or months (compilations for
inclusion in a distro being the extreme example). In that kind of
situation, trading some additional compile-time for even a small
improvement in run-time performance is worthwhile, IMHO.

I've attached a proof-of-concept patch that implements this. Caveats:

- you'll need to re-run autoconf
- the libgcov.a stuff is a temporary hack, you may need to adjust it for
where libgcov.a is on your system
- I've only bothered adding support for GCC 3.4 (IIRC profile-guided
optimization was introduced in GCC 3.3, but 3.4 adds a simpler interface
to using it). By the time 8.1 is out I think GCC 3.4+ will be pretty
prevalent anyway.
- the patch should remove the .gcda and .gcno files that are produced by
GCC; I haven't done that yet

The patch adds a new make target ("profile-opt") that does the PGO steps
outlined above -- the "representative input data" is the regression
tests running in serial mode. I haven't run any benchmarks yet (if
someone wants to try that, I'd be very curious to see the results).

Comments?

-Neil


Attachment

pgsql-hackers by date:

Previous
From: "Simon Riggs"
Date:
Subject: Re: shared memory release following failed lock acquirement.
Next
From: Peter Eisentraut
Date:
Subject: Re: profile-guided opt. w/ GCC