cache and write buffer and tlb

concept

哪个先出现,这个问题比较难回答,因为它们的历史可以追溯到计算机的早期。
	早期的计算机并没有像现代计算机那样拥有Cache和Write Buffer,之后随着计算机的发展,这些技术开始逐渐普及和应用。
	可以说,Cache和Write Buffer的发展是同时的,它们是为了解决不同的性能瓶颈而被开发出来的。

Write buffer
	是一种 store 指令 不会被写入主存储器 但被写入到缓存区域 的技术
		缓解了CPU和内存之间的延迟,
		加速了数据写入的速度。
	也称为 store buffer
	是CPU内部的一种结构,通常比L1 Cache更小。 

Cache
	是存储器的一种形式,用于临时存储CPU运行时经常使用的数据和指令。
	Cache分为内部缓存和外部缓存。
	内部缓存包括L1 Cache和L2 Cache,是安装在CPU内部的,用于临时存储CPU运行时需要的指令和数据。
	外部缓存是指安装在CPU芯片之外的存储器,比如L3 Cache和主存储器,用来提高系统整体的读写性能。

Compare

cache和write buffer是两种不同的设计。
	cache是用来存储被频繁访问的数据,以提高访存速度
	write buffer则是用来临时存储写操作的数据,避免写操作阻塞CPU。


cache 也可以存储写操作的数据,为什么不能替代 write buffer 呢

	虽然cache也可以存储写操作的数据,
		但是它并不是为了解决写操作的性能瓶颈而设计的,
		所以在处理写操作时并不如write buffer有效。
		write buffer还可以对写操作进行优化,如将多个小的写操作合并成一个大的写操作,从而减少写操作对CPU的影响。
		因此,在需要处理大量写操作的场景下,write buffer依然是必要的。

cache writebuffer tlb ARM32-TCM
number many few less few
Location Internal L1/2 External L3 Internal (between cache and cpu) MMU SOC
Will the data for read operations be stored? meeting Won't No, only the page table entries of the tablewalk process will be stored. X64 CAT
Will the data for write operations be stored? meeting meeting Won't ARM64 System Cache
Performance when storing data for write operations Low high none RISCV Scratchpad Memory
Optimizations when storing data for write operations No merge write operations none
Design goals Store frequently accessed data to increase memory access speed Solve the performance bottleneck problem of write operations on the CPU Reduce memory access in table walk to increase memory access speed Stores the executed binary instructions and data to improve the instruction fetch speed
When brushing, where will the data go? Memory cache Data is cleared directly without backup If you don’t know how to brush, the initialization will be fixed. Generally, you can’t do dynamic programming.

question


cache 和 write buffer 都会存储写操作的数据,假设往一个地址A写了值B . 刷cache 的时候会不会造成一次内存写入? 刷 write buffer 的时候会不会造成一次内存写入?

写操作会首先被写入 write buffer,然后被异步地写入 cache。然后该操作就完成了,不会立即写入内存

当 write buffer 被刷写时,其中包含的写操作会被异步地写入 cache,
	这个过程也不会立即导致一次写入,只是会将 write buffer 中的数据刷入 cache,重复的会被删掉
	然后再根据具体的硬件实现,将 cache 中的数据写入主存。
所以,在 cache 和 write buffer 都enable的情况下,  最终会造成一次内存写入

Guess you like

Origin blog.csdn.net/u011011827/article/details/131261351