Speculative execution
Speculative execution is a processor technique that performs predicted work before its need or correctness is confirmed, discarding results if the prediction is wrong.
Latency
Speculative execution is a processor technique that executes predicted future instructions before their dependencies or control-flow conditions are confirmed.
- How it is used
- Hides latency by starting predicted work before its result is confirmed as necessary.
- How deep it goes
- Defines early execution and examines prediction costs, without detailing CPU predictor circuitry or a runnable implementation.
- Examples
- Uses speculative CPU loads and branches alongside login-time prefetching of user-specific data.
- What you can do after
- Evaluate/understand it by weighing hidden latency against wasted resources and possible latency increases from failed predictions.
Hacking Cryptography
Speculative execution is processor execution of predicted instruction paths before the corresponding control-flow decisions are resolved.
- How it is used
- Connects processor performance features to timing attacks against cryptographic implementations.
- How deep it goes
- Explains prediction, pipeline flushing, cache effects, and a C performance comparison, but stops short of a complete attack trace.
- Examples
- Uses a 100-million-element integer array, a threshold branch, branchless conditional move, and measured sorted versus unsorted timings.
- What you can do after
- Apply branchless comparisons and avoid secret-dependent branching when implementing timing-sensitive cryptographic code.
Read how Hacking Cryptography explains speculative execution →
Related concepts
- predictive techniquekind of · A predictive technique performs an operation before its need is confirmed by forecasting future access, demand, or execution behavior.
- timing attackused by · A timing attack is a side-channel attack that infers information, often secret data, by measuring differences in the time taken to process inputs or perform computations.
- optimistic concurrency controlincludes · Optimistic concurrency control is a concurrency-control technique that allows operations to proceed with limited locking and detects conflicting changes through validation before committing updates.
- prefetchincludes · Prefetching is the proactive retrieval or preparation of anticipated data or resources before they are needed.
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.

