“CACHE” IT
- January 24th, 2012
- Posted in Programmers Inc.
- Write comment
Considering how your computers and laptops almost virtually replaced all your best pals, this comes as no wonder that the article is on them. Everyone must have heard the word “Cache” sometime or the other. So I take you a level deeper into the architecture of our computer to understand a tad bit more about it.
We are so used to our computers just doing all the things within seconds that i guess we have started taking it for granted. A major reason for this speed is your Cache Memory. You each say it is the little personal deposit of data and instruction the CPU keeps close at hand.
Hard disk is a mechanical device. Therefore, the time taken for the bits & bytes to travel from there all the way to the CPU could be a heavy compromise on the speed. Main memory although a little bit closer, still takes relatively longer to transfer the data.
So, came the cache. Being on the same chip as the processor itself, we don’t have to be a tech geek to deduce the results. Intel currently uses microprocessors with an architecture nicknamed “NEHALEM”. It uses 3 levels of caches. Usually cache sizes are smaller, given the higher cost & limited area available. (That tiny chip of microprocessor you have has got millions of transistors on it!)
The memory is accessed only if the data is not present on any of these cache levels (commonly known as a cache miss). The Intel i7 3960x uses a 32KB each of instruction & data cache, 256KB of unified instruction/data L2 cache for core while 15MB of L3 cache is shared among the cores (for desktops).
Just to give a feel of it here are some actual figures: L1 can work as fast as 2 ns (1 clock cycle), L2 at around 5 ns ,L3 at 10 ns. A memory operation may take around 100ms while the hard disk is stuck at 200ms.
Caches use SRAM technology in comparison to your RAM which uses DRAM. Just like in a memory, we need a mapping to know which data goes where. The core i7 uses 20 way associativity for its L3 cache. What does it mean? Well the cache is divided into sets each having 20 blocks. Now the data is mapped to a parameter set (i.e. can go anywhere in that set) instead of 1 block.
Going into the technicalities of all these right now, what it means is that higher the associativity, better the possibility of finding your data in the cache.
Seeing as there is only so much I can fit into this article without losing your interest, I’ll end it here. While the engineers are still racking their heads over how to increase the speed, the battle between power management and better speeds will always go on.
MEGHNA MEHTA

I spusope this can be useful especially in connection with AJAX enhancements. I’ll take a closer look on this topic for my future developments. Thanks for the information about the caching mechanism in WP2