mumblings on branch prediction
This commit is contained in:
parent
201384442f
commit
8baa4589e3
@ -859,6 +859,22 @@ Techniques specific to the architecture running the code
|
|||||||
* reducing pointer chasing
|
* reducing pointer chasing
|
||||||
* temporal and spacial locality: use what you have and what's nearby as much as possible
|
* temporal and spacial locality: use what you have and what's nearby as much as possible
|
||||||
* branch prediction
|
* branch prediction
|
||||||
|
* remove branches from inner loops:
|
||||||
|
if a { for { } } else { for { } }
|
||||||
|
instead of
|
||||||
|
for { if a { } else { } }
|
||||||
|
benchmark due to branch prediction
|
||||||
|
structure to avoid branch
|
||||||
|
|
||||||
|
if i % 2 == 0 {
|
||||||
|
evens++
|
||||||
|
} else {
|
||||||
|
odds++
|
||||||
|
}
|
||||||
|
|
||||||
|
counts[i & 1] ++
|
||||||
|
"branch-free code", benchmark; not always faster, but frequently harder to read
|
||||||
|
|
||||||
* function call overhead
|
* function call overhead
|
||||||
* reduce data copies
|
* reduce data copies
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user