What is the cost of memory access?

Posted by Jurily on Stack Overflow See other posts from Stack Overflow or by Jurily
Published on 2010-06-14T16:33:01Z Indexed on 2010/06/14 16:42 UTC
Read the original article Hit count: 173

We like to think that a memory access is fast and constant, but on modern architectures/OSes, that's not necessarily true.

Consider the following C code:

int i = 34;
int *p = &i;

// do something that may or may not involve i and p

{...}

// 3 days later:

*p = 643;

What is the estimated cost of this last assignment in CPU instructions, if

  • i is in L1 cache,
  • i is in L2 cache,
  • i is in L3 cache,
  • i is in RAM proper,
  • i is paged out to an SSD disk,
  • i is paged out to a traditional disk?

Where else can i be?

Of course the numbers are not absolute, but I'm only interested in orders of magnitude. I tried searching the webs, but Google did not bless me this time.

© Stack Overflow or respective owner

Related posts about language-agnostic

Related posts about memory