根本原因,
读是在 cpu pipe line 中进行,而写是 back end work,所以 读 out of order 会带来性能的提高
比如 read a 发生 cache miss, read b 可以继续,同时如果b也发生cache miss 二者latency 可以重叠。写没有必要touch cache, 还因为写必须保证顺序否则结果几乎不可逆。
借这个帖子写写对这些patch 的优化思想。
先说在 CPU 中 写和读的顺序:
1、Reads are not reordered with other reads.
真正的操作是:在cpu 内部所有的读操作都可以 out of order
但是提交是in program order所以我们会看到读操作是 in program order.
2、Writes are not reordered with older reads.
所有的写操作从进入cpu 到出来都是in (program) order