liveBook · Manning

Branch prediction

Branch prediction is a processor technique that forecasts the outcome or path of a control-flow branch before it is resolved.

How 2 Manning books explain it

Hacking Cryptography

Branch prediction is a processor mechanism that forecasts the outcome or target of a control-flow branch to keep instruction execution supplied.

How it is used
Explains how data-dependent control flow changes processor performance and motivates branchless techniques for cryptographic implementations.
How deep it goes
Demonstrates prediction patterns, compares timings, and reaches CMOV-based code, but does not detail predictor hardware internals.
Examples
Uses a threshold-summing loop, sorted and unsorted arrays, CMOV inline assembly, and measured GCC program output.
What you can do after
Diagnose performance variation by comparing branch patterns and apply conditional moves to construct a branchless implementation.

Read how Hacking Cryptography explains branch prediction →

100 Go Mistakes and How to Avoid Them

Branch prediction is a processor technique that forecasts the outcome of a conditional branch so subsequent instructions can be executed speculatively.

How it is used
Explains how processors mitigate conditional-branch stalls while exploiting instruction-level parallelism.
How deep it goes
Explains control hazards, prediction, pipeline flushing, and penalties, but stops short of predictor implementation details.
Examples
Uses Go increment loops, conditional checks, execution diagrams, and contrasting dependency structures.
What you can do after
Diagnose performance effects by relating conditional branches and data dependencies to speculative execution and pipeline stalls.

Read how 100 Go Mistakes and How to Avoid Them explains branch prediction →

Related concepts

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.