The Memory Hierarchy: Why Computers Use Several Kinds of Memory

No single memory technology is simultaneously fast, large, and cheap. This article introduces the concept of a memory hierarchy that combines several different memory technologies to approximate the speed of the fastest one at the cost of the cheapest, then walks through the core technologies that make up each level.

Memory HierarchySRAM and DRAMMemory Technologies

~3 دقیقه مطالعه · آخرین به‌روزرسانی ۱۵ شهریور ۱۴۰۵

Why One Memory Type Is Never Enough

An ideal memory would be extremely fast, hold an enormous amount of data, and cost very little. In practice, no single technology achieves all three at once: faster memory is always more expensive per byte and typically smaller, while cheaper, larger memory is always slower. This tradeoff is the central problem that the Memory Hierarchy is designed to solve.

The Core Idea: Combine Several Levels

Rather than choosing one memory technology, a computer combines several different levels of memory, each with a different balance of speed, size, and cost. Data that is frequently used is kept in the smallest, fastest, most expensive level, while data used less often resides in progressively larger, slower, and cheaper levels further away from the processor.

Fastest, smallest, most expensive:
Registers → Cache → Main Memory → Disk/SSD
Slowest, largest, cheapest

SRAM: The Foundation for Fast, Small Memory

SRAM (Static Random Access Memory) stores each bit using a small circuit of transistors that holds its value continuously as long as power is supplied, without needing to be refreshed periodically. This makes SRAM very fast to access, but each storage cell requires several transistors, making it physically larger and more expensive per bit than the alternative used for main memory.

DRAM: The Foundation for Large, Cheap Memory

DRAM (Dynamic Random Access Memory) stores each bit using a single transistor and a capacitor, which is far more compact and cheaper to manufacture per bit than SRAM. The tradeoff is that the capacitor's charge leaks over time, so DRAM must be periodically Refreshed — its stored values re-written at regular intervals — to avoid losing data, and reading from it takes noticeably longer than reading from SRAM.

Why These Two Technologies Are Used Differently

Because of these tradeoffs, SRAM is used almost exclusively for small, extremely fast Cache memory built directly into or very close to the processor, while DRAM is used for larger Main Memory that holds far more data at a fraction of the per-bit cost, at the price of slower access time.

Beyond SRAM and DRAM: Persistent Storage

Below main memory in the hierarchy sits persistent storage, such as Solid-State Drives (SSDs) or traditional magnetic Hard Disk Drives (HDDs), which retain data even when power is removed, hold vastly more data than DRAM, but are significantly slower to access, particularly hard disk drives, which involve mechanical movement to physically locate data.

Why Understanding This Foundation Matters

Every technique discussed in the remainder of this chapter — caching strategies, virtual memory, and performance optimization — exists specifically because of the fundamental tradeoffs described here between speed, size, and cost. Without appreciating why no single memory technology can satisfy every requirement, the design decisions behind cache hierarchies would appear arbitrary rather than necessary.

نوشته و پژوهش‌شده توسط دکتر شاهین صیامی

مقالات مرتبط

Common Misconceptions About Parallel Computing and the Book's Final Lessons

After covering everything from thread-level parallelism to warehouse-scale computing, it is worth correcting persistent misconceptions about parallel systems that even experienced engineers sometimes hold. This article addresses common fallacies about scaling and parallel hardware, then closes out the parallel processing chapter by tying together the full journey from a single instruction to a building full of cooperating machines.

ادامه

Real Stuff: Benchmarking CPUs Against GPUs and Multiprocessor Matrix Multiply

Comparing a CPU and a GPU fairly requires a model that accounts for both computational throughput and memory bandwidth limits together. This article introduces the roofline model used to compare real hardware like the Intel Core i7 and NVIDIA Tesla GPU, then shows how matrix multiplication is accelerated across multiple processors as the final practical application of this chapter's parallel concepts.

ادامه

Benchmarking Multiprocessors and Modeling Parallel Performance

Measuring the performance of a parallel system requires different tools and metrics than measuring a single-core processor. This article covers the specialized benchmarks used to evaluate multiprocessor systems, explains how to model scaling behavior as more processors are added, and revisits Amdahl's Law in the context of real-world performance measurement.

ادامه

Cluster Networking: Connecting to the World Outside

A cluster of machines is only useful if it can communicate efficiently both internally and with the outside world. This article covers the networking layers involved in cluster communication, the tradeoffs between latency and bandwidth at scale, and how clusters connect to external networks and users.

ادامه

Clusters, Warehouse-Scale Computers, and Network Topologies

Beyond a single chip, parallelism extends to entire buildings full of independent computers working together. This article explains the shift from shared memory multiprocessing to clusters of separate machines, introduces the concept of warehouse-scale computing, and covers the network topologies that connect these independent machines efficiently.

ادامه

An Introduction to GPUs: Massive Parallelism for Data-Heavy Workloads

A GPU takes the SIMD idea covered earlier in this series to an extreme scale, running thousands of lightweight threads simultaneously to process massive amounts of independent data. This article explains why GPUs are architecturally so different from CPUs, how their thread execution model works, and what kinds of workloads benefit most from this design.

ادامه