hard disk drivesjannen/teaching/s20/cs333/... · hard disk drives (hdds) • high capacity, low...

16
Hard Disk Drives CS333 Spring 2020 Logistics Lab 1: Unix utilities, system calls, & C Due Thursday Anyone stuck? Questions about C/system calls? `man 2 read`

Upload: others

Post on 22-Sep-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Hard Disk Drivesjannen/teaching/s20/cs333/... · Hard Disk Drives (HDDs) • High capacity, low cost • Predictable performance • “Unwritten contract”: Tracks (LBAs) near each

Hard Disk DrivesCS333

Spring 2020

Logistics

• Lab 1: Unix utilities, system calls, & C

• Due Thursday

• Anyone stuck?

• Questions about C/system calls?

• `man 2 read`

Page 2: Hard Disk Drivesjannen/teaching/s20/cs333/... · Hard Disk Drives (HDDs) • High capacity, low cost • Predictable performance • “Unwritten contract”: Tracks (LBAs) near each

Last Class• I/O Devices

• Physical Interfaces

• Device Drivers vs. Firmware

• Polling vs. Interrupts

• Big Picture: Memory Hierarchy / Layers

This Class• HDD Guarantees

• Performance & correctness

• Physical components and Geometry

• Breaking down an I/O

• The role of caching

• Scheduling requests

Page 3: Hard Disk Drivesjannen/teaching/s20/cs333/... · Hard Disk Drives (HDDs) • High capacity, low cost • Predictable performance • “Unwritten contract”: Tracks (LBAs) near each

Hard Disk Drives (HDDs)

• High capacity, low cost

• Predictable performance

• “Unwritten contract”: Tracks (LBAs) near each other are more efficient to access than tracks (LBAs) that are far away

HDDs

Disk Head (seeks in/out)

Platters (rotate)

Page 4: Hard Disk Drivesjannen/teaching/s20/cs333/... · Hard Disk Drives (HDDs) • High capacity, low cost • Predictable performance • “Unwritten contract”: Tracks (LBAs) near each

HDDs

Disk Head (seeks in/out)

Platters (rotate)

Tracks (concentric circles)

HDDs

Disk Head (seeks in/out)

Platters (rotate)

Tracks (concentric circles)

Sector (unit of transfer)

Page 5: Hard Disk Drivesjannen/teaching/s20/cs333/... · Hard Disk Drives (HDDs) • High capacity, low cost • Predictable performance • “Unwritten contract”: Tracks (LBAs) near each

“Unwind” The Tracks

Seeking through the Linear Address Space

Page 6: Hard Disk Drivesjannen/teaching/s20/cs333/... · Hard Disk Drives (HDDs) • High capacity, low cost • Predictable performance • “Unwritten contract”: Tracks (LBAs) near each

HDDs

HDDs

• Disks are addressed by LBA: [0-MAXLBA)

• Transfer data in fixed-size units: “disk block”

• “block interface” used for both reads and writes

0 MAXLBA

Page 7: Hard Disk Drivesjannen/teaching/s20/cs333/... · Hard Disk Drives (HDDs) • High capacity, low cost • Predictable performance • “Unwritten contract”: Tracks (LBAs) near each

Breaking Down an I/O

0 MAXLBA

• Two costs to every operation:

• Setup: Moving the disk head, rotating the platters

• Transfer: Reading/writing while the disk rotates

Ex: data <- read(10024, 10048)

Performance Observations

• Setup (placing the disk head) is expensive O(10 ms)

• seeking to target track

• Up to a full rotational delay to locate sector

• Once the disk head is in place, data transfer is quite fast O(100 MiB/s)

Page 8: Hard Disk Drivesjannen/teaching/s20/cs333/... · Hard Disk Drives (HDDs) • High capacity, low cost • Predictable performance • “Unwritten contract”: Tracks (LBAs) near each

213

216

219

222

225

228

2�2

20

22

24

26

Read size (bytes)

Eff

ecti

ve

Band

wid

th(M

B/s

ec)

HDD

To maximize performance, minimize seeks and maximize the ratio of time spent transferring.

Why Does This Matter?

Page 9: Hard Disk Drivesjannen/teaching/s20/cs333/... · Hard Disk Drives (HDDs) • High capacity, low cost • Predictable performance • “Unwritten contract”: Tracks (LBAs) near each

HDD

File System

Application user space

OS kernel

Simplified Storage Stack

data = read(LBA),write(data,LBA)

Good Cases

Sequential I/O • Write a large file to an empty

file system.

• Read an existing file in order

0

40

80

120

*higher is better

MB/

s ext4raw disk

Sequential I/O

Page 10: Hard Disk Drivesjannen/teaching/s20/cs333/... · Hard Disk Drives (HDDs) • High capacity, low cost • Predictable performance • “Unwritten contract”: Tracks (LBAs) near each

Good Cases

• Write a large file to an empty file system.

Good Cases

• Read an existing file in order

Page 11: Hard Disk Drivesjannen/teaching/s20/cs333/... · Hard Disk Drives (HDDs) • High capacity, low cost • Predictable performance • “Unwritten contract”: Tracks (LBAs) near each

Bad Cases

Random I/O • Randomly update an existing

file

• Randomly reading an existing file

• Reading data from many independent files

0

40

80

120

*higher is better

MB/

s ext4raw disk

Random Overwrites

Bad Cases

• Randomly update an existing file

Page 12: Hard Disk Drivesjannen/teaching/s20/cs333/... · Hard Disk Drives (HDDs) • High capacity, low cost • Predictable performance • “Unwritten contract”: Tracks (LBAs) near each

Takeaway: Locality Matters

Disk Geometry

• High level idea gets us most of the way, but disk geometry adds complications (opportunities?)

• Multi-zoned disks

• Track Skew

Page 13: Hard Disk Drivesjannen/teaching/s20/cs333/... · Hard Disk Drives (HDDs) • High capacity, low cost • Predictable performance • “Unwritten contract”: Tracks (LBAs) near each

Takeaway: Sometimes it pays to “open the black box”. Abstractions are important, but

they hide important details.

Scheduling

• High Level Question: You are given a series of requests that must be completed (LBAs), what order do you perform the work?

• Obstacles?

• Who does the scheduling?

HDD

File System

Application

read(LBA),write(blk,LBA)

Page 14: Hard Disk Drivesjannen/teaching/s20/cs333/... · Hard Disk Drives (HDDs) • High capacity, low cost • Predictable performance • “Unwritten contract”: Tracks (LBAs) near each

Scheduling

• Greedy: Shortest job first

• Shortest-seek-time-first (SSTF)

• Nearest-block-first (NBF)

• Problems?

• Starvation: one (or more) requests never receive access to the resources they need to complete

Scheduling

• Elevator!

Page 15: Hard Disk Drivesjannen/teaching/s20/cs333/... · Hard Disk Drives (HDDs) • High capacity, low cost • Predictable performance • “Unwritten contract”: Tracks (LBAs) near each

Any Questions?

HDD Handout(15-20 minutes)

Page 16: Hard Disk Drivesjannen/teaching/s20/cs333/... · Hard Disk Drives (HDDs) • High capacity, low cost • Predictable performance • “Unwritten contract”: Tracks (LBAs) near each

Activity: HDD Modelinghttps://github.com/williams-cs/cs333-class