Saddle up Streisand fans, it’s memory time!
I feel the theme of this blog is to get people hyped about a topic that is only marginally related to what we are really going to talk about so as to disappoint and trick my audience into learning things that are cold and boring.
Annnddd… this week is no exception! We are going to discuss the concept of memory in computing, the memory hierarchy, and, regrettably, not Barbara’s 1974 hit, The Way We Were.
First of all, what is memory in computing?
Memory is both a mental concept and a physical one. Simply, when we discuss memory in the context of computing, we understand memory to be a space where we can store (permanently or temporarily) and retrieve data. But what is this magic black box that does all of this for us? That’s where the physical notion of memory comes in. Memory is spread out along many physical hardware devices that all interact together to store and deliver our data. These devices can be perceived through a hierarchical chart of physical devices that allows us to understand how a single bit can flow from one device to the other on its way to present itself to your screen.
What is the memory hierarchy?
The memory hierarchy chart was born from the necessity to understand memory utilization, performance rates, and the overall purpose of memory in different types of computing hardware. The levels are divided by the device’s use and speed.
As you can see, there are levels of memory that belong to the CPU, RAM/physical memory, persistent memory via SSD (or a little bit older HDD), and virtual memory. The top of the pyramid structure denotes memory that is faster to access (and more expensive) whereas the bottom of the pyramid denotes memory that takes much longer to access (also cheaper). If data is not found on a specific level, it must reach down the levels until that data is found and brought up and stored somewhere more accessible.
Summary of how it all works.
At the top of the pyramid, we have the CPU which can be looked at as the “brain” of the computer. It runs all our applications, it takes the data we give it and stores it somewhere in memory and recalls the data stored in memory so it may be read or manipulated. The CPU contains caches that have data that has been brought up from a lower level in memory to be used by the CPU. The data that it stores is volatile meaning it is temporary and will no longer be there if the computer turns off. The content the cache contains is data that may have been used recently, used frequently, or some other metric deemed by the design of the cache system. If the CPU is looking for some data and it finds it here, it is referred to as a cache hit. A cache hit is an ideal situation for retrieving data because the closeness of the cache allows the CPU to get the data very fastest.
The level underneath the CPU caches is the physical memory. You may have heard of the word RAM being thrown around here and there when referring to computer specs. RAM or random access memory, is volatile physical memory and is another level of memory that may hold data that the CPU may need. The CPU may use this as another level of holding data. Getting data from RAM is still faster than from the lower levels, but not as fast as if the data were in the CPU cache.
The level underneath of physical memory shows as solid state memory on the pyramid (in reference to solid state drives (SSD) which many modern computers have), but more generally can be thought of as secondary storage. At this level, memory is no longer volatile. You can power your computer on and off again as many times as you want and if your cat memes have persisted (saved) to a hard disk drive (HDD) or an SSD, you can rest assured that they are safe and sound. If the CPU can not find the data it needs from its cache or physical memory, it will travel to the secondary storage to find it and bring it up into RAM or cache memory so it may be utilized more quickly in the future. Having to do this is slower than if the data were in the CPU caches or RAM.
The last level is slow, well slower, well slower relative to what hardware you have going on in your machine. Anyhow, virtual memory is created in secondary storage and is created when all the RAM is utilized. It is slow and can decrease the performance of applications you may be using.
Whew! If this crude and high-level summary of the memory hierarchy doesn’t leave you misty-eyed (🙄) and thinking of the “smiles we left behind” (ok, I’ll get out 🚪 🏃♀️) I don’t know what will!
That’s it for this week, take care!