[CS61C FA20] Lecture 25.3 - Caches II: Cache Terminology — Transcript
Full transcript
- 0:00and welcome back now let's talk about
- 0:02some of the terminology as we
- 0:04start we've seen some examples with
- 0:05caches we understand direct map caches
- 0:07we think about how to think about them
- 0:08how to draw them
- 0:09but there's a lot of new words caches
- 0:11boy caches have probably
- 0:12i feel like 20 words you may have never
- 0:14used before so or maybe using different
- 0:16context so let's make sure we understand
- 0:18all the words that people use when they
- 0:19talk about different caches
- 0:20so when i read memory sometimes it's
- 0:23there
- 0:24sometimes it isn't or sometimes it's
- 0:26there but the tags don't match those
- 0:27three cases we call a cache hit
- 0:31that's the best situation it means i
- 0:33loaded it before
- 0:34into the cache spot and the cache block
- 0:37and
- 0:37when i want some data it's there the
- 0:39tags match
- 0:41best situation well there's
- 0:44the there's a not so great situation
- 0:46which is i go there
- 0:48i go to see the cash it's in the i go to
- 0:50the cover the cupboard's bare i went to
- 0:52the cash
- 0:52the cash wasn't there and we call that a
- 0:55cash miss if i don't successfully get it
- 0:57if i look it up
- 0:58and either it wasn't there because i
- 0:59never loaded that that particular block
- 1:01or the block isn't there it's going to
- 1:02be a miss so both of those cases i
- 1:04kind of walk away unhappy is a cache
- 1:06miss i probably got to go to sacramento
- 1:08to memory to do that
- 1:10now there's a situation where what if i
- 1:13went there and it was loaded by somebody
- 1:15else it's almost like goldilocks wait
- 1:16who's in my bed
- 1:17i went to that block and there was
- 1:19somebody in my right what do you do
- 1:20there
- 1:21and so that's a situation where you have
- 1:22a cache missed with block replacement
- 1:24i went there someone was already loaded
- 1:27into that into that row
- 1:28into that block but it's not the one i
- 1:30wanted so that's a replacement that's
- 1:32got to be replaced out
- 1:34and the new one has to be loaded in
- 1:35there so that's an issue okay
- 1:38cache is always a copy now here's an
- 1:40interesting i i i made this slide this
- 1:42is a brand new slide for this year and i
- 1:44wanted to add that because i've heard
- 1:45people who talk about caches use these
- 1:47words but we never actually formally
- 1:49share with students so i want to share
- 1:50some of the these are kind of informal
- 1:52words we use about the cache
- 1:54are temperatures you can look at a cache
- 1:56and assign a
- 1:57temperature to it well what does that
- 2:00mean
- 2:00well when the cache is empty we actually
- 2:02call it a cold cache
- 2:04it means there's nothing there we think
- 2:06of the heat as how full
- 2:08and successful the cache might be to be
- 2:09able to respond to a future request
- 2:11so as i start to chug through my the
- 2:14beginning of my for loop
- 2:15it's cold if you don't have every code
- 2:16it's always cold because i you know you
- 2:18don't preload their cache the cache
- 2:19always starts empty so
- 2:20it's there by the way you could in other
- 2:22situations pre-load a cache but in kind
- 2:23of normal the computer science
- 2:25the memory hierarchy we don't pre-load
- 2:27caches
- 2:29then i have to warm it up as i start
- 2:32exercising my for loop and as i'm going
- 2:34to memory and bring it in and having a
- 2:36lot of misses we saw that
- 2:37as i misses all of a sudden i'm filling
- 2:39it up and maybe i'm
- 2:40walking across here and maybe i'm
- 2:42filling the rows and blocked okay got
- 2:44that i've got
- 2:45okay i've got it here we go it's warming
- 2:46up it's warming up and now i'm starting
- 2:48to have him hits
- 2:49and now i'm starting to have that good
- 2:51that good warm fuzzy feeling
- 2:52that i'm actually getting back the
- 2:54reason i had a catch in the first place
- 2:55that i'm actually getting some cash hits
- 2:57so i love that so when it's warm
- 3:00they say that cash is now warm when the
- 3:02catch is warm it means it's doing its
- 3:03job
- 3:04it's filled up with you know it's not
- 3:05gonna be perfect every time but it's
- 3:06filled up with
- 3:07probably some recent guys and i'm
- 3:09hitting them i'm hitting some fraction
- 3:10of them
- 3:11now i've also heard hot which means i'm
- 3:14stuck on a tight loop and i'm everything
- 3:16as a hit when i get to the point where
- 3:18basically a high percentage is
- 3:19maybe here and then whoop i jumped over
- 3:21here but mostly it's hits that cash is
- 3:23hot
- 3:23so that kind of temperature is a way to
- 3:25think about it's really fun way to think
- 3:27about
- 3:27um how successful my cash is to be able
- 3:30to respond with more
- 3:32cache hits in the future it always
- 3:33starts cold it warms its way up and when
- 3:36if you're really lucky in a tight loop
- 3:37it gets really hot can it not it doesn't
- 3:39mean that the silicon gets hot it means
- 3:40that the idea that you're just
- 3:42hot means a high chance of a successful
- 3:43hit in the future some more cash terms
- 3:46let's make sure we go through all of
- 3:47them
- 3:49as i'm getting more hits know what a hit
- 3:50is obviously a cash hit means i
- 3:52successfully got there so as i get a
- 3:54cash hit
- 3:57there's a fraction of all the total
- 3:59requests i had how many of them were
- 4:00hits
- 4:01we called that the hit rate so that's
- 4:03just a fraction that's a unitless number
- 4:05it's a fraction of the of the hits that
- 4:07actually were successful
- 4:08the fraction of my requests that were
- 4:10hits i'll say it again it's a fraction
- 4:12of requests
- 4:12that were hits the miss rate
- 4:15is the opposite it's the it's the the
- 4:18complement of that number so
- 4:19they both add to one uh the one minus
- 4:22the hit rate
- 4:23is the miss rate so if i have a eighty
- 4:25percent hit rate whoo
- 4:27you know four out of five requests or
- 4:28hits probably a 20
- 4:30miss rate because you're either hit or
- 4:31miss okay
- 4:35xor or inclusive or
- 4:38you're either a hit x or a miss you're
- 4:41never
- 4:42both see how i fix war with them okay
- 4:46miss penalty miss penalty is
- 4:49the time to replace the block when i
- 4:51have a miss
- 4:52you know you gotta miss what's your
- 4:54penalty you know okay you caught me with
- 4:56my hand in the cookie jar where's my
- 4:57penalty
- 4:58you know it's some wallops on my butt or
- 4:59i have to go i'm on time out for
- 5:01you know i stand in the corner that's
- 5:03the penalty for
- 5:04for having this myth so um the time to
- 5:07replace a block from the lower level is
- 5:08my miss
- 5:09by the way this is true for any cache
- 5:10it's true for any cache to the guys
- 5:12below any cache that's caching the lower
- 5:14element at any level
- 5:16this is you have this miss penalty how
- 5:18how long does it take to get to the
- 5:20level below to bring it back into
- 5:22the level above because you always want
- 5:23to bring that back in and the hit
- 5:25time is what time is it to access the
- 5:28cache memory so this is just great and
- 5:30by the way this
- 5:31counts the tag time i do the tag
- 5:33comparison blah blah blah
- 5:35a lot of these are hardware so they're
- 5:36fast because they're parallel but that's
- 5:38a factor as well you gotta factor in the
- 5:39hit time as well
- 5:40and by the way this is an interesting
- 5:42thing we actually use a dollar sign for
- 5:44cash
- 5:45so kind of like you know the whole the
- 5:46whole kind of that
- 5:48i know what this means this means i'm
- 5:49hitting my hands i know what this means
- 5:50but
- 5:51cash money people so think of a dollar
- 5:53sign for
- 5:54a berkeley innovation we may as far as i
- 5:57know
- 5:57my predecessors invented that they use a
- 5:59dollar sign for cashes
- 6:01there's one more piece of information we
- 6:03need which is
- 6:06i mentioned this earlier do we have a
- 6:08sentinel value
- 6:09that the cache can never have to know
- 6:11when it's remember we need to know
- 6:13whether
- 6:13am i cold am i warming up how do i know
- 6:16when it's
- 6:16garbage data so do i have to re i write
- 6:19zeros to everywhere
- 6:20i can't just write zeros everywhere
- 6:21because you could have a tag of zero and
- 6:23a data of zero and that doesn't make any
- 6:25sense so
- 6:25am i gonna let's reserve a spot that can
- 6:28never be in the well that doesn't i
- 6:29don't like that either
- 6:30so what we're gonna do and this is a
- 6:33clever design decision you may have come
- 6:34up with this on your own
- 6:35is have a bit just call it a valid bit
- 6:38and when that bit is zero
- 6:40it's not valid and when bit is one now
- 6:43it means i have good data there
- 6:44so by having a single bit it saves me
- 6:46from having to kind of
- 6:48write to my cache to erase it putting
- 6:50the sentinel value in
- 6:51just have a single bit once i set those
- 6:53all the zeros
- 6:54that the cache is is is is cold and has
- 6:57garbage values in there
- 6:58so we're going to use what's called a
- 6:59valid bit to store it which is nice and
- 7:01this tells me whether that tag is valid
- 7:03because the tag can be anything
- 7:05the tag is my cache number that's from
- 7:07zero to the maximum number of
- 7:10cache copies i could have in memory
- 7:11that's it that's all i've got
- 7:13so there's no bad value there so we
- 7:15don't you want to think about having a
- 7:17sentinel and borrowing one of those guys
- 7:19we want to be able to access anything
- 7:20any part of memory should be able to be
- 7:22in my cache which means any tag whatever
- 7:25however
- 7:25wide bits wide my tag is that could be
- 7:28any bit pattern i don't want to use up
- 7:29one of those bit patterns i don't like
- 7:30that idea it's not a good design
- 7:31i don't like that from a computer
- 7:32engineering point from an engineer
- 7:33period i get the computer i don't think
- 7:35from an engineering printer to waste
- 7:36something because i can't think of
- 7:38having another bit
- 7:38now i do you know ain't no free lunch i
- 7:42need to borrow some space to store that
- 7:44vial but anyway but it's better than
- 7:45having to steal
- 7:46some memory that i can't access anymore
- 7:48it could never be in the cache i don't
- 7:49like that model i like to battle a bit
- 7:50better
- 7:51so that's it zero is there so
- 7:54zero is like when i go to request it if
- 7:57it's zero it's always gonna be a miss
- 7:59a cold cache has all zeros in the valid
- 8:01bit it means there's nothing there
- 8:03it has bits there but they're garbage
- 8:04all the tags are garbage you can't trust
- 8:06them you can't trust them
- 8:07i'm telling you give them some money
- 8:08they'll never return it can't trust it
- 8:10can't trust those tags if the valid if
- 8:12the valid bit is set to zero
- 8:13if you can't if there's one then you can
- 8:15trust it this idea
- 8:16so here is a picture here's a beautiful
- 8:18picture a 16 kibi byte
- 8:20how many bits why how many total bits
- 8:22for my
- 8:24for my i and my oh 16kb come on 16 kb
- 8:2716 14 bits
- 8:302 to the 14 is 16 kb bytes
- 8:33okay so 14 bits for total amount
- 8:37and i have here look at this oh look 0
- 8:39through well
- 8:40i'll i'll do with the other numbers
- 8:41later oh say here we go 16 by blocks
- 8:43in my head i'm already doing 16 byte
- 8:46blocks
- 8:47okay well 16 kibi byte total 16 by
- 8:51blocks that means the width of 16 bytes
- 8:52how many rows
- 8:541k 1k times 16 is 16k
- 8:57that's not that hard okay so how many
- 8:59bits for 1k
- 9:0110 10 bits of index how many bits to
- 9:03tell me what byte it is for 16
- 9:054 four bits four here ten there
- 9:09that's 14 bits there's my total area to
- 9:11the 14 to 16 kb it just works
- 9:14and there's my valid bit and there's my
- 9:16tag
- 9:17so my valid bit is set and we're going
- 9:19to reset it to make it all zeros
- 9:22this looks like a real cache i'm feeling
- 9:23pretty warm this is pretty i'm feeling
- 9:25pretty good about this this is a nice
- 9:27model this is a picture that we might
- 9:28use
- 9:30this is the end of this lecture i'm
- 9:31pretty excited we're already kind of
- 9:32half this is it there's a halfway point
- 9:34we're downhill from here we're going to
- 9:35see a really nice example very detailed
- 9:37example as we play with this and
- 9:39expand more of the parameters of how to
- 9:41expand our cache
- 9:42we're going to show you a cache and say
- 9:43well it doesn't work in this way and
- 9:45we'll add this feature
- 9:46it doesn't work in this way we'll add
- 9:47these features and we haven't talked
- 9:48about rights yet we've only talked about
- 9:49reading bytes for now so we'll talk
- 9:51about
- 9:51a more general thing in the cache as
- 9:53well but in conclusion
- 9:54in these lectures you've learned the
- 9:56operation of a direct map cache the
- 9:58simplest kind it comes from
- 10:00i hope you understood and appreciated
- 10:02the tio
- 10:03and the kind of where to think about
- 10:04that i did in the last lecture i thought
- 10:06that was useful
- 10:07we talked about a mechanism for moving
- 10:08data back and forth in the memory
- 10:10hierarchy which is kind of neat
- 10:11there's address and value bindings from
- 10:13the point of view of the program i don't
- 10:15even know whether it's a cache or not it
- 10:16just is faster when it does
- 10:18have a cache so i don't have to change
- 10:19anything now if i did change something
- 10:21that'd be great because i could optimize
- 10:22for the cache and that would be
- 10:23something we could talk about later
- 10:25we got to compare our address with the
- 10:26tag and we got to be able to handle the
- 10:28hit or miss
- 10:29that's the idea and when it's missed we
- 10:31gotta load the new block and reset it
- 10:32and bind it up on a miss
- 10:34okay that's it we're done with this
- 10:35lecture we're done with we're at the
- 10:37halfway point
- 10:38we will see the next set of lectures
- 10:40cache is part three take care
About this transcript
This page contains the full transcript of [CS61C FA20] Lecture 25.3 - Caches II: Cache Terminology by CS 61C Departmental, generated from the public captions YouTube serves with the video. The transcript has 2,439 words across 373 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.