Computer architecture - Memory - lecture 8b - Charles Fox - University of Lincoln
Overview
Charles Fox explains how caching exploits locality across the memory hierarchy, from SRAM caches between a CPU and DRAM to RAM-backed virtual memory and global content delivery networks. He compares direct, associative, and hybrid cache designs, explains write-through and write-back policies, then surveys storage from punch cards and hard disks to SSDs, RAID, optical jukeboxes, tape, and experimental glass archives.
Key takeaways
- Temporal, sequential, and spatial locality explain why caches can predict future memory accesses: programs revisit recently used values, repeat instruction sequences, and traverse neighboring addresses.
- Direct-mapped caches use a fast address-to-line hash but can suffer repeated conflicts; set-associative caches reduce those conflicts by allowing multiple candidate lines within each hashed pool.
- Write-through updates RAM along with the cache, whereas write-back delays RAM updates until eviction; dirty bits track which cached blocks require writeback.
- Virtual memory extends the apparent address space by using RAM as a cache for disk-backed data, with the operating system translating virtual addresses to physical addresses.
- Storage trade-offs continue beyond RAM: SSDs offer fast flash access, hard disks provide magnetic capacity with mechanical delays, and tape or optical jukeboxes support slower archival storage.
- Redundancy and distribution address different storage risks: RAID can protect data across disks, while content delivery networks place cached copies near users to improve access.
Chapters
- The memory hierarchy places smaller, faster storage closer to the CPU, keeping likely-needed information accessible as a cache.
- Temporal locality means a recently accessed address is likely to be used again soon.
- Sequential locality arises when program loops revisit address sequences, while spatial locality predicts accesses to neighboring addresses, such as adjacent array elements.
- Caches store data in lines containing a tag and a block, often larger than a single RAM word to exploit spatial locality.
- A cache hit supplies requested data from the faster cache; a miss requires accessing main RAM, with the extra delay called the miss penalty.
- Hash functions map large inputs, such as memory addresses, to smaller outputs; different addresses can therefore map to the same cache location.
- A dirty bit records whether cached data has been modified, which matters when updated data must eventually reach RAM.
- Direct caching hashes each RAM address to one specific cache line, then compares the requested address with that line's tag.
- For a hit, a multiplexer returns the cached block; for a miss, the system fetches data from RAM and stores a copy in the selected line.
- Charles Fox's Logisim sketch uses the low address bits as a cache index and a comparator to check the tag.
- Direct mapping is simple and fast, but addresses with the same hash compete for one line and can repeatedly evict one another.
- Associative caching allows a memory block to occupy any cache line, reducing conflicts caused by direct mapping.
- Finding a requested block requires comparing its tag against many or all cache lines in parallel, adding circuit area and logic.
- A victim policy, such as evicting the least recently accessed line, decides what to replace when the cache is full.
- Hybrid, or set-associative, designs hash an address to a pool of lines and search associatively within that pool, balancing conflict reduction with hardware cost.
- Both write policies update the cached value when the CPU stores new data; they differ in when they update RAM.
- Write-through sends the update to RAM promptly, giving more predictable memory consistency but involving the slower memory path.
- Write-back defers the RAM update until the cache line is evicted, using a dirty bit to identify data that needs writing back.
- Write-back can make normal cache operations faster but may cause a delay on eviction, complicating CPU pipeline timing and hazard handling.
- Modern CPUs commonly use multiple cache levels, with upper levels smaller, faster, and more expensive than lower levels.
- Instruction caches can exploit sequential instruction fetching and loops, while data caches handle different access patterns.
- A translation lookaside buffer, or TLB, caches virtual-to-physical address translations used by operating systems.
- In multiprocessor systems, cache coherence must account for writes by one CPU, cached copies on other CPUs, and dirty data.
- Punch cards served as secondary storage from early machinery through the 1980s and are human-readable, a useful archival property during technology failures.
- Wax cylinders and later gramophone records stored sound mechanically, while magnetic disks encode digital data using regions with different magnetic orientations.
- Floppy disks and hard disks use magnetic storage; hard disks place read/write heads over spinning platters.
- Hard disks organize data into concentric tracks divided into sectors, commonly around 512 bytes, which are read or written as units.
- Disk access is not fully random: moving the head between tracks and waiting for a sector to rotate into place take time.
- Keeping related sectors close together reduces head movement; fragmentation spreads data across the disk and can slow access.
- Modern platters can rotate at roughly 100 to 200 revolutions per second, and the read/write head flies above the surface on a thin air cushion.
- RAID combines multiple disks to improve redundancy or performance; RAID 1 mirrors data, while RAID 5 uses striping and parity for fault tolerance.
- Charles Fox emphasizes keeping important data in multiple places rather than relying on a single hard disk.
- An SSD replaces moving platters with flash memory chips, offering faster access and no moving parts, often at higher cost per capacity.
- SSDs and hard disks remain secondary storage, accessed through I/O rather than directly through the CPU's primary memory address space.
- Virtual memory lets a computer present a larger address space by keeping some data on secondary storage and using RAM for the currently needed portions.
- Programs use virtual addresses that the operating system translates to physical RAM addresses.
- A Linux-style memory map separates physical memory, including areas for the kernel and user processes, from the larger virtual address space.
- Charles Fox contrasts durable records such as Babylonian clay tablets and the Domesday Book with the 1986 BBC Domesday Project laser discs, which became difficult to read after about five years.
- Optical storage progressed from CDs to DVDs and Blu-rays; optical jukeboxes use robotic arms to retrieve discs for large-scale, slower archival access.
- Magnetic tape remains useful for company backups, with the lecture citing systems holding about 400 terabytes and lasting around 30 years.
- Content delivery networks distribute cached copies around the world, while experimental glass nanostructured storage is presented as a possible long-term archival medium.
Transcript excerpt
0:00 Caching is a general idea of using multiple layers of the memory pyramid in more efficient ways. It's it's often the case, like in [snorts] the lawyer's office, it's often the case that you have a load of information, like all those old books behind you, and you don't know at the start of your task which information you're going to be using, but once you start using some of it, once you've pulled a couple of books off the shelf, you are quite likely to go on using the same books. Um and so it makes sense to not put the book back on the shelf straight away, but to leave it on your desk. You might have
0:47 multiple layers of this as well. You know, you might you might feasibly tear a page out of the book and bring it much closer to you than the rest of the book, or you might have different areas on your desk that are closer and further away for books that you think you're going to be using a lot. You try you try to get all the information that you're currently using and therefore will probably be using again in the future and keep it close to you. So technologically you have a bunch of different kinds of memory. For example, we've seen the SRAM and the DRAM so far. Um you might try to [snorts] arrange things so that that fast memory is trying to guess which parts of the slow memory are
1:37 likely to be used, and you try and fill the small fast memory with stuff that you think you're going to need. And you you can do this all the way through the memory pyramid. You you could have your basement full of archival Blu-rays that that take a long
This is the start of the transcript. Save this video free for the whole transcript, searchable and time-coded.
In this course
Related notes
Summary, takeaways, and chapters were generated by AI from the video's transcript and may contain errors. The video belongs to its creator, Charles Fox.