Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does larger cache size always lead to improved performance?

Since cache inside the processor increases the instruction execution speed. I'm wondering what if we increase the size of cache to many MBs like 1 GB. Is it possible? If it is will increasing the cache size always result in increased performance?

like image 401
Taha Taha Avatar asked Feb 19 '13 10:02

Taha Taha


People also ask

Does increasing cache size affect performance?

Cache memory is a large determinant of system performance. The larger the cache, the more instructions can be queued and carried out. Storing instructions in cache reduces the amount of time it takes to access that instruction and pass it to a CPU core.

Is bigger cache always better?

It's an area of more easily accessed memory for the CPU to store data it needs to continue computing. A computer with a larger cache is faster because it takes less time to retrieve information from its own memory than if it had to go back and fetch it from remote storage devices like hard drives and RAM.

Does higher cache size guarantee higher hit rate?

Cache hit ratio is higher with the most popular photos. Cache ratio improves with larger caches. (Doubling the size of the edge cache increased the ratio from 59% to 65%.


2 Answers

There is a tradeoff between cache size and hit rate on one side and read latency with power consumption on another. So the answer to your first question is: technically (probably) possible, but unlikely to make sense, since L3 cache in modern CPUs with size of just a few MBs has read latency of about dozens of cycles.

Performance depends more on memory access pattern than on cache size. More precisely, if the program is mainly sequential, cache size is not a big deal. If there are quite a lot of random access (ex. when associative containers are actively used), cache size really matters.

The above is true for single computational tasks. In multiprocess environment with several active processes bigger cache size is always better, because of decrease of interprocess contention.

like image 138
leventov Avatar answered Oct 17 '22 13:10

leventov


This is a simplification, but, one of the primary reasons the cache increases 'speed' is that it provides a fast memory very close to the processor - this is much faster to access than main memory. So, in theory, increasing the size of the cache should allow more information to be stored in this 'fast' memory, and thereby improve performance.. In the real world things are obviously much more complex than this, and there will of course be added complexity, and cost, associated with such a large cache, and with dealing with issues like cache coherency, caching algorithms etc.

like image 40
Michael Avatar answered Oct 17 '22 15:10

Michael