In the fascinating world of computers, storage devices are undoubtedly one of the most core members. We usually divide storage devices into two major categories: memory and hard disk, each with its own strengths and responsibilities. Memory, with its non-persistent nature, serves as a temporary storage pioneer; although data will vanish when the device loses power, it has an unparalleled advantage in data transfer speed. The hard disk, as a representative of persistent storage, still silently guards the safety of data even after the device loses power.
However, the world of computer storage is far more than this. If we delve deeper, we will find that storage devices can actually be divided into two major camps: internal and external storage. Internal storage usually refers to those storage devices closely connected with the device's motherboard, such as the BIOS storage and memory that we are all familiar with. External storage, as the name suggests, requires a specific protocol to connect with the motherboard, and mechanical hard drives, SSDs, and optical discs are all members of this camp.
In this large storage family, ROM and RAM are two members that must be mentioned. ROM, which stands for Read-Only Memory, guards data that is not allowed to be modified with its read-only characteristic. RAM, which stands for Random Access Memory, has become a good helper for the CPU with its ability to read and write randomly. In the RAM family, SRAM and DRAM are two very important branches. SRAM, which stands for Static Random Access Memory, plays an important role in CPU cache with its ultra-fast speed. The memory we often talk about is actually DRAM, which stands for Dynamic Random Access Memory.
When it comes to cache, we must mention the three levels of CPU cache - L1, L2, and L3. These caches are mostly implemented using SRAM, and their speeds are faster and faster, while their capacities are smaller and smaller. The speed of L1 cache can reach an astonishing 1150GB/s, but the capacity is only a few hundred KB; the speed of L2 cache is slightly lower, but also 470GB/s, and the capacity is a few MB; as for L3 cache, the speed is about 200GB/s, and the capacity can reach tens of MB. Compared with these caches, memory, although with a huge capacity that can reach the TB level, is far inferior to the cache in terms of speed and access latency.
When we turn our attention to external storage, such as hard drives, optical discs, and magnetic tapes, we will find that their speeds are even slower by more than one order of magnitude. Taking the NVMe protocol SSD as an example, its bandwidth will not exceed 10GB/s at most, and the bandwidth of the mechanical hard drive is only a little more than 100MB/s. If we look from the perspective of access latency, these storage devices have a huge difference compared with CPU cache.
In this storage performance pyramid, the latency of CPU cache is between 1 and 10 nanoseconds, the access latency of memory is about 100 nanoseconds, the access latency of solid-state drives is about 16 microseconds, and the access latency of mechanical hard drives is at the millisecond level. If we use transportation tools in life as a metaphor, the speed of CPU cache is comparable to a rocket, the speed of memory is like a regular passenger plane, the speed of solid-state drives is like a green train, and as for mechanical hard drives, their speed is almost as slow as a horse-drawn carriage.
After understanding the performance differences of these storage devices, both storage R&D personnel and ordinary developers can more accurately choose the storage solutions that suit their needs. For example, when developing high-concurrency applications, if you can fully consider the issues of cache synchronization and multi-core concurrent access of CPU cores, you can significantly improve the performance of the program. In the field of storage-related software, by using faster media as a cache for slower media, you can also significantly improve the overall performance of the file system.
Some enterprise-level storage systems have even adopted a layered architecture of mixed SSD and mechanical hard drives, which not only provides higher performance for users but also does not increase the price too much. This design undoubtedly reflects the exquisite balance between performance and cost of storage technology.
In general, the world of storage devices is colorful, and each storage device has its unique performance characteristics and applicable scenarios. Understanding the characteristics of these storage devices is indispensable for us to better utilize them and improve our work efficiency and quality of life. In the following chapters, we will delve deeper into the application of these storage devices, so stay tuned.