Memory hierarchy explained

In computer organisation, the memory hierarchy separates computer storage into a hierarchy based on response time. Since response time, complexity, and capacity are related, the levels may also be distinguished by their performance and controlling technologies. Memory hierarchy affects performance in computer architectural design, algorithm predictions, and lower level programming constructs involving locality of reference.

Designing for high performance requires considering the restrictions of the memory hierarchy, i.e. the size and capabilities of each component. Each of the various components can be viewed as part of a hierarchy of memories in which each member is typically smaller and faster than the next highest member of the hierarchy. To limit waiting by higher levels, a lower level will respond by filling a buffer and then signaling for activating the transfer.

There are four major storage levels.[1]

This is a general memory hierarchy structuring. Many other structures are useful. For example, a paging algorithm may be considered as a level for virtual memory when designing a computer architecture, and one can include a level of nearline storage between online and offline storage.

Properties of the technologies in the memory hierarchy

Examples

The number of levels in the memory hierarchy and the performance at each level has increased over time. The type of memory or storage components also change historically.[6] For example, the memory hierarchy of an Intel Haswell Mobile[7] processor circa 2013 is:

The lower levels of the hierarchy – from disks downwards – are also known as tiered storage. The formal distinction between online, nearline, and offline storage is:[12]

For example, always-on spinning disks are online, while spinning disks that spin-down, such as massive array of idle disk (MAID), are nearline. Removable media such as tape cartridges that can be automatically loaded, as in a tape library, are nearline, while cartridges that must be manually loaded are offline.

Most modern CPUs are so fast that for most program workloads, the bottleneck is the locality of reference of memory accesses and the efficiency of the caching and memory transfer between different levels of the hierarchy. As a result, the CPU spends much of its time idling, waiting for memory I/O to complete. This is sometimes called the space cost, as a larger memory object is more likely to overflow a small/fast level and require use of a larger/slower level. The resulting load on memory use is known as pressure (respectively register pressure, cache pressure, and (main) memory pressure). Terms for data being missing from a higher level and needing to be fetched from a lower level are, respectively: register spilling (due to register pressure: register to cache), cache miss (cache to main memory), and (hard) page fault (main memory to disk).

Modern programming languages mainly assume two levels of memory, main memory and disk storage, though in assembly language and inline assemblers in languages such as C, registers can be directly accessed. Taking optimal advantage of the memory hierarchy requires the cooperation of programmers, hardware, and compilers (as well as underlying support from the operating system):

Many programmers assume one level of memory. This works fine until the application hits a performance wall. Then the memory hierarchy will be assessed during code refactoring.

See also

Notes and References

  1. Book: Toy. Wing. Zee. Benjamin. Computer Hardware/Software Architecture. 1986. Prentice Hall. 0-13-163502-6. 30.
  2. [Write-combining]
  3. Web site: Memory Hierarchy . Unitity Semiconductor Corporation . 16 September 2009 . dead . https://web.archive.org/web/20090805170055/http://www.unitysemi.com/applications-memory-hierarchy.html . 5 August 2009.
  4. Web site: Multi-Core. Pádraig Brady. 16 September 2009.
  5. Ruud . van der Pas . Memory Hierarchy in Cache-Based Systems . 2002 . 26 . Santa Clara, California . . 817-0742-10.
  6. Web site: Memory & Storage - Timeline of Computer History - Computer History Museum. www.computerhistory.org.
  7. Web site: Crothers . Brooke . Dissecting Intel's top graphics in Apple's 15-inch MacBook Pro - CNET . News.cnet.com . 2014-07-31.
  8. Web site: Intel's Haswell Architecture Analyzed: Building a New PC and a New Intel . AnandTech . 2014-07-31.
  9. Web site: SiSoftware Zone . Sisoftware.co.uk . 2014-07-31. https://web.archive.org/web/20140913231938/http://www.sisoftware.co.uk/?d=qa&f=mem_hsw. 2014-09-13.
  10. Web site: Samsung 960 Pro M.2 NVMe SSD Review. 20 October 2016 . storagereview.com. 2017-04-13.
  11. Web site: Ultrium - LTO Technology - Ultrium GenerationsLTO . Lto.org . 2014-07-31 . dead . https://web.archive.org/web/20110727052050/http://www.lto.org/technology/generations.html . 2011-07-27 .
  12. Web site: Pearson. Tony. 2010. Correct use of the term Nearline.. dead. https://web.archive.org/web/20181127020712/https://www.ibm.com/developerworks/community/blogs/InsideSystemStorage/entry/the_correct_use_of_the_term_nearline2?lang=en. 2018-11-27. 2015-08-16. IBM Developerworks, Inside System Storage.