# 流缓冲

流缓冲是一种小型硬件预取缓冲，由诺曼·P·朱皮（Norman P. Jouppi）于1990年首次提出。它保存一串在处理器需求访问之前预取的缓存行，使顺序数据在需要之前就已到达，同时主缓存保持不被污染。<sup>[1](https://doi.org/10.1145/325164.325162)</sup><sup> • </sup><sup>[2](https://www.researchgate.net/publication/220244792_Improving_data_cache_performance_with_integrated_use_of_split_caches_victim_cache_and_stream_buffers)</sup>

| 关键事实 | 详情 |
|---|---|
| 起源 | 由数字设备公司西部研究实验室的诺曼·P·朱皮在《通过增加小型全相联缓存和预取缓冲来改善直接映射缓存性能》（ISCA 1990）中提出<sup>[1](https://doi.org/10.1145/325164.325162)</sup> |
| 结构 | 一个全相联的先进先出缓冲，含4或5个条目，每个条目保存一个标签、一个可用位和一条数据行，设计用于支持直接映射缓存<sup>[2](https://www.researchgate.net/publication/220244792_Improving_data_cache_performance_with_integrated_use_of_split_caches_victim_cache_and_stream_buffers)</sup><sup> • </sup><sup>[3](https://www.cs.utexas.edu/~mckinley/papers/zlwang.pdf)</sup> |
| 操作 | 缓存缺失触发将缺失块及后续块预取到缓冲而非缓存中；缓存查找也会探测缓冲，并将命中的条目移入缓存<sup>[2](https://www.researchgate.net/publication/220244792_Improving_data_cache_performance_with_integrated_use_of_split_caches_victim_cache_and_stream_buffers)</sup><sup> • </sup><sup>[3](https://www.cs.utexas.edu/~mckinley/papers/zlwang.pdf)</sup> |
| 目的 | 避免缓存污染，即预取行过早地将有用数据逐出缓存<sup>[2](https://www.researchgate.net/publication/220244792_Improving_data_cache_performance_with_integrated_use_of_split_caches_victim_cache_and_stream_buffers)</sup> |
| 实测效果 | 多路流缓冲的性能几乎是单流缓冲的两倍，并消除43%的总体缺失；流缓冲配合牺牲缓存，其缺失率降低幅度可相当于将缓存容量翻倍或增至四倍<sup>[3](https://www.cs.utexas.edu/~mckinley/papers/zlwang.pdf)</sup><sup> • </sup><sup>[4](https://www.researchgate.net/publication/239668006_Reducing_Compulsory_and_Capacity_Misses)</sup> |
| 现代应用 | MicroBlaze V软处理器实现了一个指令流缓冲，最多可保存两个缓存行，由`C_ICACHE_STREAMS`参数启用<sup>[5](https://docs.amd.com/r/en-US/ug1629-microblaze-v-user-guide/Stream-Buffers)</sup> |

## 机制

流缓冲针对的是向缓存中预取时的一种特定失效模式。当预取行被直接放入直接映射缓存时，一次不准确的预测会逐出程序即将使用的数据，从而降低命中率。朱皮的设计改为将预取行放入一个独立的小型结构中。发生缺失时，缺失块及其后的顺序块被取入流缓冲而非缓存。此后每次缓存查找也会探测流缓冲；一旦命中，该条目被移入缓存，预取从流的新尾部继续。<sup>[1](https://doi.org/10.1145/325164.325162)</sup><sup> • </sup><sup>[3](https://www.cs.utexas.edu/~mckinley/papers/zlwang.pdf)</sup>

由于该缓冲是全相联的并以先进先出方式管理，它能保存那些在直接映射缓存中会发生冲突的块，而不会从缓存本身逐出任何内容。在单流设计中，对流缓冲的缺失会重置缓冲，丢弃过时的流。<sup>[3](https://www.cs.utexas.edu/~mckinley/papers/zlwang.pdf)</sup>

## 起源与朱皮的评估

流缓冲出现在朱皮1990年的ISCA论文中，与另外两种结构——缺失缓存和[牺牲缓存](https://www.edgepedia.org/zh/victim-cache)——一同作为改善直接映射缓存性能的硬件技术被提出。<sup>[1](https://doi.org/10.1145/325164.325162)</sup> 一份1990年的西部研究实验室配套技术报告将流缓冲与两种更简单的替代方案——更长的缓存行和经典预取——进行了比较。报告发现，流缓冲的缺失率低于为每个程序选用最优缓存行大小时的缺失率，并且即使假设每次预取仅花费一个指令发射延迟，其表现也优于或几乎等同于传统预取技术。与牺牲缓存结合使用时，流缓冲通常能将缺失率降低相当于缓存容量翻倍或增至四倍的程度，在某些情况下甚至超过任何缓存容量所能达到的效果。<sup>[4](https://www.researchgate.net/publication/239668006_Reducing_Compulsory_and_Capacity_Misses)</sup>

朱皮后来获得了自适应流缓冲的专利，其中标签增量器通过将步长值加到分配地址或尾部条目的标签上来计算下一个要预取的行地址。所分配的缓冲可以使用增量方法或指令特定预取避免（ISPA）方法进行预取。<sup>[6](https://uspto.report/patent/grant/5958040)</sup>

## 变体

**多路流缓冲。** 交错访问多个大型数据结构的程序会使单流失效，因为每次切换数据结构都会重置缓冲。多路流缓冲同时保持多条流；当对所有缓冲都缺失时，重置最久未命中的缓冲。这几乎使单流缓冲的性能翻倍，并消除43%的总体缺失。<sup>[3](https://www.cs.utexas.edu/~mckinley/papers/zlwang.pdf)</sup> 一项多媒体基准研究比较了流缓冲、步长预测表和一种称为流缓存的混合方案，考察了5路和16路流缓冲等配置。<sup>[7](https://www.researchgate.net/publication/2496047_A_Comparison_Of_Hardware_Prefetching_Techniques_For_Multimedia_Benchmarks)</sup>

**步长流与预测器导向流。** 帕拉查拉（Palacharla）和凯斯勒（Kessler）扩展了流缓冲，将步长与每条流关联，从物理地址空间的分区和历史缓冲中检测步长，使缓冲能够预取非单位步长的模式。<sup>[8](https://cseweb.ucsd.edu/~calder/papers/sair-thesis.pdf)</sup> 预测器导向流缓冲（PSB）由加州大学圣迭戈分校的蒂莫西·舍伍德（Timothy Sherwood）及其同事在第33届国际微体系结构研讨会（2000年12月）上提出，走得更远：流缓冲跟随地址预测流而非固定步长，用置信度技术指导流的分配、优先级排序及其预取请求，针对的是缺失流不规则的指针型应用。<sup>[9](https://cseweb.ucsd.edu/~calder/abstracts/MICRO-00-PSB.html)</sup><sup> • </sup><sup>[8](https://cseweb.ucsd.edu/~calder/papers/sair-thesis.pdf)</sup>

**预取数据的放置。** 后来的预取工作将流缓冲视为“预取数据应放在哪里”这一问题的一种答案。流缓冲为不同的流引入了带有前瞻地址的额外缓冲，以确保及时性而不污染缓存，但由于额外的硬件成本和复杂性，许多预取器直接预取到缓存中，转而根据置信度阈值限制预取或将数据放入更大的高层缓存。<sup>[10](https://ecommons.cornell.edu/server/api/core/bitstreams/329168c5-de09-4f9d-9b45-b3c1ff0a8c56/content)</sup>

## 成本与局限

提前于使用进行预取会带来成本，分离缓冲的设计缓解了这些成本但并未消除。激进的预取有可能用不必要的数据污染缓冲缓存并逐出有用数据，增加物理内存压力，使正确预取的页面在使用前被逐出，在不必要的读取上浪费I/O带宽，并拥塞设备队列；当内存稀缺且可预测的顺序访问使得计算最小提前量很容易时，风险最大，此时提前更多工作几乎没有好处。<sup>[11](https://www.usenix.org/legacy/event/hotos05/final_papers/full_papers/papathanasiou/papathanasiou_html/index.html)</sup> 无效预取还会限制总线带宽并争夺缓存端口；根据历史信息对好坏预取进行分类的动态预取污染过滤，可以将无效预取减少90%以上，与激进预取器结合时性能提升可达16%。<sup>[12](https://research.ibm.com/publications/reducing-cache-pollution-via-dynamic-data-prefetch-filtering)</sup>

## 现代实现

流缓冲的思想在当代处理器中得以延续。MicroBlaze V软处理器在参数`C_ICACHE_STREAMS`设为1时，会从最后请求的地址之后按顺序推测性地取缓存行，直到其最多可保存两个缓存行的流缓冲填满；从预取行请求的指令（这在线性代码中发生）立即可用，因此处理器等待指令取出的时间更少。`C_ICACHE_DATA_WIDTH`参数决定每个时钟周期从流缓冲传输32位还是一整个缓存行。<sup>[5](https://docs.amd.com/r/en-US/ug1629-microblaze-v-user-guide/Stream-Buffers)</sup> 研究型预取器继续在该框架上构建，将预取缓冲用作预测与缓存填充之间的暂存区。<sup>[13](https://doi.org/10.1145/3725843.3756081)</sup>

## References

1. [Norman P. Jouppi (1990). Improving Direct-Mapped Cache Performance by the Addition of a Small Fully-Associative Cache and Prefetch Buffers. ACM SIGARCH Computer Architecture News 18(2SI), 364–373.](https://doi.org/10.1145/325164.325162)
2. [Improving data cache performance with integrated use of split caches, victim cache and stream buffers (ResearchGate)](https://www.researchgate.net/publication/220244792_Improving_data_cache_performance_with_integrated_use_of_split_caches_victim_cache_and_stream_buffers)
3. [Zhong Lu Wang, thesis chapter on stream buffers, University of Texas at Austin](https://www.cs.utexas.edu/~mckinley/papers/zlwang.pdf)
4. [Norman P. Jouppi (1990). Reducing Compulsory and Capacity Misses. WRL Technical Note.](https://www.researchgate.net/publication/239668006_Reducing_Compulsory_and_Capacity_Misses)
5. [Stream Buffers, MicroBlaze V Processor Reference Guide (UG1629), AMD](https://docs.amd.com/r/en-US/ug1629-microblaze-v-user-guide/Stream-Buffers)
6. [Adaptive stream buffers, US Patent 5,958,040 (Jouppi, Digital Equipment Corporation)](https://uspto.report/patent/grant/5958040)
7. [Zucker, Flynn, Lee (2002). A Comparison of Hardware Prefetching Techniques for Multimedia Benchmarks.](https://www.researchgate.net/publication/2496047_A_Comparison_Of_Hardware_Prefetching_Techniques_For_Multimedia_Benchmarks)
8. [Predictor-Directed Stream Buffers, PhD thesis chapter, University of California, San Diego](https://cseweb.ucsd.edu/~calder/papers/sair-thesis.pdf)
9. [Sherwood et al. (2000). Predictor-Directed Stream Buffers. MICRO-33.](https://cseweb.ucsd.edu/~calder/abstracts/MICRO-00-PSB.html)
10. [Software-Oriented Hardware, Cornell University](https://ecommons.cornell.edu/server/api/core/bitstreams/329168c5-de09-4f9d-9b45-b3c1ff0a8c56/content)
11. [Papathanasiou and Scott. Aggressive prefetching: power, pollution and congestion risks. HotOS X.](https://www.usenix.org/legacy/event/hotos05/final_papers/full_papers/papathanasiou/papathanasiou_html/index.html)
12. [Zhuang and Lee (2007). Reducing Cache Pollution Via Dynamic Data Prefetch Filtering. IEEE Transactions on Computers.](https://research.ibm.com/publications/reducing-cache-pollution-via-dynamic-data-prefetch-filtering)
13. [RICH Prefetcher: Storing Rich Information in Memory to Trade Capacity and Bandwidth for Latency Hiding. MICRO 2025.](https://doi.org/10.1145/3725843.3756081)

---
*Initially written Oct 15, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 计算机硬件 › Processors & processor engineering › Computer architecture theory › Memory hierarchy and caching

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/stream-buffer

English original: https://www.edgepedia.org/stream-buffer
