从记忆中提取一个单词需要多少时间?
Taking Peter Norvig's advice, I am pondering on the question:
How much time does it take to fetch one word from memory, with and without a cache miss?
(Assume standard hardware and architecture. To simplify calculations assume 1Ghz clock)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在 github.org 上发布了该表中的数据很好的可视化,他们还有一个“人类尺度”对时间价值的重新诠释。
There is a nice visualization of the data in that table published on github.org They also have a "human scale" reinterpretation of the time values there.
此处进行了公平的总结,但有些不精确。当编写时(两年多前),对于当时的中档 PC,估计:内存访问,60ns;一级缓存,10ns; L2 缓存,20-30ns(没有对 L3 缓存访问时间的估计)。当然,这一切都有很大的不同,具体取决于争用和访问模式(因为缓存层通常是从较慢的内存中“按行”填充的,如果您访问地址 X,然后访问地址 X+1,则第二次访问可能会速度会快一点,因为缓存行填充是由第一次访问开始的)。
当然,经过精心调校的高端服务器会更快(此类机器之间内存访问延迟的相对差异通常比“原始”CPU 速度的相对差异大得多)。
Fair summary here, with some imprecision. When written (2+ years ago) and for a mid-range PC of the time, it estimated: memory access, 60ns; L1 cache, 10ns; L2 cache, 20-30ns (no estimates for L3 cache access times). It all varies a lot of course, depending on contention and access patterns (since cache layers are typically filled "by lines" from slower memory, if you access address X then address X+1 the second access may be a bit faster as the cache line filling was started by the first access).
And, of course, a high-end, well-tuned server will be much faster (relative differences between such machines in memory access latency are typically much larger than ones in "raw" CPU speeds).
看起来 Norvig 自己回答了这个问题:
“执行典型指令”= 1 的部分ns 意味着 1 GHz CPU(当然假设高效的流水线)。
我不知道他从哪里获取这些信息,但我相信 Peter Norvig 是可靠的:-)
Seems like Norvig answers this himself:
The part where it says "execute typical instruction" = 1 ns implies a 1 GHz CPU (assuming efficient pipelining, of course).
I don't know where he takes this information, but I trust Peter Norvig to be reliable :-)