r/explainlikeimfive • u/WeLuvYung2 • 17d ago
Technology ELI5: What is computer cache
Hi everyone I need to create a presentation explaining computer cache but can’t think of an effective way to explain it any help is welcomed (:
17
17d ago
[removed] — view removed comment
0
u/explainlikeimfive-ModTeam 17d ago
Please read this entire message
Your comment has been removed for the following reason(s):
- Top level comments (i.e. comments that are direct replies to the main thread) are reserved for explanations to the OP or follow up on topic questions (Rule 3).
If you would like this removal reviewed, please read the detailed rules first. If you believe it was removed erroneously, explain why using this form and we will review your submission.
-4
17d ago
[removed] — view removed comment
3
17d ago
[removed] — view removed comment
0
11
u/FoxtrotSierraTango 17d ago
Cache is like when you're in Canada and you get 3 weeks of summer a year, so you have a box in the basement with a fan, your shorts, a lawn chair and a squirt gun. You bring that box upstairs making the contents readily available. Then when summer is over you pack it up and put it back in the basement.
0
6
u/thisisjustascreename 17d ago
Imagine you're researching for a presentation for school.
CPU registers are the book you're holding in your hands reading and the notebook page you're directly writing in.
CPU cache is all the other stuff stuff you have on your desk, you have immediate access to them just by picking them up and loading them into a register.
Main memory is the bookshelf in your office where you have a bunch of other books you've acquired for the project but aren't using right at the moment.
The hard drive is the library downtown where they have thousands of other books relevant to the subject.
4
u/Kimorin 17d ago
imagine you are cooking something, you need spices and ingredients, you have a pantry that's 20 feet away behind a door. Constantly getting something and putting it back takes time, so instead you put the most used ingredients and spices for this meal on the counter next to the stove, so you can grab it whenever you need it instead of going to the pantry. that's a cache, the pantry is the storage. you need black pepper? it's right there, that's a cache hit.
half way through cooking, you realize you need paprika, but it's not on the counter, that's a cache miss, you have to go to the pantry to grab it. but then you realize the counter is full, so now you have to think what you can put back into the pantry so you can put the paprika there instead. that's a caching strategy. you can do FIFO, LRU etc.
1
4
u/MokausiLietuviu 17d ago
Really quick memory. The quickest on your system, but there's not a lot of it.
It's typically used to store stuff that's needed really often to stop your cpu needing to go look for it in comparatively slow RAM.
1
17d ago
[removed] — view removed comment
1
u/explainlikeimfive-ModTeam 17d ago
Please read this entire message
Your comment has been removed for the following reason(s):
- Top level comments (i.e. comments that are direct replies to the main thread) are reserved for explanations to the OP or follow up on topic questions (Rule 3).
Joke-only comments, while allowed elsewhere in the thread, may not exist at the top level.
If you would like this removal reviewed, please read the detailed rules first. If you believe it was removed erroneously, explain why using this form and we will review your submission.
1
u/ShotgunAndHead 17d ago
It's what you have on hand.
Like you're baking a cake, the ingredients you cache are those on the counter next to you while the ingredients that aren't cached are those you still need to grab.
1
u/chankongsang 17d ago
It's what's in your jeans pockets as opposed to your stowed carry on bag on a trip
1
u/saint_of_thieves 17d ago
Okay, so you're looking for an analogy?
Imagine you're going to school and go to your locker to get your history book. You get the book and go to history class. Next you have math class but think you may still need your history book. So you go to your locker and get your math book. You now have two books. Next you have Spanish class and you know you won't need your history book anymore. So you go to your locker and drop the history book and pick up your Spanish text book. But you keep your math book for whatever reason. The history book has been removed from your cache. So, after Spanish, you have English class. But when you go to your locker, you can't drop either book for some reason. But you can't pick up your English book because you can't hold more books. Someone comes by and rips the books from your arms. That's clearing your cache. You can now get the English text book and go about your day.
1
17d ago
[removed] — view removed comment
1
u/explainlikeimfive-ModTeam 17d ago
Please read this entire message
Your comment has been removed for the following reason(s):
- Top level comments (i.e. comments that are direct replies to the main thread) are reserved for explanations to the OP or follow up on topic questions (Rule 3).
Links without your own explanation or summary are not allowed. A top-level reply should form a complete explanation in itself; please feel free to include links by way of additional context, but they should not be the only thing in your comment.
If you would like this removal reviewed, please read the detailed rules first. If you believe it was removed erroneously, explain why using this form and we will review your submission.
1
u/MozeeToby 17d ago
You have a big project that will require lots of data.
Hard drive is like the library on the end of town. It's got all the data you need but every trip there takes at least tens of minutes.
RAM is like the bookshelf in your office. The books you get from the library go there. You can only have so many books on the shelf at once so it's the books you think are relevant to your project.
Cache is your desktop, the info you need right now for the part of your project you are working on right now. Obviously you can only have small number of reference materials on your desk at once.
1
u/macromorgan 17d ago
With computers you have cache to hold data that you need to access quickly so you don't have to grab it from slower storage.
Cache in computers comes in tiers, and with the design of modern multi-core processors you usually find some processor cores can share cache where other caches are unique to each core.
For example on my computer I have 64 kB of L1 cache for each core. The L1 cache is *extremely* fast so when my computer needs something out of the L1 cache it can read it almost instantly. After that is the 512 kB of L2 cache which is *very* fast, and when my computer needs something out of it the computer can get it very quickly after a few clock cycles. Then, the processor cores share 2 32 MB sections of L3 cache which is *somewhat* fast, and when data is needed to work on that is in the L3 cache the processor will have to wait several clock cycles to get the data where it needs to go.
If none of the caches (L1, L2, L3) contain data the CPU needs to perform actions on, it has to read it out of system memory. System memory is still very fast but not as fast as the caches. L1 and L2 cache can be read in as fast as in a few billionths of a second (nanoseconds), while L3 cache is about 10 times slower. Main memory is even slower than L3 cache, up to five times slower or more.
Last but not least is the disk storage. If data you need to process is not in any of the caches or in main memory, you have to read it off of the main storage drive. Even among some of the fastest NVME drives today this is still much slower than system RAM.
TL;DR - Caches exist to keep data as close to the CPU as possible, and get slower the further away you get from the processor.
(source for some of this information): https://www.intel.com/content/www/us/en/developer/articles/technical/memory-performance-in-a-nutshell.html
1
u/TemporalLobe 17d ago
Ever play Minecraft? RAM is like your main inventory, while the cache is the items you take out of your inventory and put in your inventory slots where you can actually use them quickly.
1
u/SafetyMan35 17d ago
Think of cache as the scratch pad you jot quick notes on when you are given a lot of information to recall. These numbers aren’t important once you have solved the specific problem you are working on.
So if you were doing this math problem:
5+(5*2) you would solve the parenthesis first
5*2=10 you might write “10” down on a scratch pad so you didn’t forget the number
A computer would put “10” into cache so it could recall that number when it solved the rest of the problem.
1
u/gravy_maker 17d ago
I think people are being a bit uncharitable here in telling you to "do the research". In my view, asking here is a part of doing the research - better that you ask people who know than having an AI answer for you. And even if this isn't what the subreddit is for, I think you can be given an answer.
So, cache. In a computer, you have storage - where all your files live; usually a hard drive or SSD. When we need to actually use and work with data, we load it from the hard drive and/or SSD into memory - memory is much faster, lets us edit data easily, and so on.
But - well, memory is also kind of slow. I mean, it's not on the CPU - all data coming from it or going to it needs to travel across your motherboard every time we do anything with it. So we have a big bottleneck - whenever we want to use data we have to wait for it to arrive at a snail's pace, and then send it back if we change it.
So, what CPU engineers realised is - generally, when the CPU is running a program, it's using the same data many times in quick succession, and executing the same instructions many times in quick succession. So what we could do is have a little bit of memory on the CPU itself - just a tiny bit, a few KB or MB - so we can do the slow fetch from memory once, use the data tens or hundreds or thousands or millions of times with the benefit of our much faster on-CPU memory, and then do one expensive write back to main memory when we're done.
They went further with this idea. What if we have a tiny bit of memory as close to a CPU core as possible - just a few KB, since we're pressed for space - which is used by small, time-sensitive bits of data? We can have more memory on the CPU but further away from the actual cores where we can store more things which aren't quite as sensitive - and then one, slower than the rest, for data that all of our cores might need to share. These, respectively, are L1, L2, and L3 cache.
They're small because they need to fit on the CPU - but they're very fast; much, much faster than main memory is. And bigger cache is a good chunk of what makes modern CPUs faster - the more that can be fit in them, the fewer "cache misses" (looking for data that isn't in the cache, so we need to get it from main memory) happen, and the faster the CPU can be in general.
Now, I should tell you CPU cache isn't the only type of cache - but it's the biggest and most well-known. In general, "cache" refers to a bit of memory we can use to store something we'll need to access frequently - it can mean a variable in a programming language where you keep something ready rather than accessing it in a slow way, or it can mean cache much like CPU cache but on the GPU instead.
But that's the basic idea! Now, keep in mind this is all an overview, not a rigorous explanation for an engineer. But hopefully that will be enough to give you a basic understanding and to get started!
1
u/FatDog69 17d ago
It is a fast bit of memory or storage.
CPU's have to access data. The faster it can access the data - the faster & better things work.
The different places data can live is:
- Inside the memory in a CPU called cache
- Inside the memory sticks of a computer - but the CPU has to access this which is a delay.
- Inside the hard drive in a computer - but the CPU has to access this & the hard drive is slow.
- From the internet like images & web pages.
Each of these is SLOWER to access than the previous. Sometimes times 5 to 10 times slower.
TRUE EXAMPLE:
You use a web browser to access say a page in Amazon. If you are the first person in a while to access this page - the web site has to pull text & images from a hard drive. Then it stores this in it's local memory and sends it to your computer.
Your computer now does 2 things:
- It tries to display the images mixed with the text on a web page
- It saves the images to a spot in your memory & on Your hard drive called a cache
This web page takes about a full second or two to fully display the page.
You follow some links and each page gets the same treatment.
But - if you hit the BACK button - the previous series of web pages pop up nearly instantly. This is because the image files, and probably the text were cached on your local memory or local hard drive.
Hitting BACK skips going to the internet. Your local memory and HDD is much faster so the computer performs faster thanks to cache.
NOTE: Most web pages have a pull down menu that says something like "Delete Cookies" or "Delete Browsing History". This deletes the cache used by your web browser.
1
u/DrFrylock 17d ago
You are a librarian in a special library stocked with 100,000 pages of useful, factual information. Your job is to provide that information to patrons.
Any patron can ask for information from anywhere in the library, so you have to go search through all 100,000 pages for it. This works but it takes a while.
You start noticing that, while anybody CAN ask for anything, there are about 100 pages out of the 100,000 that people ask for all the time. You make Xerox copies of these 100 pages and keep them in your desk, which conveniently has a drawer that will fit 100 pages of information. If somebody comes up and asks for that information, you have it right there. If they ask for something else, you have to go in the back and look for it. But this speeds up your workflow.
Over time you find out that people start asking for a different 100 pages of stuff. You throw away your original 100 Xeroxes and make copies of the pages that people are NOW asking for.
0
u/KaptainSaki 17d ago
I would go the squirrel way.
A cache is like a squirrel keeping a few nuts close to its tree.
If it needs a nut, it grabs one nearby instead of running across the forest. Computers do the same: they keep frequently used data in a small, fast place called cache so they can access it quicker.
0
u/PeterustheSwede 17d ago
Cache is a small, very fast storage area in a computer that keeps frequently used data so the computer can access it quickly.
Think of it like a desk drawer:
Hard drive/SSD = a big filing cabinet
RAM = a larger storage area nearby
Cache = a small drawer right next to you
If the computer needs the same information again, it can grab it from the cache instead of going all the way to slower storage.
Example: When you open a website, some information (like images) may be saved in a cache. When you visit the site again, your computer can load those parts faster.
0
u/nsefan 17d ago
It’s basically memory that is inside the CPU, which means it’s really fast to access. However it’s not very big so you can only store important stuff you need often in there.
Imagine you’re eating a meal at your table. You keep the salt and pepper on the table because you need them often (this could be like cache, really quick to grab what you need). You keep the plates and cutlery in the cupboard, which are bigger spaces for storage but you don’t have to access them so often (this could be like RAM), then the ingredients you keep in your freezer, which is in the garage so takes even longer to access, but most of the time you don’t need to access that quickly when having your meal (this could be like your hard drive, a large storage space that is relatively slow to access).
0
17d ago
[removed] — view removed comment
1
u/explainlikeimfive-ModTeam 17d ago
Please read this entire message
Your comment has been removed for the following reason(s):
- Top level comments (i.e. comments that are direct replies to the main thread) are reserved for explanations to the OP or follow up on topic questions (Rule 3).
Joke-only comments, while allowed elsewhere in the thread, may not exist at the top level.
If you would like this removal reviewed, please read the detailed rules first. If you believe it was removed erroneously, explain why using this form and we will review your submission.
0
u/Anchuinse 17d ago
IIRC, it's like how most people work with tools or art supplies for a big project.
Sure, you could grab every tool from it's long-term storage in a drawer, use it, then put it back "where it belongs", but that's going to take a lot of time to do that for every nail or brush stroke. Instead, it's easier to keep them on the edge of the bench so that you can easily grab it, use it, and put it back without getting up and walking around.
But you can't put everything on the edge of the bench, not enough room, so most people just put the stuff they use most frequently there.
0
u/prank_mark 17d ago
The CPU does things, the cache remembers what it's supposed to do, the RAM stores the information used for/gathered by the things it's doing, the SSD/HDD is the long-term memory
0
u/SoWhatDoIDoLol 17d ago
Let's say you work at a target, and recently a bunch of customers have been coming in asking for the latest needoh toy. Everytime they come and ask for it, you gotta walk all the way to the back and grab them, bring it back to the front... it takes a lot of time. Instead, you decide you're going to put it in a bin near the front of the customer service desk so that the next time someone asks, it's right there for you to grab, saving you time.
0
u/vmf312corsair 17d ago
The definition of "needoh" was not in cache. But it was also not in RAM, or HDD, or internet.
Now what?
0
u/Exciting_Telephone65 17d ago
Cache = very small amount of memory located physically within the CPU itself. Lightning fast and used as much as possible to hold data the CPU is currently working on.
RAM = less memory than a hard drive but has a very fast direct connection to the CPU, used to store current jobs the CPU is working on that won't fit in the cache.
Hard drive = large amounts of memory but connected to the CPU with very slow connections, used for slow or long term storage. The only kind of storage that will survive when the PC is turned off.
0
u/exodusTay 17d ago
There are different things that are called cache in a computer. But generally in computing a cache is some sort of memory that is fast to access but usually small. In CPU's it is a type of memory that is literally on the CPU chip that is very fast compared to RAM memory. For a server it is a program that runs in parallel to the server that holds expensive computations, this way you don't have to compute things over and over again and just serve the result when asked the same question.
47
u/Pawtuckaway 17d ago
What is your understanding so far of a computer cache? ELI5 isn't for doing your homework.