 Good morning, everybody. Everybody stand up. All five people who are here. Come on, Jen. She doesn't like standing up. I don't know how she got here today. But apparently, it didn't involve standing up. I didn't notice you being wheeled into the room. But OK, that's good. So today, we're going to start off by just quickly reviewing clock LRU, just because we kind of sped through that at the end of class last time. And then we're going to start talking about disks. And this is actually a kind of fun video Friday, because we get to watch some movies today in class. So that's kind of fun. I don't know. That was always a nice thing about high school, right? There was always this high probability. I don't know. Maybe the probability has increased since I went to high school. But there was definitely a non-zero probability in any class that you would just end up watching a movie. And maybe the probability is higher now. But today, we're going to watch a few movies. Not the whole period, but no, a couple. All right, so I was just looking at last year's slides. And last year, assignment two was due on March 26, which is several days ago. So this year, there are no due dates. But that's somewhat of an idea of the pacing, the trajectory you guys should be on. So anyway, provided without too much comment. And then, yeah, so assignment three, the auto-grading scripts, I'm going to finish writing those today. And then that should be done. So at that point, you will have all the tools necessary to grade your own work in the class. And hopefully, we'll get that done today. So you'll have about five weeks, potentially, to do assignment three. I think recitations next week will be on assignment two. But at that point, I'm going to tell it to you. You just got to keep going. If you guys are still working on assignment one, then recitations are going to start to feel like they're for some other course. So it's time to catch up a little bit. All right, so let's talk quickly about clock. We just went through this really, really fast. So the goal was that we wanted something that was like the least recently used page replacement algorithm without requiring as much state. Because we looked at LRU policies, and we thought, man, I might need to keep a lot of information about how long it's been since each page was used, which is the information that I'm using to try to predict how long it's going to be before the page is used next. And so rather than doing that, and having to search all that information, we came up with something called the clock. So the clock uses one bit of information on every PTE that is set whenever the page is accessed. Or again, whenever the kernel notices that the page is accessed. So it wins one time that the kernel will definitely notice that the page is being accessed. Or alternatively, you could tell me a time when the kernel will not notice that the page is being accessed. So that's one of them. Which category does that fall into? When it knows, right? When it knows is when the MMU asks, why is the MMU asking, Robert? So when there's no translation in the TLB and the MMU asks me, at that point I know that the page is used. Because what caused that was an eb-tent to access the page, right? OK, so when does the kernel not know that the page is being used? Dan? When it's already in the TLB, right? Or when it's already in the MMU. And with hardware managed TLBs, this is a little bit different, but I'm not going to cover that too much. But the point is that the kernel has some limited visibility to when pages are accessed, particularly when the memory management unit causes either a TLB fault on a software managed TLB or a page fault on a hardware managed TLB. That's when I know that the pages has been accessed. And at that point, I can mark this bit. And then what's going to clear the bits is the algorithm. So when I need to find a page to evict, I'm going to essentially cycle through all the pages in this fixed order. So I just walk through all the pages on the system. As I go, if I find a page that has a clear bit, I use that page. That's the page that I choose to swap out. If the page bit is set, I clear it. And then I keep going. So here's our nice description, right? So these four PTEs have their bit clear. This is where the algorithm starts. So it clears the bit on this PTE because the bit is set, and then it keeps going. Now, this PTE on the first iteration of my algorithm is the one that's going to be evicted. This page will be moved to disk, and its contents are placed with something new. The next time the algorithm runs, I'm going to keep going until I find this page, which will be removed, et cetera. So here's a question, at what point will these pages go from having their bits clear to set? When does that happen? Amen. Yeah, so the kernel page fault handlers or TLB fault handlers are setting these bits. The algorithm is only ever clearing the bits. So this algorithm will never set a bit. But that's how the bit status changes in both ways. So the algorithm clears it, the page fault handler sets it. So then the question I left you guys with last time is, what does it mean about the system if my clock hand is moving slowly? What does that mean? How can I use that as an indicator of system performance? Tom, is this like a text-to-friend sort of thing? Oh, no, that's perfectly applied. No, no, no, that's fine. Wembley. System is idle. Yeah, or let's put it this way, my page replacement algorithms are working pretty well. Because I'm pretty quickly finding a page that's not being accessed, or right, or load is low. Or there's not much going on. Because the idea is, there aren't very many bits being set. And so the bits are clear. And so my algorithm is finding a page to evict pretty quickly. What happens if the clock hand is whipping around really, really rapidly? What does that mean? Jen, we had a term for that last time, potentially. Tom? Yeah, it could be thrashing. Because I'm trying to look for a page to evict. And I'm clearing all the bits. And in the worst case, maybe by the time I get back to the top of my algorithm, all the bits have been set again, because the system is constantly trying to page things in and out. So in general, the hand spinning around rapidly indicates the system is really heavily loaded. So that's kind of some intuition about how clock works. Any questions about clock or really anything else with virtual memory before we barge onward? All right, so, oh, sorry, mom. Does the clock LRU use that? Yeah, yeah, OK. So that's a good code. Yeah, so I think you can implement a version of clock LRU that actually also incorporates some idea of a dirty bit. And maybe instead of using the page access, I actually look for pages that are clean. Yeah, that's possible. I could incorporate that, but I have to think about a little bit more how you would combine those two things. That's a good question. Because again, if we're on the page fault path and we can find a clean page, we'd love to use a clean page. Because that means that we don't have to do an IO in order to evict the page from memory. Yeah, that's a good question. And you get to see my little animation again, which is great. All right, any other questions? All right, so let's start talking about disks. So again, we're going to throw out some degree, right? Although we're going to end up reusing a lot of concepts from virtual memory and from CPU scheduling a lot of other things. So and to some degree, disks are kind of fun, right? They don't have, at least in my opinion, they don't have some of the conceptual simplicity and elegance that some of the things we've talked about so far do. But they make up for that in just sort of like nitty gritty details and weirdnesses and things like this. So disks are kind of a kind of, and there were 10, 20, 30, 40 years of really interesting file system research, right? That was really based around this, right? And you'll see some examples of people who really took a lot of time to understand how these devices work and built file systems and disk scheduling techniques and stuff like that that are really, really grounded in the real details of how disks work. So that's kind of cool, right? And again, there's all sorts of interesting things. So the other thing, of course, that's happening right now that I'm sure you guys are aware of is that there's this new technology called Solid State Drives, which are drives that are built on flash memory, which does not lose its contents when powered down. For many applications, those are starting to replace magnetic spinning hard disks, right? And there's some people, I was talking with somebody after class last week, who really think that spinning disks are essentially a quick to be completely obsolete technology, right? There's a guy at Stanford who's doing research into building server architectures in particular, right, that are completely disk-free, right? They don't use any stable storage. Why would you consider a memory-only architecture for a server, but not maybe a memory-only architecture for your laptop? What's the big difference about servers, typically? No, so that's the great thing, right? And memory is also much, much faster, right? But what do servers typically not do that your laptop typically does? Sarah, they don't turn off, right? You can imagine clusters of servers that just stay on basically forever, right? And so they don't need stable storage, right? So stable storage is used on computers because it's there if your device turns off, right? There's some state I want to store on the device, right? If I have a server cluster that my intention is to never power down, then who cares, right? I don't need a disk or I don't need, maybe I need a tiny and tiny disk just to keep my operating system on, but I really don't need a lot of disks, right? Because the theory is that I'm gonna store all my contents in memory and I'm never gonna power off, right? So when we talk about stable storage, we talk about what we're talking about for both SSDs and HDDs. Solid state drives, we call it SSDs, and hard disk drives, we usually refer to as HDDs. And these, I don't wanna lump these together too much because they're quite different, right? So spinning drives, right, which we've lived with for several decades, again, have all these really kind of funky characteristics partly because they're physical devices, right? So if you have a computer, and many of you do, and that computer has a disk drive in it, it is the only thing in that computer that is moving, right? None thing else inside the computer is moving, right? The disk, if you have a spinning disk, it's the only thing inside the computer is moving, and if you don't, there's nothing left in the computer that's moving, right? So actually, I was in my office last week and I tipped my laptop over and it, wham! I fell on the ground and I was like, oh, it's just too bad, you know? But then I picked it up and it was fine, right? Because it has a solid state drive in it. I was like, yes, this is so good because there's nothing moving, so who cares, right? Oh, you know, I went through like half a dozen hard drives on my last laptop because I kept dropping it, right? And those were spinning and every time you dropped it, well, we'll see what happens today, so. So yeah, so it's the only really physical drive and all the physics and sort of the movement of it end up producing these fun problems for operating systems to solve and file systems to solve, right? This is data from last year, right? But in general, right, and this trade-off is still true, right, and with any new technology, you see this kind of price curve that goes down. You can sit up in the front, too. I'm just so used to having you up here. You sit back there, I won't feel lonely. So, but in general, I mean, I think I, I don't know where I pulled these numbers, right? And it should be a gigabyte, of course, but you're still seeing at least an order of magnitude difference in price per gigabyte for spinning disks and solid state drives, right? And to some degree, this is the only reason that we still have spinning disks, yeah, right? Yeah, so that's a good question, right? So, yeah, okay, so the parts of the stable storage that I use for paging are typically clear, right? They're not necessarily actually clear because why spend the disk IO, but the operating system doesn't reuse the contents, right, does that make sense? Yeah, I wouldn't go and zero them out because that would take a lot of time and it would just be silly but I wouldn't necessarily save the contents. But you could potentially but I don't think modern systems do that, right? Because once you re-initialize memory, the assumptions are gonna have completely new contents, right? However, if you think about sleep states on your system, right? So many of you guys have laptops that sleep or other sort of devices that are able to sleep, those devices will essentially store the contents of memory on stable storage, right? And then reload it from stable storage when they start up again, right? That's how these sort of deep sleep hibernate modes work, right? I've got the contents of memory, I kind of take all the contents of memory and push them onto disk, right? And then when I boot up again, I take all those disk contents and reload them into memory and essentially I'm in the exactly same state I was when I powered down, so that's kind of neat. But again, so this price curve is really the only thing that's, I think, as well as just the fact that it takes a while to get rid of legacy technologies that's still causing us to use hard disk drives, right? If once these numbers catch up, hard disk drives will pretty much go away, right? So, and yeah, if there's the distinction that needs to be made, please ask me to make it because hard disk drives and solid state drives have pretty different characteristics. A lot of what we're gonna talk about are hard disk drives, right? And you might ask why, right? Because hey, flash drives are the future, they avoid all these ugly problems with hard disk drives that we're gonna start talking about today, but hard disk drives are still out there, right? And I think they will be for a while, right? I mean, big, you know, and part of the reason for that, right? Let me go through this more slowly, right? Part of the reason that hard disk drives, so what do you think what's the reason that hard disk drives are still around, right? So, okay, I've got this, solid state drives are, in many ways, much faster and perform much better, right? But hard disk drives are, so you might say hard disk drives are cheaper per gigabyte, but who cares, right? I just, you know, I mean, I might as well spend the money and get the performance that I want, right? But what else has been happening over the last 10, 20 years that's caused hard disk drives to sort of stick around, it might cause them to continue to stick around, right? What else has been increasing at this? And you've seen these graphs that sort of go up exponentially to the right. I saw one of these in one of our faculty candidates' job talk a couple of days ago, right? Yeah. Not requirements for memory, right? We're talking about disks, right? What do we have more and more of? The amount of data that you want to store? The amount of data that is stored, right? So you think about, you know, now if you, apparently if you buy one of these overpriced new Google Chromebooks, right? You get a, that's not my impressions like some, I read a review of these online. I never do that, but someone I know bought one and you get a terabyte of online storage provided by Google, right? A terabyte. What? Isn't it a three terabyte? I don't know, maybe it's three terabytes. I hear three terabytes from this corner of the room, right? So it's a lot, it's a lot of terabytes, right? I mean, I remember a friend, you know, when I was in college, it was like, wow, you know, one day I think I'm gonna build this massive disk array so I can have a terabyte of storage, right? And now you can have it in the cloud for free because you spent $1,000 on a, on a, on a netbook, right? So, so yeah, I mean, we've got all this, all this data that's being stored. Now how much of that data is being processed? Who knows, right? But I mean, you know, how many people use Gmail? You have an only, you know, basically unlimited. How many people have ever run out of space on Gmail? Yeah, that would be a sign of something. I'm not sure exactly what, but so I mean, we've got all this data that we're storing, right? And a lot of it, that data at places like Google is sitting around on spinning disks, right? And, you know, until hard, until SSDs catch up with the, you know, price per gigabyte, I think that's going to be continued to be true, right? And to some degree, you know, a lot of that data isn't really an act of use, right? I mean, a lot of your Gmail is sitting there and you might not, you know, how many people read all their messages on Gmail every day, right? Yeah, that's probably taking all of them. Going back to the beginning of, did you start using Gmail yesterday? Yeah, so I mean, most people have very, you know, very, very cold, shall we call it, email, right? Email that almost never gets used or looked at. So, so how much of that data is being accessed? You know, that those are questions that are interesting to think about. And there's a lot of work trying to figure out how do we integrate these new storage technologies into kind of the storage stack, right? So I've got memory, which is very fast, disks, spinning disks, which are very slow but very big and cheap per gigabyte, where do we put SSDs and how do we use them, right? How do we fit them in there? And one of the, you know, candidates we interviewed this year is working very, you know, very hard on that problem, right? They're all working hard on something, right? He's working on that problem in particular. So, so yeah, so we still have all this data and all that data really right now, you know, fits on hard disk drives, right? If you ask Google and they said, hey, I can replace all your hard disk drives with SSDs, it's just gonna cost you 10 times much, like that, no thanks, right? Especially for all that old email nobody's reading. The other thing we're gonna talk about for the next, you know, a week or two are these, are things called hierarchical file systems, right? Many of you guys have used hierarchical file systems for years, but not really even understood that you were using, right? How many people have ever, have ever called your systems, your systems storage hierarchical, right? But you guys know about hierarchical file systems, right? You have folders with sub-directories and you go, yeah, those are hierarchical files, right? But to some degree, search-based interfaces, especially to storage, have really started to, to predominate, right? So, you know, it used to be that people like me and maybe some of you guys were like super hyper-organized with how you put things on your computer and every MP3 had to be in the right sub-directories somewhere and that was like very important to you, you know? It's like very much of my, my well-being during graduate school was, was predicated on the fact that like certain characters didn't correctly map to UNIX file names and so that was causing me difficulty in arranging my large MP3 collection, right? So, but now it's like people don't, people don't care where things are on their computer, right? I mean, a lot of times the interface provided by something so, you know, you use iTunes, right? You buy an album from the iTunes store, who knows where that album gets put on their computer? Okay, maybe about half of you, right? Who cares where the album gets put? See, iTunes, don't worry. It's kind of embarrassing. It's like I have this problem with, with where things are on my computer but I shouldn't care anymore, right? Because iTunes knows where it is and if I need to find it, I can search in iTunes and things like that. So, to some degree things like Gmail and there's people who are, there's some people who are like, oh, these interfaces are terrible, search is so disorganized, it doesn't help people really have access to information but, you know, how many people use Google Docs? How many people carefully arrange all of your Google Docs files into folders and some directories? Talking to the wrong crowd. Anyway, a lot of people probably don't, you know? I know people that don't, including one who I'm married to, right? So, and a lot of, you know, they find things that's like, oh, well, what did I call that file and they start searching around it? Pretty soon they have it, right? So search, so there's other people who have said, you know, these hierarchical file systems aren't useful anymore, they don't reflect the way people think and so let's get rid of them and replace them with search-based file systems but again, I mean, a lot of search-based file systems, things like Spotlight for Mac and all these, you know, that, does Windows still have the dog? The dog that helps you find things, yeah. So that guy, that pup is built on top of, those are still built on top of hierarchical files. So that's still what we have, right? And again, I mean, there are these, this is a fun area to think about, right? Especially with all this data that we're storing, you know, big data processing and things like that but a lot of these solutions are gonna be built on top of earlier solutions and to some degree, if you can understand some of these earlier technologies and the approaches that were taken, I think it puts you in a good position to think about these new emerging problems, right? And again, and this is another area, right? Where we're talking about these really mature systems, right? So people have been designing and redesigning hierarchical file systems for decades, right? And I have to say, you know, I've used some of the, you know, more mature outputs of this recently and I've been really impressed by them, right? By what they can do, by all the problems they've solved, they're really, really mature. So how many people have used ZFS before? Yeah, okay, see, now I'm getting to the hacker crowd. You know, people are still working on these problems and actually some of those solutions are really, really nice, right? All right, so let's talk about spinning disks, right? So spinning disks, fundamentally, where data ends up on spinning disks is something called a platter, right? A platter is a, you know, and I wish I had a disk here to take apart and show you guys, but you know, it's a piece of very rigid material that's coated with a magnetic substrate that allows it to store data. Usually data is written on both sides, right? Because why not? The spindle is the drive shaft, right? On which multiple platters are connected, right? And then all those platters get spun around at, you know, a fairly, fairly high rate of speed, right? Up to potentially 15,000 RPMs for maybe even faster now for sort of high-end server drives, right? And then now we also have, you know, so we have the data on the disk, right? We have the data on the platter. We have the platter going round and round. And then we need something to kind of move around on the platter and read and write data and that's what we call a head, right? So the head, essentially it floats, right? We don't want it on the platter. We'll see what happens when it gets on the platter later. But we want to float right over the top of the platter, right? And it actually turns out that, you know, it's spinning at kind of tiny, tiny nanometers over the top of the platter, right? Reading and writing data, right? So here's a picture, all right? Here we go. So, you know, you can ignore most of the parts of this, right? They aren't super interesting, right? Here's the top platter, right? The others are stacked below it. The spindle on which the platters are mounted. And here's the head that, this is what's called the actuator and all the heads for the disk are mounted on this. How many people have ever seen a disk sort of disassembled like this before, right? Okay, that's cool, right? So when we start talking about disks, we talk a lot about where data is on the drive, right? So, you know, where the bit or the byte or the sector that I'm looking for is in relation to other parts of the drive. In order to do that, we talk about dislocations using a piece of terminology, right? So the track is like a lane on the disk that runs around on one of the platters, right? The sector, so it's, all right, here we go. Boom, picture, right? So track, right? Tracks are these, you know, is on one platter this sort of circular, you know, circular thing that runs around. I wish I had better like geometry words. I was gonna say hemispherically, but I don't think that's actually correct. It just sounds cool. So the sector, a sector is like a pie shaped piece, right? And you break up disks into multiple sectors that kind of run around here again hemispherically, which is wrong, but. And then a cylinder, if you imagine taking the disk, right, and disks are composed of all of these stacked platters, right? And taking like an aluminum can that might have had dog food in it, you know, but then you would clean it first, and you would take it and you would push it down through the disk. All the tracks that it would intersect are what we call a cylinder, right? And the reason why cylinders are important is because the heads on a disk are typically in the same place on every platter, right? So a cylinder represents all the data that the heads can potentially access without having to move, right? So imagine there's actually between a cylinder and the set of platters, right? So these are vertically aligned tracks. So if you imagine, again, you got to go down, does this make sense to people? I'm probably belaboring this. How many people think this makes sense? All right, cool, great. All right, here we go, this is video time. This is awesome. So here is, oops, sorry. I think I need to do it over here too. Here is a disk. So platter, spindle, head, this is the actuator arm. We're going to watch this disk do its thing. That's the top platter, right? The top platter is usually the only one that's visible, right? The rest of them are stacked underneath it. So this badass is taking the hard drive off. You should try this at home, especially if you have a lot of extra disks, right? So there it goes, see it's spinning? So you guys are going to see what makes that noise. There, check that out. How many people have heard this noise before? That's what it is. So now he's going to do some stuff, right? So this is Windows probably deleting a folder because no other file system requires like thousands of operations to delete a folder. But here's, I don't know why this goes on for so long. But so the disk is spinning, right? And this head is moving along the disk in order to read and write data, right? So I think he's going to do something else now or maybe not. Oh, copy, paste. So this is kind of cool, right? You see the disk is kind of, the heads are kind of oscillating between two different locations, right? That's probably where the data is coming from, right? This is a copy and paste and where it's going to. That's pretty cool, right? I don't know why it keeps stopping, but it gets tired. I can't remember how long this goes on for. There might be one more cool thing to see. Oh, here we go. So this is a quick format, boom. So if you've ever formatted disk using Windows and you didn't make the mistake of not choosing the quick format option because the other one takes like 10,000 years, that's what happens. There we go. Cool, right? Nick, well, we'll come back to this when we talk about files. In theory, deleting a folder should require just writing a small amount of information to the disk. Yeah. How was the head getting to other platters? What's that? How was that? Ah, good question. So how does the head get to the other platters underneath? Does anybody know? Manish? Yeah, so that actuator arm actually has pieces that go in between all of the different platters, right? And this is why the cylinder, so it's difficult to think about this in 2D, right? But this is why the cylinder group is kind of important, right? Let's see here, right? So this just makes sense to people. It's difficult to understand, but you can imagine that that head is, again, that actuator arm, if you take it out, it actually has a bunch of different heads, right? And there's one for the top platter, and then there's one in between every set of platters and one on the bottom as well, right? So it can rewrite data to any side of any platter. But, again, for a disk like that, those heads are in the same position on every platter, so that's why we talk about a cylinder, right? Because a cylinder refers to all the disk parts that can be read without moving the head, read or written, right? All right, so we have our, this is pretty cool. And so, and when we start talking about disks, right? I mean, disks are in many ways really quite distinct from other things we talked about, right? We talked a little bit about this, right? So again, disks move, right? Dysks are slow, right? And really, they're slow because they move, to some degree. And disks are devices, right? So to some degree, if you think about, we've talked about processors and memory, right? These are abstractions that are, and components of a system that are really tightly coupled with the operating system, right? Dysks, you know, you get a computer, you can add a disk to it, right? And, or you could take out a disk, you could replace the disk you have with a different vendor, right? So disks are on some level devices, right? We don't talk about the CPU and memory as a device. They're kind of like the computer, right? The disks are devices, and so they're a little less tightly coupled to the abstractions that are built on top of them. And this is kind of significant, right? Because what we want is, you know, and this works really beautifully now, if you, when you use modern file systems, what would be great is if I have my computer, I add a disk, and the file system would just naturally expand over all the disks without caring what kind they were or the details of how they work at a very low level. And actually, that is what happens today, which is pretty awesome. So, and again, this is partly just because, why are disks slow? They're slow because they move, right? I don't want to belabor this point, right? But electrons moving along between your CPU and your processor right are fast, right? Physical objects moving back and forth, those heads spinning, it looks like they're going pretty fast, right? But they're not, right, compared with other things, right? This is completely gratuitous, but I just wanted to show this because this is an awesome video. How many people have ever used a table saw, right? So if you've ever used a table saw, you know that there's this possibility when you're using a table saw that you can cut off parts of your body, right, with that saw, and this guy came up with this, what I think is just this incredible technology for what's called a safety saw, right? So let's just watch it in action, right? This has nothing to do with this class, I'm sorry, but it's just really awesome, all right? All right, I don't care. I don't know this guy at all, okay? This is not a product pitch, I'm just... So essentially they monitor the voltage across the table saw and use it to detect human flesh, and then they can stop the blade within like, I don't know, very, very quickly, right? It ruins the blade, but check that out. Do you see that? So there it's your finger, boom. The hot dog is complete, well, it's nicked, okay? But you would take that rather than having your finger, finger gone, right? Anyway, so it is possible for physical devices to move quickly, but, okay, anyway, sorry, sorry about the minor digression, but I think that's pretty awesome. All right, back to computers. So the other thing that's interesting about disks when compared with other parts of your system is that disks fail, right? Discs can wear out, and part of that is because they move, right? And there's a couple of interesting things that happen, right? So first of all, disk manufacturing technologies for a long time would mean that certain parts of the disk were inoperable. When you bought it, actually, right? So it's like one of the things that frequently happens when you initialize new disks and the disk sometimes does this itself, right? Is the disk will detect that there are certain sectors, certain parts of it that don't work, right? They just, for whatever reason, maybe they just, that part of the sector can't store or recall data and the disk will transparently ignore it, right? There was actually an interesting project that somebody did a couple years ago where they ordered like 20 identical disks, right? From the same company, right? And like the same batch on the same day, and they did these performance tests on them, and they found really big performance differences, right? Like significant performance differences you would not expect, right? And this matters to companies like Google because Google orders like thousands and thousands and thousands of hard drives, right? And some of Google's algorithm has probably assumed that those hard drives perform kind of the same. It's the same drive, right? Well, it turns out that, you know, because of the details of the manufacturing process and problems like this, those disks can frequently have pretty big performance differences, right? Over time, parts of the disk can also fail, right? And this is, I think, less common than it used to be, right? But it used to be, you know, you would have cases where your disk would lose a little bit of data, but it would usually be able to recover from it depending on which sector failed, right? Disks, you know, can also frequently just completely fail catastrophically, right? This is a physical device, right? It's like a car, right? If you take it and you slam it into a wall, it doesn't work anymore, right? And one of the things that can happen to disks, right, is kind of the equivalent of a car crash when we call it a head crash, right? And what this means is that when some, you know, some jolt to the disk, remember those heads, right? Those heads are just floating nanometers over the surface of the drive, right? That surface of the drive is coded with a, you know, this substrate that's there to hold data, right? If you take that head, right, and you push it down into the drive, it just starts scraping that stuff off, right? And given how fast those disks are spinning, it can take off a lot of material, right? And then that disk doesn't work anymore, right? And this has happened to me several times, so I knew exactly how this works, right? When you dropped your laptop, or you would at least, this used to be true, right? The laptops, even with spinning disks are much better at this now, and we can talk about why that is. But, you know, the machine will last for 20 seconds. I don't know, that's not like a rigorous figure, but that was always my experience, right? Like you pick the laptop up, you kind of get to look at it, and maybe type a few things, and then it, you know, then it's over. Okay, so, and here we go. Another video, I told you it was video day. All right, so here is a video showing what happens when you have a head crash, or, oh, this is the result of a head crash, right? So check this out, this is not a stripe on the drive that it came with, right? This is not a racing stripe. This is missing material that was caused by heads making contact with the drive, and scraping off stuff, right? So yeah, so this disk is not going to work anymore. And this was what would, what that is. Yeah, I don't know. So I guess he's pointing out that this filter, which is supposed to help remove debris from the drive, has essentially absorbed all the debris that was caused by this head crash, right? There we go. Yeah, back up your data. All right, so, and so we're also gonna talk, when we talk about disks, and particularly about file systems, about, yeah, Frank, you got a question? Exactly, right? So this is really common, right? And one of the reasons my laptops kept failing when I was a graduate as soon as I was running Linux on them, which didn't actually use those sensors properly, right? But this is, I wasn't gonna mention this, but it's cool to mention anyway, right? So modern laptops now have these sensors, right? So they're essentially accelerometers. So when they detect an acceleration, right, like one might be caused by dropping your machine, what they do is they do something called parking the heads, right? So they very quickly take the heads and they just move them to a safe place, right? They can't stop the drive, right? You can't stop the drive from spinning. It's spinning too fast, it has too much momentum, right? But what you can do is you can get the heads out of the way, right? So this is called head parking. And with some drives, you used to be able to hear this, right? If you took them and took them a little bit, you would hear this noise as the disk rapidly parked the heads, right? Does this make sense to people? So rather than letting the heads attach to a drive, use these accelerometers, you build some sensors into it and then you rapidly park the heads. And I think actually on some systems this was done in software, right? I think there are probably some drives that do this automatically. I won't tell this story because I've told too many stories already today, but there's this fantastic story that I heard from a Google engineer once about a really, really fascinating interaction between those sensors and the way that some of their servers were designed that caused this really, really weird performance problem. But again, I won't tell the story. If you ask me about it, if you want to hear it, it's really, really fascinating. So when we talk about this, we always have this idea in mind that they can fail, right? And when they fail, they hold stuff that people want, right? So things like the, I mean, CBUs in memory don't typically tend to fail because they're not physical devices, right? But the other thing about disks is not only do they fail, but they usually have stuff on them that people want to keep because people put it on the disk so that it would stay there, right? And so we're gonna talk about failures both and we talk about several ways of addressing failures. So one is through file system design, which we'll get into another is, hopefully we'll have time to do this lecture this year and another way is actually called RAID, right? Which many people may have heard about or worked with machines that use RAID and RAID can also be used to increase performance, but one of the reasons people do use RAID is to increase reliability as well, right? So you take multiple disks and you use statistics to say, you know, if there's this probability that one disk fails and I start adding disks to it, if I'm clever about how I put my data, lay out my data, I can tolerate some number of disk failures before I actually start to lose things. And again, as a performance bonus, as a bonus you get some performance out of the arrangement as well, right? And disks are, you know, when systems become IO bound, right? The disk frequently starts to bottleneck other parts of the system, right? And so operating systems and file systems do quite a bit, right? To try to hide these latencies and there's, you know, especially so, this was maybe, man, I'm getting old, you know, 10 years ago when I was, you know, I did an internship at Microsoft in a group that was looking at desktop performance and their big focus was on trying to get slow disks to perform better, right? Because at that time, and this is still kind of true, right? What was happening is that you were shipping these consumer devices, you know, desktops and laptops with big disks, right? People wanted space for all of the pictures of their grandkids, right? But those big disks also were slow, right? So Moore's law is like, you know, pushing processor speeds ahead rapidly, right? And to some degree, memory bus speeds were keeping up with the processor. So you're getting the processor and the memory that were like racing off into the distance in terms of speed and the disks were like plodding along and they were just getting farther and farther and farther behind. And so that huge gap in performance was starting to have some really problematic consequences and there were people who were really working on this. But we'll see all of our usual games that we talked about and the systems design techniques, we're gonna apply those principles to disks as well, right? And also the operating system is involved with this, right? So memory latencies, you know, if people have studied computer architecture and know about out of order processing, you know that the processor is the one who's usually working on trying to hide the delays in memory, right? But here, this is the kernel's job and file system's jobs, right? Is to work on these distalings, right? So let's talk about the actual, I think we get through to say, let's talk about the actual process, right? Of reading or writing from a disk, right? And we're gonna talk about this in kind of general terms that we'll get more specific later, right? So again, I have this disk, I have platters that are spinning around at high speed, I have my spindle that's got some heads on it, right? So the first thing I have to do is tell the device what to do, right? I have to issue the command and the command has to cross this device bus, right? And then the drive has some thinking to do, right? So the drive actually helps out here, the drive has to figure out which head do I use to access that data, right? Because remember, that data that I'm asking for is gonna be on some platter and normally, I mean, it depends on the layout of the disk, right? Some disks have multiple sets of heads that they can use independently, right? So it's possible that it's not as easy as just figuring out which head, like which is the only head that can access that platter. Sometimes I might have multiple choices, right? I need to figure out which one to use, right? The next thing that has to happen is the drive has to move the heads, right? You saw this happening on that video, right? That's what was happening with that, the actuator was moving back and forth, right? So the operating system was saying, I wanna read this piece of data and the drive was saying, okay, I've gotta move my heads over here, right? The next thing that happens, right? Is that you think about it, I've got these disks that are spinning at a high rate of speed. The tracks on the disks are really narrow, right? Why do I make the tracks on the disk very narrow? The tracks where I'm gonna store data. Why would I make them as narrow as possible? Yeah, yeah, I mean, to some degree, the smaller I can make the bits on the disk, the narrower I can make the tracks, the more data I can jam onto the drive, right? The problem though is again, imagine this, like you've sent this head, like racing across to the other side of the disk, right? And then suddenly it's gotta like settle on this tiny, tiny, tiny little track, right? So this actually takes some time, right? Now that I'm at the track, right? I need to wait because potentially, right? Because the data is somewhere on that track, right? So now the heads are on the right location, but the disk is still spinning and so I have to wait for the data to come under the heads, right? So once I get to the right track, it's possible that the data is still on the other side of the drive and now so I've gotta wait for it to rotate underneath the heads. And then finally, I've got the head in the right place. I've got the data underneath me. I'm gonna start reading that data off and transmitting it back over the bus, right? So over time, so these are all potential sources of slowness, right? And we'll talk about the significance of each one of these, yeah, I don't know. Yeah, yeah, yeah, so this will occupy us for a while, right? At this point, we're assuming that, yeah, the operating system knows what disk the data is on. It knows that the location, something about, so there's this, there's a, you know, the disk and the operating system need to agree on some naming convention, right? Like, how do I tell the disk where things are? Usually, disks have blocks, right? And I tell the disk a block ID. So, right, there's this whole process of getting from a file name, right, which is what you guys think about, to the location on a specific disk. And we'll talk about that in great detail, yeah. That's coming. So over time, you know, what's happened is that interconnect speeds, right, have improved. You know, there's, you know, there's multiple versions of these different interfaces, and they seem to just, you know, every time a new one comes out, it just seems to double, right, the speed. It, which I can write, like, once the data has, the disk has data and wants to stream it back to the processor, these, or back, you know, onto the motherboard, these interconnect speeds seem to be going up pretty nicely, right? Seek times are what is always plagued disks, right? So the things that have not sped up, seek times are the biggest problem, right? Rotation speeds are also important, right? And rotation speeds haven't followed Moore's law. If they did, we'd have a disk that we're spinning at, like, you know, one megahertz, right? I mean, that would, that would be awesome. They could be dangerous, right? Like, if that disk wobbled a little bit, it would go flying out of the machine and like it would lodge itself in the wall or something. But yeah, so we have, you know, maybe if you have a high-end server drive again, we have 15,000 RPMs, right? Not a giga-RPM. But what it turns out is that rotation speeds actually don't matter as much as other parts of things, right? The seek times have always dominated, right? Moving the heads, right, is usually the biggest source of delay, right? Once you get the heads to where they are, you don't have to wait that long for the data to rotate under the heads, even with the drive that's not spinning that right. So this is what we kind of talked about before, right? So, you know, hard drive densities are increasing, capacities are getting bigger, users are being encouraged to save everything, right? Like, don't ever delete a file. I mean, I try not to do this on my own systems because I find that when I delete things, I always regret it, right? So I just say, I'm not gonna delete things anymore, right? That's just my new policy. I'll move them somewhere else so I don't have to look at them anymore because I'm an OCD person and I like to have things organized but I'm not gonna delete things anymore, right? As satisfying as it is. And a lot of people are encouraged to think this way and a lot of cloud storage and things like that are making this more and more prevalent, right? Never throw out a file. Who knows? Maybe you'll want that picture someday, you know? Unless it's incriminating or something, a picture of you doing something illegal, in which case I would encourage you to delete it. So, and seek times are really limiting the ability to, so this is a graph showing kind of the availability of different drives, right? And this is interesting. Going back to, like, 1984, right? In 1990, you know, I was starting to use computers. You had these, and these are internal, essentially kind of internal drives, right? And what you can see is that you've seen several orders of magnitude in increase in capacity, right? Capacity, not seek times, right? Seek times are not growing like this, but the capacity of drives is. And so this is what was causing this problem, right? You had these big, slow drives and the seek times often kept dropping. Seek times have been keeping up with capacity. I think the design assistance would be quite different, right? So, you know, somebody pointed out before, this low level disk interface that we haven't talked about, but we don't make you that much, is quite messy and very limited, right? It talks about, you know, reading and writing, essentially usually what disks allow you to do is to ask to read or write an entire 512 byte block, right? They don't work in bytes, they work in these blocks, right? Discs have no notions of these higher level file system abstractions you guys are used to thinking about. They don't, disks don't know about directories, they don't know about files, they don't know about append, they don't know about file types, they don't know about access patterns, so disks expose this very low level interface and what we're gonna talk about, you know, next week and the week after is how we build all of these nice abstractions and file system concepts and reliability and these nice principles on top of, on top of this slow level abstraction. And the last thing I'll point out today is that, again, a lot more of the file abstraction, so to some degree, when we talked about the CPU memory because of the speed of those devices, kernel interaction with them required a lot of hardware help, right? Like we talked kind of about hardware and software had been sort of evolved together so that hardware help the operating system sort of enforce policies, but to some degree some of the mechanisms we talked about were implemented in hardware, right? Here, more of that file system abstraction is implemented in software, right? And if you think about it, there's like even with a single machine, right? And particularly if you use open source or freely available systems, right? There's like you have a huge number of different choices about what file system to use, right? I mean, if you're running Linux you can probably sit down today and install five or six different file systems on your machine, right? And I think this is why a lot of systems people like file systems, right? It's because there's a huge amount of kind of hacking to do, right? Like you get to build real things they're not as constrained by the hardware you've got this low level interface, 512 byte blocks, read or write, you know? And then it's like, oh, wow, I get to build all these cool things on top of it. And that's a lot of fun, right? Let's see, I'll spend two minutes on flash, right? So, and just talk about sort of, you know what why flash might end up being harder than we think it is, right? So flash seems to have this nice feature which is that because parts don't move and data locality, so with spinning disk data locality ends up mattering a lot, right? Because depending on where I have to put the heads performance might be great or it might be terrible, right? On flash I get rid of that problem, right? But flash has this problem where I have to erase really big pieces of flash before I can rewrite the data, right? And it also wears out, right? It turns out flash wears out faster than magnetic drives, right? And what can happen if we're not careful about how we use it as a part of it might wear out more quickly, right? So that might be the patchy part of my flash that doesn't work anymore or other parts are still in good shape. And it turns out, yeah, this is complicated, right? So the simplicity that I get through flash of not having to worry about where things are as much and parts moving around is kind of to some degree at least counter balanced by the fact that these other features of flash make designing flash. File system test object of flash equally complex. All right, so next time we're gonna talk about how we build low level algorithms for issuing disk requests and scheduling disk requests and that's to some degree based on a disk geometry that we talked about and then we'll start talking about file system and how file systems work. So I will see you guys on Monday. Have a great weekend.