What is hard drive cache and what does it do?
Anyone who’s worked with PC hardware is familiar with the main hard drive specs, like capacity, read/write speeds, and platter rotation speeds. However, there is a lesser known and often overlooked feature that can really impact the speed of your hard drive, the cache size.
What Is Hard Drive Cache?
Hard drive cache is often known as the disk buffer. By that name, its purpose becomes a little more clear. It acts as temporary memory for the hard drive as it reads and writes data to the permanent storage on the platters.
You can think of a hard drive’s cache as being like RAM specifically for the hard drive. The analogy actually fits very well too. Hard drives have built-in micro controllers that act to govern and process data coming in and out of the drive, much like a CPU. The cache works in conjunction with that controller to store memory as its being processed.
You can also think of it like a buffering video. Everyone has dealt with streaming a video on a slow connection. The video player waits before or during playback to collect more data so that it can continue playing the video more smoothly going forward. Hard drive cache allows a hard drive to do the same thing while reading or writing data.
How Does It Work?
As the hard drive reads and writes data, it has to pull that data from the platters. Very often, a hard drive is working with the same data repeatedly, since the person using the computer is probably going to be working on one or two tasks at a time. The drive holds data that you or your programs are using most frequently and most recently in its cache, eliminating the need to pull it from the platters each time that that data is needed and speeding up the drive.
Reading Ahead and Behind
Typically, a hard drive doesn’t just pick up the data that it needs. It also reads the data around it. Hard drives aren’t efficient. The system of spinning platters and read/write heads is inherently limited by relying on physical moving parts. Moving parts are much slower than entirely electronic ones. So, hard drives try to compensate by guessing.
When a user or a program makes a request for data, the hard drive pulls that data and the data around it on the platter and stores it all in the buffer. Since there is a decent likelihood that the surrounding data is similar, the drive bets that the user or process that requested the initial data will also request the surrounding data soon too.
Evening Data Flow
There are a bunch of different steps to retrieving data from a hard drive. Each one of them takes time, and it’s rare that they sync up. Transfer from the hard drive via SATA usually moves much faster than the drive can read and write data to the platters. The disk buffer is often used to even out this flow of data and make the process much smoother.
Minimizing Wait Times When Writing
Again, hard drives are slow. They are probably the slowest part of any computer because of their physical moving parts. Writing data is usually especially painful.
Cache helps to speed up writing by lying to the rest of the computer. A hard drive will take data into its cache and begin writing it. Instead of waiting to write all of that data to the platters, the drive signals back to the rest of the computer that it wrote all of the data. The computer either continues sending more data or moves on, believing that the process is complete. Either way, this allows the computer as a whole to continue to the next task.
There is a downside, though. While the hard drive is trying to make good on its promise to write the data, it can lose it. If the computer is powered off suddenly, all of the data stored in the cache waiting to be written will disappear. Cache, like RAM, is volatile storage.
Speeding Up Your Hard Drive
Cache isn’t going to directly equate to faster drive performance on single tasks. It’s not like it’s actually causing the drive to move faster.
Having a disk buffer does, however, allow a hard drive to multitask much more efficiently, and chances are, that’s something that you’ll need.
It’s rare that a drive only does one thing or will only interact with one process at a time. Most of the time, disk-based hard drives are going to be storage drives in modern PCs, leaving operating system and application installs to solid state drives. Even with this single job, multiple programs may need to access that storage at a time. You may even actively be working with two or more files from your storage drive at once.
Servers are another space where having cache in hard drives is very important. Server hard drives are always going to be doing multiple things. Think of a database behind a website. Every time a user on that site completes an action that the website has to store or log, the site accesses and writes to the database. Every time someone even views that website, it reads from the database. It would be rare that the drives storing that database wouldn’t be performing multiple tasks simultaneously.
Cache In SSDs
SSDs aren’t as slow as physical hard drives, so do they need cache too? In short, sort-of. Most SSDs do make use of a cache system. While cache in hard drives behaves like RAM, cache in solid state drives actually is DRAM. It’s much faster and keeps pace with the drives themselves.
Even though SSDs are much faster than their disk-based counterparts, cache still has benefits. Solid state drive still use cache to regulate the drives and provide somewhat faster read and write access.
Some SSDs don’t actually have that built-in DRAM for cache. It saves on power consumption, but forces the drives to compensate in other ways.
Buying a Drive
So, cache obviously does matter. Cache probably won’t matter as much as the primary drive specs, but you should still take it into account.
If your drive is going to be multitasking or running constantly, like in a server, look for larger cache sizes. You’re going to see the most benefit from it.
Home users that are looking for a storage drive that they’ll only access on occasion don’t have to worry about it as much.
For solid state drives, the waters are a little murkier, but it’s still worth considering cache in your decision process. Other factors can easily overshadow it, though.