[CS61C FA20] Lecture 30.4 - Virtual Memory II: VM Performance — Transcript
Full transcript
- 0:00[Music]
- 0:10hello
- 0:11and welcome back to our operating system
- 0:13and virtual memory module
- 0:17but now we know pretty well how does the
- 0:20virtual memory
- 0:21system work and even we even know how to
- 0:24implement it so what is left is
- 0:26to evaluate its performance and we even
- 0:29actually know that
- 0:30because we're going to be using the same
- 0:32set of
- 0:33principles that we have used for
- 0:35evaluating the performance of
- 0:37our cache so
- 0:40to get started let's compare cache
- 0:44and virtual memory system so whatever in
- 0:46the cache version whatever we use to
- 0:48call a block or a line
- 0:50is going to correspond to a page in a
- 0:52virtual memory system
- 0:54cache misses correspond to page faults
- 0:58block sizes and caches were 32 to 64
- 1:01bytes
- 1:02typical page size that we are dealing
- 1:04with is 4 kb
- 1:05um sometimes page sizes are a little bit
- 1:09smaller 2 kb
- 1:10can be larger 8 or 16 kb but we
- 1:13typically deal with
- 1:144 kb pages placement
- 1:18in cache can be direct mapped or n-way
- 1:21set associative
- 1:23generally in
- 1:26virtual memory systems our pages
- 1:29are fully associative dlbs are fully
- 1:33associative
- 1:36replacement policy in cash can be least
- 1:39recently used or random
- 1:41or anything in between those two
- 1:45in virtual memory system we
- 1:48generally would like to go with the
- 1:51leads
- 1:52recently used but sometimes we'll
- 1:53approximate it with something
- 1:55that may end up being either a fifo or a
- 1:58random
- 2:01when we talk about
- 2:05right back policy writing back to the
- 2:09to dram in case of
- 2:12a cache we can we we have options for
- 2:16right throw and right back in virtual
- 2:17memory systems
- 2:19we only write back because the penalty
- 2:22of writing back writing through
- 2:26to the disk is so high
- 2:29so we're ready to evaluate the
- 2:31performance
- 2:33performance in a virtual memory
- 2:36system is going to be evaluated in the
- 2:38same way how we evaluated the
- 2:40performance
- 2:41of our cache system uh virtual memory
- 2:44is the level of memory that is
- 2:48below the main memory in our previous
- 2:50calculations
- 2:51everything stopped at the main memory at
- 2:53the dram level
- 2:54now virtual memory extends the dram
- 2:58into the cache through paging
- 3:02our virtual memory extends the dram into
- 3:06a disk by using paging
- 3:10so although tlb comes before the cache
- 3:14it affects the data you know data
- 3:17transfers
- 3:18from the disk to the main memory so
- 3:22in our previous calculations main memory
- 3:24was the lowest level
- 3:26we just need to account
- 3:29for cases where our data is actually not
- 3:32in the dram but we have to go all the
- 3:34way to a disk to retrieve it
- 3:37so same metrics of cycles per
- 3:40instruction
- 3:41and average memory access times are
- 3:44going to
- 3:45apply but this time we are going to
- 3:49uh treat our main memory as some kind of
- 3:53an intermediate
- 3:54level cache so we are going to go to l1
- 3:57cache
- 3:57hit misses speculations then
- 4:01our calculations then l2 hits and misses
- 4:04then we're going to hit into the drum or
- 4:07miss and
- 4:08end up in the disk so
- 4:12here are some of the parameters that we
- 4:14care about so
- 4:15when we calculated you know in our
- 4:17calculations we had cpu cache and the
- 4:20primary memory
- 4:21now we are going to have cpu primary
- 4:24memory and the secondary memory
- 4:26so when we're talking about the caches
- 4:29we talked about the cache entry in
- 4:32demand paging
- 4:33we are dealing with page frames
- 4:36cache blocks were 32 to 64 bytes as we
- 4:39said before
- 4:40pages are for kibi when we talk
- 4:43about cache miss rate we were
- 4:46generally happy when we get something
- 4:48that was in single digits so it would be
- 4:51typically
- 4:52you know l1 caches would be like one
- 4:54percent uh
- 4:56hits and 20 percent perhaps 10 20
- 4:59in l2 um
- 5:02now page miss rates have to be much much
- 5:06lower
- 5:06uh typically uh one in ten thousand
- 5:10or one in hundred thousand or lower than
- 5:12that
- 5:14cash hits um would
- 5:18you know our cash was designed so well
- 5:20that
- 5:21and in most processor it will be that
- 5:23basically
- 5:24we get the data out of cache in one
- 5:26cycle
- 5:28cache miss corresponds to the page hit
- 5:31in dram
- 5:32so that will be from then a few tens of
- 5:34cycles
- 5:35to 100 cycles now page miss corresponds
- 5:38to say 5 million
- 5:40clock cycles because that's how much
- 5:43does it take us
- 5:44to go to the disk and corresponds to jim
- 5:47gray's analogy
- 5:48of going to pluto
- 5:52so let's find out what is the impact of
- 5:54paging on
- 5:55average memory access time um
- 5:58so let's assume that we have the
- 6:00following memory parameters
- 6:02that are reasonably common and we can
- 6:04plug in any other numbers that you like
- 6:06commonly we get to do that in
- 6:09in our exams so um
- 6:14let's say that the l1 cache it is
- 6:18accomplished in one clock cycle and we
- 6:21do that with
- 6:2295 of accesses um
- 6:25l2 cache it takes 10 clock cycles
- 6:28and the hit rate is 60 of l1 misses
- 6:34dram takes 200 clock cycles
- 6:38say say 100 nanoseconds that's kind of
- 6:40pessimistic for modern systems
- 6:42um usually would be less but that's okay
- 6:44for the current calculation
- 6:46and finally disk takes 20 million clock
- 6:48cycles
- 6:49say 10 milliseconds i'll be faster if we
- 6:52plug in
- 6:52an ssd so
- 6:56the average memory access time without
- 6:59paging
- 7:00is calculated as this time that if
- 7:04we don't have a miss if we have a hit we
- 7:07can do everything in one
- 7:08clock cycle we get data out of the l1
- 7:11cache in one clock cycle
- 7:14and then we need to add the penalty of
- 7:17missing
- 7:18so we will miss with five percent
- 7:20probability
- 7:22uh l1 and that's going to cost us 10
- 7:24clock cycles
- 7:25and then we we miss um
- 7:29in l2 there'll be five percent of a miss
- 7:32in l1 times forty percent of a missing
- 7:35l2 times 200 cycles that is going to
- 7:37take us to get to dram
- 7:39so that evaluates to 5.5 clock cycles
- 7:45all right this is a bit pessimistic you
- 7:47know modern systems are going to be
- 7:49a little bit faster than that but
- 7:52let's see how do we modify this to our
- 7:55account
- 7:56for the paged
- 8:00memory system so to add paging
- 8:03what we need to do we need to take this
- 8:045.5
- 8:09amat and add the impact of paging
- 8:13um and so let's do that
- 8:16so average memory access time with
- 8:18paging
- 8:19equals to our 5.5 cycles plus
- 8:22five percent times forty percent five
- 8:25percent
- 8:26probability they're going to miss in l
- 8:28one forty percent are
- 8:29gonna miss l2 times one minus
- 8:33the hit rate into the memory that our
- 8:36data is not going to be in dram it is
- 8:38going we we are going to have to go all
- 8:40the way to a disk
- 8:41and that's going to cost us 20 million
- 8:43cycles now keep in mind
- 8:4520 million is a huge number compared to
- 8:47any other numbers
- 8:49so this hit rate into memory better be
- 8:54close to 1. so we mentioned it has to be
- 8:57better than 99
- 8:58but let's just take a look at what
- 9:00happens if it is
- 9:01just 99 so we plug that in
- 9:045.5 plus 0.2 times 0.01
- 9:08that is 1 minus 99 times 20 million
- 9:12we have a mat of 4 000.
- 9:15that's like 700 times slower machine
- 9:19that's terrible that's a horrendous
- 9:20performance by the way this does happen
- 9:22in practice
- 9:24we if we continuously
- 9:27end up swapping pages
- 9:30which happens if the if we are running
- 9:32out of physical memory there are too
- 9:34many processes
- 9:35too many classes perhaps sharing a
- 9:37machine
- 9:39the machine continuously swaps every 100
- 9:42cycles or so
- 9:44is going to go to swap a page with the
- 9:46disk
- 9:47and that is called trashing and
- 9:50typically
- 9:51when a machine is trashing it's like a
- 9:54hundred to a thousand times
- 9:55slower than it normally it
- 9:59is
- 10:02so let's see what happens if you have a
- 10:04little bit better
- 10:05hit rate
- 10:09so yeah what this is what we have seen
- 10:11this is what happens when uh uh
- 10:14a program is you know if too many people
- 10:16are
- 10:17sharing a machine a 10 second program
- 10:19can take two hours
- 10:21so what if the
- 10:24hit rate is 99.9
- 10:27well things get a little bit better but
- 10:29not much better it's
- 10:31still amat is 400
- 10:34a lot worse than what we have had before
- 10:36finally let's see
- 10:37what if it is a more reasonable number
- 10:40if
- 10:40our heat rate or our miss into the dram
- 10:44is one in 10 000
- 10:46then our amat
- 10:50gets increased from 5.5
- 10:54to 5.9 which is more reasonable
- 10:57and this is something that we will often
- 10:59encounter
- 11:02that's basically it what we need to do
- 11:04for
- 11:07in this module we can
- 11:10take a quick break and then we are going
- 11:12to see how
- 11:14can we incorporate io devices
- 11:17into this see you
- 11:20a bit later
About this transcript
This page contains the full transcript of [CS61C FA20] Lecture 30.4 - Virtual Memory II: VM Performance by CS 61C Departmental, generated from the public captions YouTube serves with the video. The transcript has 1,488 words across 275 segments, with the original timestamps preserved so you can click any line to jump to that moment in the embedded player.
What you can do with it
Use the transcript to take notes, quote the speaker, build a study guide, generate a summary with ChatGPT or Claude via the YouTube Summary tool, or export it as a timed subtitle file with YouTube to SRT. You can also re-open it in the transcriber to translate the transcript into 100+ languages.
Free YouTube transcript tool
YouTube2Text is a free YouTube transcript generator — no signup, no daily limit. Paste any YouTube link and get the full transcript instantly, with timestamps, click-to-jump, translation to 100+ languages, AI prompts for ChatGPT, Claude, and Gemini, and exports to TXT, SRT, VTT, or Markdown.