public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Compilation-time suggestion
@ 2004-01-19 17:46 Roger Sayle
  2004-01-19 17:58 ` Gabriel Dos Reis
  0 siblings, 1 reply; 2+ messages in thread
From: Roger Sayle @ 2004-01-19 17:46 UTC (permalink / raw)
  To: gcc


I have a proposal/suggestion for perhaps improving GCC compilation
time: Perhaps we could make more use of __builtin_expect inside the
compiler itself.

I'm not sure how much it would save us, but Jan's experiments
with profiled bootstraps seemed to be encouraging, if memory
serves.  Certainly, SPEC results are much more competative with
profiling enabled.

If our profiling tools could be used to identify a small number
of critial conditionals in the source code level, they could be
annotated with __builtin_expect.  Hopefully, this might be able
to gain us much of the benefit of profile-feedback statically,
assuming that its a few hotspots are responsible for a significant
fraction of the gain.

The usual use of macros in system.h can be used to allow the source
code to bootstrap on non-GCC compilers.

In addition to the tools locating critical conditionals at the
source code level, we'd also need the ability to identify those
__builtin_expect annotations that were incorrect or no longer
critical, to prevent too much obfuscation of the source code.
But certainly, machine generated functions such as the garbage
collector's traversals and insn-recog could be made expectation
aware.


Clearly, there are issues with training sets, and branch probabilities
that differ between one platform and another, but the hypothesis is
that a handfull, perhaps 100, __builtin_expect annotations might give
us a few percentage points, but maybe more.


Are the benefits of user-annotated branch predictions significant
enough to make them worth going after?  Do any of the distributions
come with a profile-optimized GCC?


Just throwing out a brain-storm to see if anyone has a better handle
on the potential benefits vs. increased maintenance overheads.

Roger
--

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Compilation-time suggestion
  2004-01-19 17:46 Compilation-time suggestion Roger Sayle
@ 2004-01-19 17:58 ` Gabriel Dos Reis
  0 siblings, 0 replies; 2+ messages in thread
From: Gabriel Dos Reis @ 2004-01-19 17:58 UTC (permalink / raw)
  To: Roger Sayle; +Cc: gcc

Roger Sayle <roger@eyesopen.com> writes:

| I have a proposal/suggestion for perhaps improving GCC compilation
| time: Perhaps we could make more use of __builtin_expect inside the
| compiler itself.

This has been suggested in the past

  http://gcc.gnu.org/ml/libstdc++/2002-11/msg00151.html

and RTH made this comment:

  http://gcc.gnu.org/ml/libstdc++/2002-11/msg00171.html

In fact, from a recent thread on libstdc++ list, I've come to agree
with RTH comment. 

I believe you would benefit much more from *algorithmic* and
*data-structure* improvements than from __builtin_expect which would
just add one more level of obfuscation to the already difficult to
follow source base.  Let's go that way first.

-- Gaby

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2004-01-19 17:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-01-19 17:46 Compilation-time suggestion Roger Sayle
2004-01-19 17:58 ` Gabriel Dos Reis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).