3 ms·
It's the first time through the loop after each time the loop is evicted from the instruction cache. If the loop is short or has been unrolled heavily (causing
by prodigal_erik 16y ago
It's the first time through the loop after each time the loop is evicted from the instruction cache. If the loop is short or has been unrolled heavily (causing each branch to be predicted separately) it could matter.
- nkurz 16y agoIs the Branch Target Buffer synonymous with the instruction cache[1]? But yes, it certainly can matter. I thought the links that 'wendroid' offered above were interesting: a Scheme interpreter, presumably already fairly well optimized, saw about a 10% improvement through the hinting macros. But I'd argue that if this level of optimization is required, the bigger gains are to be see through changing your algorithms to become more regular: for example, using fixed length blocks in a compression scheme rather than checking for null termination [2]. But if this is for some reason impossible, then use hinting! [1] http://www.agner.org/optimize/microarchitecture.pdf http://www.agner.org/optimize/microarchitecture.pdf [2] http://www2008.org/papers/pdf/p387-zhangA.pdf http://www2008.org/papers/pdf/p387-zhangA.pdf
- prodigal_erik 16y agoThanks, I didn't know that branch predictions are now cached separately from instruction decodings. Hopefully evictions are a rarer problem.