Approximate cost to access various caches and main

2019-01-01 08:01发布

Can anyone give me the approximate time (in nanoseconds) to access L1, L2 and L3 caches, as well as main memory on Intel i7 processors?

While this isn't specifically a programming question, knowing these kinds of speed details is neccessary for some low-latency programming challenges.

109条回答
浮光初槿花落
2楼-- · 2019-01-01 08:08

Cost to access various memories in a pretty page

Summary

  1. Values having decreased but are stabilized since 2005

            1 ns        L1 cache
            3 ns        Branch mispredict
            4 ns        L2 cache
           17 ns        Mutex lock/unlock
          100 ns        Main memory (RAM)
        2 000 ns (2µs)  1KB Zippy-compress
    
  2. Still some improvements, prediction for 2020

       16 000 ns (16µs) SSD random read (olibre's note: should be less)
      500 000 ns (½ms)  Round trip in datacenter
    2 000 000 ns (2ms)  HDD random read (seek)
    

See also other sources

See also

For further understanding, I recommend the excellent presentation of modern cache architectures (June 2014) from Gerhard Wellein, Hannes Hofmann and Dietmar Fey at University Erlangen-Nürnberg.

French speaking people may appreciate an article by SpaceFox comparing a processor with a developer both waiting for information required to continue to work.

查看更多
闭嘴吧你
3楼-- · 2019-01-01 08:09
看淡一切
4楼-- · 2019-01-01 08:09
爱死公子算了
5楼-- · 2019-01-01 08:09
人气声优
6楼-- · 2019-01-01 08:09
人间绝色
7楼-- · 2019-01-01 08:09

Look at this "staircase" plot, perfectly illustrating different access times (in terms of clock tics). Notice the red CPU having an additional "step", probably because it has L4 (while others don't).

Graphs of access times with different memory hierarchies

Taken from this Extremetech article.

In computer science this is called "I/O complexity".

查看更多
登录 后发表回答