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
- Uses speculative execution to hide latency by performing potentially needed work ahead of time.
- How deep it goes
- Explains prediction and discarded work, compares CPU and application costs, and names several speculative techniques.
- Examples
- Illustrates prefetching user data during authentication and cites speculative branches and memory loads.
- What you can do after
- Evaluate speculative execution by weighing latency savings against prediction errors and resource consumption.
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
- latency hidingimplements · Latency hiding overlaps waiting for delayed operations with other useful work to keep processing resources productive.
- predictive techniquekind of · A predictive technique performs an operation before its need is confirmed by forecasting future access, demand, or execution behavior.
- 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, often to reduce waiting time.
- 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.
Questions about speculative execution
What is 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.
Which Manning books explain speculative execution?
Latency and Hacking Cryptography.
What is the difference between speculative execution and Spectre?
Speculative execution is a processor technique that performs predicted work before its need or correctness is confirmed, discarding results if the prediction is wrong. Spectre is a class of processor vulnerabilities that exploits speculative execution and side channels to expose information across security boundaries.
What kinds of speculative execution are there?
Kinds of speculative execution include optimistic concurrency control and prefetch.
What is speculative execution a kind of?
Speculative execution is a kind of predictive technique. A predictive technique performs an operation before its need is confirmed by forecasting future access, demand, or execution behavior.
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.

