Jump to content

What does cache do in a CPU?

Go to solution Solved by mariushm,

The cache keeps important data very close to the CPU cores, where it can be accessed super fast. 

The cache memory often works at super high frequencies and has super low latency but it uses a lot of silicon space therefore it's expensive. The memory sticks are fast, but much slower (lower frequency) than cache memory and with higher latency. Then mass storage (hard drives, SSDs etc) are even slower.

You could imagine yourself sitting at a desk, with a few sheet of paper spread on the desk. If you need to work with data, looking up something on the sheets of paper on the desk is super fast - that's your cache.

The memory sticks (DDR3, DDR4 etc) are like you having stacks of paper in the desk  - you have to open the door to the desk, slide out the compartment or whatever, take the stack of papers and get the sheets.

The SDD / storage is like you getting up from the desk and going to get a stack of papers from another desk or from some storage area - it's much much slower.

 

Think about playing a game, a first person shooter - the game will use some information all the time, and reuse it and update often .. coordinates of the player on the map, how many bullets each weapon has, how much life you have,  where the enemies are, and what the AI determined their behavior should be (go towards you, search for enemies etc)

Each time a frame is calculated, the game has to calculate if the player hit a wall or is hidden by a wall, if some light hits the player and makes a shadow ... the game engine can cache the calculations and redo them much faster compared to requesting the data from the actual memory sticks.

The RAM sticks will hold textures that get applied over objects in the frame, if they can't fit into the video card's ram, game level stuff , audio sounds effects, background music etc etc

I'm having some trouble understanding what cache does in a CPU. I do not know what it does, why it exists and how much cache do you need. Could someone please simplify this for me?

Link to comment
Share on other sites

Link to post
Share on other sites

Cache saves previously processed stuff (could be machine code or other data) so it doesn't have to execute the whole way when the same command is run again. It's however a pointless metric if you're just looking into buying a CPU, benchmarks is still more reliable because cache size cannot be seen as a performance metric.

CPU: i7-2600K 4751MHz 1.44V (software) --> 1.47V at the back of the socket Motherboard: Asrock Z77 Extreme4 (BCLK: 103.3MHz) CPU Cooler: Noctua NH-D15 RAM: Adata XPG 2x8GB DDR3 (XMP: 2133MHz 10-11-11-30 CR2, custom: 2203MHz 10-11-10-26 CR1 tRFC:230 tREFI:14000) GPU: Asus GTX 1070 Dual (Super Jetstream vbios, +70(2025-2088MHz)/+400(8.8Gbps)) SSD: Samsung 840 Pro 256GB (main boot drive), Transcend SSD370 128GB PSU: Seasonic X-660 80+ Gold Case: Antec P110 Silent, 5 intakes 1 exhaust Monitor: AOC G2460PF 1080p 144Hz (150Hz max w/ DP, 121Hz max w/ HDMI) TN panel Keyboard: Logitech G610 Orion (Cherry MX Blue) with SteelSeries Apex M260 keycaps Mouse: BenQ Zowie FK1

 

Model: HP Omen 17 17-an110ca CPU: i7-8750H (0.125V core & cache, 50mV SA undervolt) GPU: GTX 1060 6GB Mobile (+80/+450, 1650MHz~1750MHz 0.78V~0.85V) RAM: 8+8GB DDR4-2400 18-17-17-39 2T Storage: HP EX920 1TB PCIe x4 M.2 SSD + Crucial MX500 1TB 2.5" SATA SSD, 128GB Toshiba PCIe x2 M.2 SSD (KBG30ZMV128G) gone cooking externally, 1TB Seagate 7200RPM 2.5" HDD (ST1000LM049-2GH172) left outside Monitor: 1080p 126Hz IPS G-sync

 

Desktop benching:

Cinebench R15 Single thread:168 Multi-thread: 833 

SuperPi (v1.5 from Techpowerup, PI value output) 16K: 0.100s 1M: 8.255s 32M: 7m 45.93s

Link to comment
Share on other sites

Link to post
Share on other sites

4 minutes ago, SetSakara2 said:

I'm having some trouble understanding what cache does in a CPU. I do not know what it does, why it exists and how much cache do you need. Could someone please simplify this for me?

It provides a way for data to be accessed faster rather than having to pick everything up from RAM, which is slow compared to CPU speeds.

 

Here's a graphical idea of how it works:

http://www.overbyte.com.au/misc/Lesson3/CacheFun.html

FX6300 @ 4.2GHz | Gigabyte GA-78LMT-USB3 R2 | Hyper 212x | 3x 8GB + 1x 4GB @ 1600MHz | Gigabyte 2060 Super | Corsair CX650M | LG 43UK6520PSA
ASUS X550LN | i5 4210u | 12GB
Lenovo N23 Yoga

Link to comment
Share on other sites

Link to post
Share on other sites

It is just physically closer ram that is way faster and has less latency.  The CPU/GPU will try to run what it can in cache in order to speed things up.

AMD 7950x / Asus Strix B650E / 64GB @ 6000c30 / 2TB Samsung 980 Pro Heatsink 4.0x4 / 7.68TB Samsung PM9A3 / 3.84TB Samsung PM983 / 44TB Synology 1522+ / MSI Gaming Trio 4090 / EVGA G6 1000w /Thermaltake View71 / LG C1 48in OLED

Custom water loop EK Vector AM4, D5 pump, Coolstream 420 radiator

Link to comment
Share on other sites

Link to post
Share on other sites

The cache keeps important data very close to the CPU cores, where it can be accessed super fast. 

The cache memory often works at super high frequencies and has super low latency but it uses a lot of silicon space therefore it's expensive. The memory sticks are fast, but much slower (lower frequency) than cache memory and with higher latency. Then mass storage (hard drives, SSDs etc) are even slower.

You could imagine yourself sitting at a desk, with a few sheet of paper spread on the desk. If you need to work with data, looking up something on the sheets of paper on the desk is super fast - that's your cache.

The memory sticks (DDR3, DDR4 etc) are like you having stacks of paper in the desk  - you have to open the door to the desk, slide out the compartment or whatever, take the stack of papers and get the sheets.

The SDD / storage is like you getting up from the desk and going to get a stack of papers from another desk or from some storage area - it's much much slower.

 

Think about playing a game, a first person shooter - the game will use some information all the time, and reuse it and update often .. coordinates of the player on the map, how many bullets each weapon has, how much life you have,  where the enemies are, and what the AI determined their behavior should be (go towards you, search for enemies etc)

Each time a frame is calculated, the game has to calculate if the player hit a wall or is hidden by a wall, if some light hits the player and makes a shadow ... the game engine can cache the calculations and redo them much faster compared to requesting the data from the actual memory sticks.

The RAM sticks will hold textures that get applied over objects in the frame, if they can't fit into the video card's ram, game level stuff , audio sounds effects, background music etc etc

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×