据我了解,缓存是RAM的副本,它被组合在一起,以便在给定空间和时间局部性的情况下执行速度更快。但为什么不立即进入RAM并切断中间人呢?为什么我们需要访问缓存,复制内存(有时甚至不是正确的部分)?
答案 0 :(得分:4)
以下是您的数字,希望他们能回答您的问题
0.5 ns - Execute typical instruction
1 ns - Fetch from L1 cache memory
5 ns - CPU L1 CACHE branch misprediction
7 ns - Fetch from L2 cache memory
100 ns - Mutex lock/unlock
100 ns - Fetch from main memory
20,000 ns - Send 2K bytes over 1Gbps network
250,000 ns - Read 1MB sequentially from memory
10,000,000 ns - Fetch from new disk location (seek)
10,000,000 ns - Read 1MB sequentially from disk
150,000,000 ns - Send packet US to Europe and back
答案 1 :(得分:1)
如果你有TB的硬盘驱动器,你为什么要RAM? :)