Re: performance impact of branch prediction?
"Nathan J. Williams" <[email protected]> 21 Apr 2006 14:26:18 -0400
| Newsgroups | gmane.os.netbsd.devel.performance,gmane.os.netbsd.devel.kernel |
|---|---|
| Organization | Wasabi Systems, Inc. |
| Message-ID | <[email protected]> |
Hubert Feyrer <[email protected]> writes: > Branch prediction is used in many parts throught the kernel, e.g. > > subr_pool.c: if (__predict_false((pc->pc_pool->pr_flags & PR_WANTED) != 0)) { > subr_pool.c- goto destruct; > subr_pool.c- } > > Does anyone know the performance impact of this prediction? > Were any kind of measurements done? What were the results? Note that __predict_false() isn't really about the microarchitectural concept of branch prediction; it's more about moving code out-of-line to reduce the memory footprint of the common path. That is, the following code: A if (B) C D would typically assemble to something like: A evaluate B if false, goto 1f: C 1f: D changing (B) to __predict_false(B) makes it likely to be rearranged as: A evaluate B if true, goto 2f: 1f: D ... return 2f: C goto 1f I doubt it helps much when the wrapped code is a single goto. At the microarchitectural level, dynamic branch prediction is considered more useful these days than static compiler-generated branch prediction anyway. - Nathan