chapter 111 chapter 11: hardware (slides by hector garcia-molina, hector/cs245/notes.htm)
TRANSCRIPT
Chapter 11 1
Chapter 11: Hardware
(Slides by Hector Garcia-Molina,http://www-db.stanford.edu/~hector/cs245/
notes.htm)
Chapter 11 2
Outline• Hardware: Disks• Access Times• Optimizations• Other Topics:
– Storage costs– Using secondary storage– Disk failures
Chapter 11 3
The Big Picture:
DBMS
Data Storage
Chapter 11 4
P
M
TypicalComputer
SecondaryStorage
...
Chapter 11 5
ProcessorFast, slow, reduced instruction set,
with cache, pipelined…Speed: 100 500 1000 MIPS
MemoryFast, slow, non-volatile, read-only,…Access time: 10-6 10-9 sec.
1 s 1 ns
Chapter 11 6
Secondary storageMany flavors:
- Disk: Floppy (hard, soft)Removable PacksWinchesterRam disksOptical, CD-ROM…Arrays
- Tape Reel, cartridgeRobots
Chapter 11 7
Focus on: “Typical Disk”
Terms: Platter, Head, Cylinder, TrackSector (physical),Block (logical), Gap
…
Chapter 11 8
Top View
Chapter 11 9
“Typical” NumbersDiameter: 1 inch 15 inchesCylinders: 100 2000Surfaces: 1 (CDs) (Tracks/cyl) 2 (floppies) 30Sector Size:512B 50KCapacity: 360 KB (old floppy)
30 GB (I use)
Chapter 11 10
Disk Access Time
block xin memory
?
I wantblock X
Chapter 11 11
Time = Seek Time +Rotational Delay +Transfer Time +Other
Chapter 11 12
Rotational Delay
Head Here
Block I Want
Chapter 11 13
Average Rotational Delay
R = 1/2 revolution
“typical” R = 8.33 ms (3600 RPM)
Chapter 11 14
Transfer Rate: t
• “typical” t: 1 3 MB/second• transfer time: block size
t
Chapter 11 15
Other Delays
• CPU time to issue I/O• Contention for controller• Contention for bus, memory
“Typical” Value: 0
Chapter 11 16
• So far: Random Block Access• What about: Reading “Next” block?
Chapter 11 17
If we do things right (e.g., Double Buffer, Stagger Blocks…)
Time to get = Block Size + Negligible
block t
- skip gap
- switch track- once in a while, next cylinder
Chapter 11 18
Rule of Random I/O: ExpensiveThumb Sequential I/O: Much less• Ex: 1 KB Block
»Random I/O: 20 ms.»Sequential I/O: 1 ms.
Chapter 11 19
Cost for Writing similar to Reading
…. unless we want to verify! need to add (full) rotation + Block size
t
Chapter 11 20
• To Modify a Block?
To Modify Block:(a) Read Block(b) Modify in Memory(c) Write Block[(d) Verify?]
Chapter 11 21
Block Address:
• Physical Device• Cylinder #• Surface #• Sector
Chapter 11 22
Outline• Hardware: Disks• Access Times• Optimizations• Other Topics
– Storage Costs– Using Secondary Storage– Disk Failures
here
Chapter 11 23
Optimizations (in controller or O.S.)
• Double Buffering• Disk Scheduling Algorithms: sec.
11.5.4– e.g., elevator algorithm
Chapter 11 24
Double Buffering
Problem: Have a File» Sequence of Blocks B1, B2
Have a Program» Process B1» Process B2» Process B3
...
Chapter 11 25
Single Buffer Solution
(1) Read B1 Buffer(2) Process Data in Buffer(3) Read B2 Buffer(4) Process Data in Buffer ...
Chapter 11 26
Say P = time to process/blockR = time to read in 1 blockn = # blocks
Single buffer time = n(P+R)
Chapter 11 27
Double Buffering
Memory:
Disk: A B C D GE F
A B
done
process
AC
process
B
done
Chapter 11 28
Say P R
What is processing time?
P = Processing time/blockR = IO time/blockn = # blocks
• Double buffering time = R + nP
• Single buffering time = n(R+P)
Chapter 11 29
Block Size Selection?
• Big Block Amortize I/O Cost
• Big Block Read in more useless stuff! and takes longer to read
Unfortunately...
Chapter 11 30
Trend
• As memory prices drop, blocks get bigger ...
Trend
Chapter 11 31
Storage Cost
10-9 10-6 10-3 10-0 103
access time (sec)
1015
1013
1011
109
107
105
103
cache
electronicmain
electronicsecondary
magneticopticaldisks
tape
opticaldisks
tape
typi
cal c
apac
ity
(byt
es)
from Gray & Reuter
Chapter 11 32
Storage Cost
10-9 10-6 10-3 10-0 103
access time (sec)
104
102
100
10-2
10-4
cache
electronicmain
electronicsecondary magnetic
opticaldisks
tape
opticaldisks
tape
doll
ars/
MB
from Gray & Reuter
Chapter 11 33
Using secondary storage effectively
• Example: Sorting data on disk• Conclusion:
– I/O costs dominate– Design algorithms to reduce I/O
• Also: How big should blocks be?
Chapter 11 34
Disk Failures (Sec 11.6)
• Partial Total• Intermittent Permanent
Chapter 11 35
Coping with Disk Failures
• Detection– e.g. Checksum
• Correction Redundancy
Chapter 11 36
At what level do we cope?
• Single Disk– e.g., Error Correcting Codes
• Disk Array
Logical Physical
Chapter 11 37
Operating System e.g., Stable Storage
Logical Block Copy A Copy B
Chapter 11 38
Database System
• e.g.,
LogCurrent DB Last week’s DB
Chapter 11 39
Summary
• Secondary storage, mainly disks• I/O times• I/Os should be avoided,
especially random ones…..
Summary
Chapter 11 40
Outline• Hardware: Disks• Access Times• Optimizations• Other Topics
– Storage Costs– Using Secondary Storage– Disk Failures
here