关于本章
本章讨论CPU Speculative execution,我是在学习C-family language的branch prediction optimization technique的时候,发现的这个主题。
wikipedia Speculative execution
NOTE: "speculative" 的意思是"投机的、思索的、预测的"
Speculative execution is an optimization technique where a computer system performs some task that may not be needed. Work is done before it is known whether it is actually needed, so as to prevent a delay that would have to be incurred by doing the work after it is known that it is needed. If it turns out the work was not needed after all, most changes made by the work are reverted and the results are ignored.
The objective is to provide more concurrency if extra resources are available.
NOTE: 此处对它的目的是总结是: provide more concurrency
This approach is employed in a variety of areas, including:
1 branch prediction in pipelined processors,
2 value prediction for exploiting value locality,[1]
3 prefetching memory and files, and
4 optimistic concurrency control in database systems.[2][3][4]
5 Speculative multithreading is a special case of speculative execution.
NOTE: Speculative execution是一种非常重要的optimization technique,它的目的是: "provide more concurrency"(参见上面的描述)。
它在computer science的各个field中都有着应用。
这体现了: "a technique/thought can be used in a variety of areas",即 "同一个思想,在不同领域的应用",从下面的 "Variants" 章节可以看出,在不同领域对这个思想进行运用的时候,往往会进行一定的调整,因此会产生新的concept。
Overview
NOTE: 原文这一段所描述的是 Branch predictor
Variants
Speculative computation was a related earlier concept.[6]
Eager execution
See also: Eager evaluation
Predictive execution
See also: Pipeline (computing)
Main article: Branch predictor
Common forms of this include branch predictors and memory dependence prediction. A generalized form is sometimes referred to as value prediction.[1][8]
NOTE: 在后面章节会进行描述
Related concepts
Lazy execution
Main article: Lazy evaluation
Lazy execution is the opposite of eager execution, and does not involve speculation.
经典例子
最能够体现CPU Speculative execution 的例子就是: stackoverflow Why is processing a sorted array faster than processing an unsorted array? ,它被收录于Branch-predictor
章节。