ECE 5730 Memory Systems Spring 2009 Command Scheduling Disk Caching Lecture 23: 1
Announcements Quiz 12 I ll give credit for #4 if you answered (d) Quiz 13 (last one!) on Tuesday Make-up class #2 Thursday, April 30, 6:00-7:15pm, PH 403 Pizza and soda Exam II May 7, 7:00-10:00pm, Hollister 314 Covers material from 3/10-4/28 but excluding 4/22 (Lectures 14-21, 23-24) Lecture 23: 2
Course Project Last status report due tomorrow by 5pm EDT Final report (15-25 double-spaced pages) Email Word or PDF to me by 11:59pm on May 1 20 points off final project grade if late Lecture 23: 3
Final Report Organization Introduction and motivation What is the problem you are addressing? Why is it important? Proposed solution How are you proposing to solve the problem? Simulation methodology What tools are you using to evaluate your solution, and what assumptions are you making? Results How well does the solution work? What performance and/or power benefits do you get? Conclusions and future work Briefly summarize your work and suggest ways to extend it Lecture 23: 4
Command Queuing and Scheduling Historically, I/O cmds were processed serially Host waits for cmd to complete, then issues next one ATA drives operate this way Newer drives queue and schedule cmds Host sends series of cmds, each with a tag ID Drive determines best order to process the cmds Order is continually evaluated as cmds issue and arrive Drive sends tag ID back to host when cmd completes Lecture 23: 5
Cmd Queue Depth Specified by the interface standard 32 for SATA, 256 for SCSI As with processor issue queues, performance drops off beyond a certain queue depth Diminishing theoretical performance improvement as queue size increases Higher latency to evaluate a deeper queue Lecture 23: 6
Scheduling Policies First-come-first-served Seek-time-based scheduling Total-access-time-based scheduling Sequential access scheduling Lecture 23: 7
Seek-Time-Based Scheduling Policies Seeks to reduce the seek time by reducing the seek distance Shortest-Seek-Time-First (SSTF) Greedily selects the cmd with the shortest seek distance from the current position Tends to favor addresses near the middle of the disk ID and OD requests prone to starvation Can be implemented with an aging mechanism that raises the priority of older cmds Lecture 23: 8
Seek-Time-Based Scheduling Policies LOOK Start at OD, do SSTF in radial direction (OD ID) When radially innermost cmd completed, switch direction (ID OD) Queued cmds complete in < 1 sweep Favors addresses near middle (visited twice/sweep) Circular-LOOK (C-LOOK) Moves in only one radial direction More fair, but incurs a long seek after a sweep Lecture 23: 9
Shortest-Access-Time-First Scheduling Seek-time scheduling ignores rotational delay sweep direction current position seek-time scheduling [21.5] Lecture 23: 10
Shortest-Access-Time-First Scheduling Scheduling based on seek + rotational delays current position SATF scheduling [21.5] Lecture 23: 11
SATF Scheduling Incoming cmd LBA translated to CHS address Cylinder = radial position (r) Sector = angular position ( ) Cmd total access time estimated based on CHS and estimated ending position of current cmd Cmd with smallest total access time is issued Lecture 23: 12
Estimating Access Time Seek distance calculated as r new - r current beginning radial position of new cmd ending radial position of current cmd Seek table of seek time, seek distance pairs few table entries many table entries use linear interpolation for in-between points add a fixed settle time [19.6] Lecture 23: 13
Estimating Access Time Rotation time calculated from difference in angular positions before the seek Seek and rotation occur in parallel! If t seek < t rotation t access = t rotation Else t access = t rotation + n t revolution where n satisfies t seek < t rotation + n t revolution time for a complete disk revolution Lecture 23: 14
Simplified Sorting Using an RPO Table Time to compute and sort all cmds may exceed current cmd completion time Simplification Divide angular positions into N groups Each cmd placed into appropriate group based on difference in angular position from current cmd Example: 1000, sectors/track, N=10 Group 1: 0 angular difference for sectors 1-100 Group 2: 36 angular difference for sectors 101-200 (Slightly different than book to ease explanation) Lecture 23: 15
Simplified Sorting Using an RPO Table Rotational Position Optimization (RPO) table lists for each angular difference group Max seek distance given the rotational latency corresponding to the angular difference Max seek distance given the rotational latency corresponding to the angular difference plus 1 full revolution Max seek distance given the rotational latency corresponding to the angular difference plus 2 full revolutions continues up to the max seek distance Lecture 23: 16
RPO Table Example d seekrl d seekrl+1rev d seekrl+2rev 0 36 72 108 144 180 216 252 288 324 [18.7,21.6] Lecture 23: 17
Algorithm (for this RPO Table) Starting with 72 and moving down, find a non-empty group 0 36 d seekrl d seekrl+1rev d seekrl+2rev If cmd in that group has d seek < d seekrl, issue that cmd 72 108 144 Else, move to next non-empty group Then move to 0, col 2 and work downward Then move to 0, col 3 and work downward 180 216 252 288 324 [21.6] Lecture 23: 18
Sequential Access Scheduling Independent of the scheduling policy, schedule all sequential, near sequential, and skip sequential cmds back-to-back Immediately schedule newly arriving cmd that is sequential to the current cmd Handling skip sequential cmds Reads: Not requested data is simply discarded Writes: Skip mask tells the write electronics which sectors not to overwrite Lecture 23: 19
Performance Comparison 5.75ms avg seek, 1000 SPT at OD, 10K rpm Random reads of 1KB [21.7] Lecture 23: 20
Disk Drive Cache Disk drives have a built-in cache in addition to read and write buffers implemented in DRAM Typical cache size ranges from 512KB-64MB Typically only 0.01% of the drive The disk cache has a logical organization and management policies Lecture 23: 21
Why a Disk Drive Cache? A read disk cache hit avoids seek, rotation, and media transfer times Example: 0.15ms for 4K cache hit, 100MB/s interface Read access time = 0.15 + 0.04 = 0.19ms Compared to 4.885-7.885ms Read data can be prefetched from the disk Cached write data can be Served to subsequent reads Overwritten by later writes to same LBA Prioritized lower than reads in accessing disk Lecture 23: 22
Fixed Segmentation Disk Cache Most common disk cache architecture Cache space divided into fixed-size segments Number of segments may be fixed or set by the host (e.g., SCSI) Segment table holds LBA + dirty bit for each segment Fully associative lookup and LRU replacement Internal fragmentation for small blocks [22.2] Lecture 23: 23
Circular Buffer Variable size segments organized as a ring Segment size matches request Need to search for a contiguous group of data to fit the requested segment Segment table contains LBA, dirty bit, starting cache address, and segment length [22.3] Lecture 23: 24
Virtual Memory Disk Cache Organization Cache partitioned into N pages of 2 M disk sectors each Smaller M allows better space efficiency but higher management overhead Example: M=5, sector size is 512B 16KB pages LBA Partitioning sector number Physically non-contiguous cache pages can be chained to form a logically contiguous segment Eases finding space for a new segment [22.4] Lecture 23: 25
Page Table Page table maps LBAs to physical pages Each entry corresponds to a page and contains Tag of LBAs associated with this page Valid and dirty bits for the 2 M sectors of the page Hash chain pointer to chain all the allocation groups that shared this hash number Lecture 23: 26
Cache Lookup [22.5] Lecture 23: 27
Page Allocation/Deallocation Pages arranged in replacement list, e.g., LRU Dirty flag marks write pages To allocate X pages for a new segment, deallocate first X clean pages on the list Deallocate LRU dirty pages if necessary Lecture 23: 28
Cache Prefetching Data can be prefetched from the drive and placed into the cache for subsequent cmds Prefetching is not initiated unless the cmd queue is empty Prefetching may be pre-empted by a newly arriving cmd (unless it s a cache hit) Prefetched data with errors may be discarded Lecture 23: 29
Lookahead Prefetching Read B additional sequential LBAs beyond the requested read access No seek or RL overhead, but requires cache space Implemented in all disk drives Lecture 23: 30
Look-behind Prefetching Read data before the requested read access Only read the amount permitted by the rotational latency, up to a maximum limit [22.6] Lecture 23: 31
Zero Latency Prefetch Reduces rotational overhead when head lands in lookahead area normal prefetch zero latency prefetch Lecture 23: 32
Sequential Data and Prefetching Controller may modify it policies if it recognizes a sequential stream of read cmds, e.g., If a newly arriving request is to the LBA currently being prefetched, immediately prefetch more data Do not pre-empt current prefetch due to new cmd, but instead prefetch some minimum amount of data Amount may be adaptively determined by the controller Quickly reallocate the cache space of the sequential stream rather than displace other data Lecture 23: 33
Next Time Disk Power Management RAID Lecture 23: 34