Re: [MERGE] branch prediction hints

From: Henrik Nordström <henrik_at_henriknordstrom.net>
Date: Wed, 13 Oct 2010 19:49:02 +0200

tis 2010-10-12 klockan 17:47 +0200 skrev Kinkie:
> Hi all,
> this patch-let makes implements a GCC feature to hint the branch
> prediction algorithms about the likely outcome of a test. This is useful
> to optimize the case of singleton patterns (e.g.
> CacheManager::GetInstance).
> This implements the likely() and unlikely() macros.

My experience is that unless one is very careful the use of these hints
often backfire after the code evolves a bit.

The compiler is generally pretty good at doing the right choice, and the
runtime profiling support can be used to fill in the missing spots
automatically, with no risk of decaying over time.

Yes, a profiling based build requires a bit of effort in each build, as
it requires you to first make a profiling build an put some reasonable
workload on it and then build again providing the profiling data as
input to the compiler.

Regards
Henrik
Received on Wed Oct 13 2010 - 17:49:05 MDT

This archive was generated by hypermail 2.2.0 : Thu Oct 14 2010 - 12:00:04 MDT