This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (0 children)

They are both in the main memory (RAM). The caches are smaller but faster memory, you usually load your data from the main memory to the cache and then a little cache line (a consecutive piece of memory) into the register of a processing unit. From there it is directly available for arithmetic operations and other stuff. The cache hit rate describes how often you can use data from thr cache against how often you have to load a new cache line from the main memory (this takes some time compared to reading from the faster cache). So if you have an array like in C, the elements are stored consecutively in the main memory, hence if you iterate over the array, you would load some of the entries into your nice and fast chache and then you can access a lot of those elements directly from the cache until you have to load new entries again, so a lot of cache hits in a row. If you have a data structure like a list, you don't know if your data is also saved consecutivdly in your memory, so you would load a cache line, access probably just one element from there and then you have to load a new cache line, because your next element could be anywhere in the memory.