Speculative execution

Speculative execution in computer systems is doing work, the result of which may not be needed. This performance optimization technique is used in pipelined processors and other systems.[1][2]

Contents

Main idea

Speculative execution is a performance optimization. The main idea is to do work that may not be needed. The target is to provide more concurrency if extra resources are available.

The following technologies employ this idea:

Processors

Modern pipelined microprocessors use speculative execution to reduce the cost of conditional branch instructions using schemes that predict the execution path of a program based on the history of branch executions.[2] It turns out that in order to improve performance and utilization of computer resources, some instructions have to be scheduled ahead of time in a place that is not determined that such instructions have to be executed at all, ahead of branch.[3]

Compilers

In compiler optimization for multiprocessing systems, speculative execution involves an idle processor executing code in the next processor block, in case there is no dependency on code that could be running on other processors. The benefit of this scheme is reducing response time for individual processors and the overall system. However, there is a net penalty for the average case, since in the case of a bad bet, the pipelines should be flushed.[4] The compiler is limited in issuing speculative execution instruction, since it requires hardware assistance to buffer the effects of speculatively-executed instructions. Without hardware support, the compiler could only issue speculative instructions which have no side effects in case of wrong speculation.[5]

Eager Execution

Eager execution is a form of speculative execution where both sides of the conditional branch are executed, however the results are committed only if the predicate is true. With unlimited resources, eager execution (also known as oracle execution) would in theory provide the same performance as perfect branch prediction. With limited resources eager execution should be employed carefully since the number of resources needed grows exponentially with each level of branches executed eagerly.[6]

Lazy Evaluation

Lazy evaluation does not speculate. The incorporation of speculative execution into implementations of the Haskell programming language is a current research topic. Eager Haskell is designed around the idea of speculative execution. Recent versions of GHC support a kind of speculative execution with an abortion mechanism to back out in case of a bad choice called optimistic execution.[7]

See also

References

  1. ^ a b Lazy and Speculative Execution Butler Lampson Microsoft Research OPODIS, Bordeaux, France 12 December 2006
  2. ^ a b International Business Machines Corporation. Research Division; Prabhakar Raghavan; Hadas Schachnai; Mira Yaniv (1998). Dynamic schemes for speculative execution of code. IBM. http://books.google.com/books?id=eBgMGwAACAAJ. Retrieved 18 January 2011. 
  3. ^ Bernd Krieg-Brückner (1992). ESOP '92: 4th European Symposium on Programming, Rennes, France, February 26-28, 1992 : proceedings. Springer. pp. 56–57. ISBN 9783540552536. http://books.google.com/books?id=AQbhbphyOsoC&pg=PA56. Retrieved 18 January 2011. 
  4. ^ Phillip A. Laplante (2004). Real-time systems design and analysis. Wiley-IEEE. p. 391. ISBN 9780471228554. http://books.google.com/books?id=kIhdeGVtb-kC&pg=PA391. Retrieved 21 January 2011. 
  5. ^ David J. Lilja; Peter L. Bird (1 January 1994). The interaction of compilation technology and computer architecture. Springer. p. 16. ISBN 9780792394518. http://books.google.com/books?id=D67qFdGbrw0C&pg=PA16. Retrieved 21 January 2011. 
  6. ^ Jurij Šilc; Borut Robič; Theo Ungerer (1999). Processor architecture: from dataflow to superscalar and beyond. Springer. pp. 148–150. ISBN 9783540647980. http://books.google.com/books?id=JEYKyfZ3yF0C&pg=PA148. Retrieved 21 January 2011. 
  7. ^ Optimistic Evaluation: a fast evaluation strategy for non-strict programs

External links