Sie sind auf Seite 1von 13

Memory and Disk Management

Ramakrishinan&Gehrke : Chap. 9.1,9.3


Ruemmler and Wilkes, IEEE Computer,
27(3):17-28, March 1994
Patterson, CACM 47(10):71-75, Oct. 2004

Database Systems Implementation, Bongki Moon 1

Disks and Files

 DBMS stores information on (“hard”) disks.


 This has major implications for DBMS design!
– READ: transfer data from disk to main memory (RAM).
– WRITE: transfer data from RAM to disk.
– Both are high-cost operations, relative to in-memory
operations, so must be planned carefully!

Database Systems Implementation, Bongki Moon 2

1
Why Not Store Everything in Main Memory?

 Costs too much.


– As of 2000, $200-400 will buy you either 128MB of RAM or 15GB of disk.
– As of 2007, approx. $50/GB of RAM, $1/GB of disk
 Main memory is volatile. We want data to be saved between runs.
(Obviously!)
 Typical storage hierarchy:
– Main memory (RAM) for currently used data.
– Disk for the main database (secondary storage).
– Tapes for archiving older versions of the data (tertiary storage).
 Recent research in Main-memory databases
– Cache-conscious index (T-tree, CSB-tree etc.)
– Hand-held devices: energy-efficient db algorithms

Database Systems Implementation, Bongki Moon 3

Disks

 Secondary storage device of choice.


 Main advantage over tapes: random access vs.
sequential.
 Data is stored and retrieved in units called disk
blocks or pages.
 Unlike RAM, time to retrieve a disk page varies
depending upon location on disk.
– Therefore, relative placement of pages on disk has
major impact on DBMS performance!

Database Systems Implementation, Bongki Moon 4

2
Components of a Disk Spindle
Tracks
Disk head

The platters spin (say, 90rps).


The arm assembly is moved Sector

in or out to position a head


on a desired track. Tracks
under heads make a
cylinder (imaginary!). Platters
Arm movement
Only one head
reads/writes at any
one time.
Arm assembly
 Block size is a multiple
of sector size (which is fixed).

Database Systems Implementation, Bongki Moon 5

Accessing a Disk Page

 Time to access (read/write) a disk block:


– seek time (moving arms to position disk head on track)
– rotational delay (waiting for block to rotate under head)
– transfer time (actually moving data to/from disk surface)
 Seek time and rotational delay dominate.
– Seek time varies from about 1 to 20msec
– Rotational delay varies from 0 to 10msec
– Transfer rate is about 1msec per 4KB page
 Key to lower I/O cost: reduce seek/rotation delays!
Hardware vs. software solutions?

Database Systems Implementation, Bongki Moon 6

3
Arranging Pages on Disk

 `Next’ block concept:


– blocks on same track, followed by
– blocks on same cylinder, followed by
– blocks on adjacent cylinder
 Blocks in a file should be arranged sequentially
on disk (by `next’), to minimize seek and
rotational delay.
 For a sequential scan, pre-fetching several pages
at a time is a big win!

Database Systems Implementation, Bongki Moon 7

Disk Space Management

 Lowest layer of DBMS software manages space on


disk.
 Higher levels call upon this layer to:
– allocate/de-allocate a page
– read/write a page
 Request for a sequence of pages must be satisfied
by allocating the pages sequentially on disk!
Higher levels don’t need to know how this is
done, or how free space is managed.

Database Systems Implementation, Bongki Moon 8

4
Summary

 Disks provide cheap, non-volatile storage.


– Random access, but cost depends on location of page
on disk; important to arrange data sequentially to
minimize seek and rotation delays.

Database Systems Implementation, Bongki Moon 9

Disk Drives

 Mechanism + Controller
 Mechanism: recording and positioning
– A single read-write data channel can be switched
between the heads on multiple platters.
– Seeking, Zoning, Track skewing, Sparing, etc.
 Controller: microprocessor, buffer memory,
interface to SCSI bus.
– Interpret SCSI requests, transfer data between the
disk drive and and its clients.
– Bus interface, Caching, etc.

Database Systems Implementation, Bongki Moon 10

5
Seeking

 A Seek is composed of
– speedup, coast, slowdown, and settle.
 Average seek time (published) is misleading.
– Very short seeks (less than 2-4 cyl.) dominated by
settle time (1-3 milliseconds).
– Short seeks (less than 200-400 cyl.) spend most time in
speedup phase, proportional to SQRT(seekDistance).
– Long seeks spend most time in coast phase,
proportional to seekDistance plus constant.

Database Systems Implementation, Bongki Moon 11

Data Layout
 Zoning for maximum storage capacity
– Adjacent cylinders grouped into (typically 3-20) zones.
– Outer zones have more sectors per track, higher data transfer rate
(same density, longer track).
 (E.g.) HP C2240 disk yields different access rates (3.1 – 5.3 MB/sec)
from different zones.
 Track skewing for faster access across track and cylinder
boundaries.
– Skew amount is determined by seek time and RPM.
– Each zone may have its own track skew factor.
 Mapping from a linear vector of logical blocks to physical
sectors on disk
– Vertical mapping vs. horizontal mapping

Database Systems Implementation, Bongki Moon 12

6
Bus Interface

 SCSI bus spec. more than 20 MB/s transfer rate.


– Ultra-2 SCSI : 40MB/sec (8-bit data bus), 80MB/sec (16-bit)
– Ultra-1 SCSI : 20MB/sec (8-bit data bus), 40MB/sec (16-bit)
– Fast SCSI-2 : 5-10MB/sec (8-bit), 10-20MB/sec (16-bit)
 Max transfer rate from/to disk is about 10 MB/s.
 More than a disk can be attached to a SCSI bus.
– Delay due to bus contention can occur.
 Fence: the amount of data read into the buffer before the
transfer is initiated (because bus rate is higher than disk
rate).

Database Systems Implementation, Bongki Moon 13

EIDE vs. SCSI

 EIDE (Enhanced Integrated Drive Electronics)


– Has a primary and a secondary channel connecting to two devices
each, for a total of four.
– On each channel, two devices take turns controlling the bus.
 So, it’s a bad idea to connect a disk and a CD-ROM to the same
channel.
 SCSI
– Can connect up to 7 devices (or 15 devices for Wide 16-bit SCSI) to
a channel.
– You will benefit more from SCSI than EIDE if you do:
 Multitasking, frequent simultaneous accesses, large multimedia files.

Database Systems Implementation, Bongki Moon 14

7
Caching for Speed-matching

 Disk caches (aka. track buffer) are small (~1 MB).


– Expensive dual-ported SRAM, space limitations.
 Read-ahead cache
– On-arrival read-ahead: A full track is cached.
– Cache segmentation for interleaved read streams.
 To improve the effectiveness of Read-ahead for random accesses
 Write-behind (or immediate reporting)
– Write only to buffer without actual write to disk
 Command queueing
– Multiple outstanding requests at a time.
– Disk controller determines the best execution order.
 (E.g.) SCAN, C-SCAN, Elevator algorithms

Database Systems Implementation, Bongki Moon 15

Modeling Disk Drives


 Event-driven simulation with Trace data
 Trivial model: modeled as fixed costs

Database Systems Implementation, Bongki Moon 16

8
Modeling Disk Drives

 Linear seek time,


proportional to seek
distance
 Rotational delay,
randomly chosen in
[0,max)
 Linear transfer time,
proportional to IO size

Database Systems Implementation, Bongki Moon 17

Modeling Disk Drives

 Modeling head-
positioning effects for
HP C2200A
 Non-linear seek time
– Seek-time(d) = 3.45 +
0.597*d1/2 if d < 616
– Seek-time(d) = 10.8 +
0.012*d if d ≥ 616

Database Systems Implementation, Bongki Moon 18

9
Modeling Disk Drives

 Explicit calculation of rotational delay

Database Systems Implementation, Bongki Moon 19

Modeling Disk Drives

 Modeling data caching for HP 97560 disk


– Read-ahead, write-behind

No cache Cache
Database Systems Implementation, Bongki Moon 20

10
Modeling Disk Drives

 Caching > Data transfer > Seek time > Rotational


– 112% demerit if caching is ignored.

Database Systems Implementation, Bongki Moon 21

Bandwidth vs. Latency

 Survey of ~20 year trend (1980 – 2000)


 Trend in disk technology advances
– Capacity improved most.
– Bandwidth advanced far greater than latency.
 Rule of thumb
– In the time that bandwidth doubles, latency improves
by no more than a factor of 1.2 to 1.4.
– Or, bandwidth improves by at least the square of the
improvement in latency.

Database Systems Implementation, Bongki Moon 22

11
Performance Trend of Disk
 From 1983 to 2003
– Capacity increased about 2500 times (73.4/0.03).
– Bandwidth improved 143.3 times (86/0.6).
– Latency improved 8.5 times (48.3/5.7).

Database Systems Implementation, Bongki Moon 23

Why Latency Lags?

 Moore’s law (semiconductor scaling) does not help


latency.
 The speed of light sets the lower-bound of latency.
 Latency helps bandwidth, not vice versa.
– Increasing the spinning speed of disk improves both rotational
latency and bandwidth.
– Increasing magnetic bit density helps bandwidth but not
latency.
 Operating system overhead hurts latency.

Database Systems Implementation, Bongki Moon 24

12
So What?

 The trouble is
– Latency remains important for interactive applications
(e.g., ad-hoc query response time).
– The bandwidth-latency imbalance may be even more
evident in the future.
 Some suggestions for hiding latency
– Usual stuff: caching and prefetching
– Use LFS instead of traditional file systems.
 LFS tied up to bandwidth, while update-in-place to latency
– Use large block sizes.

Database Systems Implementation, Bongki Moon 25

Good Enough to Hide Latency?

 Can’t someone invent a disk without any


moving part?
 If that happens,
– It will be purely an electronic device.
– It will enjoy near-zero latency.
 NAND flash memory
– GB of NAND flash costs less than 1/3 of GB of
DRAM; the gap is expected to get wider.
– Still much more expensive than magnetic disk.

Database Systems Implementation, Bongki Moon 26

13

Das könnte Ihnen auch gefallen