jump to navigation

Levels of Caching June 8, 2008

Posted by Prabakaran Thirumalai in cache.
Tags: , , , , , , , , ,
trackback

A cache is a collection of data duplicating original values stored elsewhere or computed earlier, where the original data is expensive to fetch or to compute, compared to the cost of reading the cache. (Wiki)

Computers have several levels of caches to speed up the operation, including processor Cache, memory cache and disk cache. Caching can also be implemented for frequent accessed internet pages on the web server and for frequently accessed data(table) for databases. Cache technology is the use of a faster but smaller memory type to accelerate a slower but larger memory type.

When using a cache, you must check the cache to see if an item is in there. If it is there, it’s called a cache hit. If not, it is called a cache miss and the computer must wait for a round trip from the larger, slower memory area.

Levels of Caching

L1 Cache

L1 cache is an abbreviation of Level 1 cache. It is also called as primary cache.
L1 cache is a small, fast memory cache that is built in to a CPU and helps speed access to important and frequently-used data. It is used for temporary storage of instructions and data organised in blocks of 32 bytes.

Write back and Write through cache: Write through happens when a processor writes data simultaneously into cache and into main memory (to assure coherency). Write back occurs when the processor writes to the cache and then proceeds to the next instruction. The cache holds the write-back data and writes it into main memory when that data line in cache is to be replaced. Write back offers about 10% higher performance than write-through, but cache that has this function is more costly. A third type of write mode, write through with buffer, gives similar performance to write back.

Speed: 5 cycles

Granularity : word length (64 bit or 128 bit)

Backend:L2 Cache

L2 Cache

Level 2 cache – also referred to as secondary cache is also present inside the processor.

Speed: 10 cycles

Granularity : word length (64 bit or 128 bit)

Backend:Memory

Memory

Principal level of system memory is referred to as main memory, or Random Access Memory (RAM).

Main memory is attached to the processor via its address and data buses. Each bus consists of a number of electrical circuits or bits. The width of the address bus dictates how many different memory locations can be accessed, and the width of the data bus how much information is stored at each location. Main memory is built up using DRAM chips, short for Dynamic RAM.

RAM is used as a cache for data that is initially loaded in from the hard disk (or other I/O storage systems).

Speed:5 to 50ns

Granularity :4 KB (page size)

Backend: Disk blocks

Disk

Speed: 5 millisecs

Granularity :Files

Backend: Distributed systems.

HTTP Cache

Speed: 1 sec

Granularity :Internet Pages

Backend: Pages on disk

Database Cache

Speed: 1 millisec for select

Granularity: Table, Result Set

Backend: Database connected via network

Comments»

1. CSQL: Yet another in-memory DBMS for caching | DBMS2 -- DataBase Management System Services - April 3, 2009

[...] interesting thing on that blog is a taxonomy of caches — Level 1 cache, Level 2 cache, RAM, disk, etc., with some approximate figures for lookup [...]