likely and unlikely
Robert Watson
rwatson at FreeBSD.org
Sat Mar 13 13:47:37 UTC 2010
On Sat, 13 Mar 2010, Bruce Evans wrote:
>> My point is: Handle with care!!! Trust your compiler/CPU predictors/... -
>> most of the time, they are smarter than you are ;)
>
> These macros may have useful 15-25 years ago for i386, i486 and Pentium1,
> since CPU branch predictors were either nonexistent or not so good. After
> that, CPU branch predictors became quite good. The macros should have been
> mostly unused 15-25 years ago too, since they optimize for unreadability and
> unwritability. Fortunately they are rarely used in FreeBSD. They were
> imported from NetBSD in 2003 where they are used more (306 instances in 2005
> NetBSD /sys vs 28 instances in 2004 FreeBSD /sys; there are 2208 instances
> of likely() in 2004 linux-2.6.10).
I think it would be reasonable to expect that people deploy branch prediction
macros (as with prefetch, etc) only where there's specific measurements that
indicate they are important to have there -- at the very least, pmc data, but
ideally also benchmarking data.
Robert N M Watson
Computer Laboratory
University of Cambridge
More information about the freebsd-arch
mailing list