Advanced Database System CS 641 Lecture #2
The memory hierarchy Computer system contains different storage devices Data capacities vary over seven orders of magnitude Data access speeds ranging over seven or more orders of magnitude
Cost per byte also varies widely (three orders of magnitude)
Caches between the cache and processor A few nanoseconds (10 -9 )
Between the cache and main memory
Main memory Personal computer: 1GB – 4GB
High-performance system: more than 10GB
Virtual memory Programs use virtual memory address space. In general, it is bigger than the physical memory Most of its contents are in secondary storage Blocks (pages) are transferred between main memory and secondary storage main-memory database systems
Only useful when the data set is small.
Secondary storage Significantly slower and significantly larger Disks, cds, zip disk, etc. They are much cheaper than main memory Moving blocks between disk and main memory are disk I/Os. Access speed: 10 – 30 milliseconds (0.01 to 0.03 seconds) Disk capacity: more than 100GB. Buffer is used to reduce the affects of slow disk accesses.
To achieve better performance, DBMS have to manage buffers by itself.
Tertiary storage Tertiary storage devices are used to hold data volumes measured in terabytes.
Slower speed, larger capacity and cheaper price compare to disks.
Volatile and nonvolatile storage Volatile device: forgets what is stored in it when the power turns off. Nonvolatile devices: keep its contents for long period when the device is turned off or a power failure occurs. Volatile: caches, main memory (DRAM)
Nonvolatile: disks, CDs, floppy disks, SRAM, flash memory.
Moore’s Law Goldon Moore: Integrated circuit follows an exponential curve that doubles about every 18 months The speed of processors (after 2005, putting more processors on a single, fixed cost chip) The cost of main memory per bit and the number of bits that can be put on one chip The cost of disk per bit and the capacity of the largest disks Some others do not follow
Memory access speed, and disk access speed
Mechanics of disks Consists of one or more circular platters that rotate around a central spindle. Holds disk heads. For each surface there is one head.
Platter, surface, track, cylinder, sector (physical), block (logical), gap (10% of the total track)
A typical disk
Top view of a disk surface
Disk controller A small processor capable of: Controlling the mechanical actuator that moves the head assembly Selecting a surface from which to read or write, and selecting a sector from the track on that surface that is under the head Transferring the bits read from the desired sector to the computer’s main memory or the bits to be written from main memory to the intended sector.
Buffering an entire track or more in local memory of the disk controller
Schematic of a simple computer system
Disk storage characteristics Rotation speed of the disk assembly Number of platters per unit Number of tracks per surface
Number of bytes per track
Typical numbers Diameter: 1 inch 15 inches (Tracks/cyl) 2 (floppies) 1023
Capacity: 360 KB (old floppy)
Example: Megatron 747 65,536 tracks per surface
8*2*65536*256*4096=2 40 B=1TB
Density of bits Assume Megatron has surface in 1.75 inch radius, inner 0.75 inch is not used. Density of bits in the radius direction: 65,536/inch. Density of bits around the track is far greater. Outermost: 11inch, 420,000 bits/inch. Innermost: 4.2inch, 1megabits/inch.
To solve this problem, using non-uniform distribution of bits
Transfer data between main memory and disk To read and write blocks: The heads are positioned at the cylinder containing the track on which the block is located
The sectors containing the block move under the disk head as the entire disk assembly rotates.
Disk access time block x in memory ? I want block X Latency : the time taken between the moment at which the command to read a block is issued and the time that the contents of the block appear in main memory.
Disk latency The time taken by the processor and disk controller to process the request (a fraction of a millisecond) Seek time: position the head assembly at the proper cylinder (a few milliseconds per track, maximum: 10-40ms) Rotational latency: the first sector containing the requested block reaches the head (average: 5ms)
Transfer time: the sectors of the block and any gaps between them to rotate past the head. (time depends)
Calculation of disk latency
Example To read a 16,384-byte block from the Megatron 747 disk. 7200RPM, one rotation: 8.33 ms To move the heads between cylinders, 1ms to start and stop, and 1ms for every 4000 cylinders. Thus, the maximum seek time: 17.38ms (for 65,536 cylinders)
Calculate the min, max and avg latency to read a block. (0.13ms,25.84ms,10.76ms)
Writing blocks The process of writing a block has the same min, max and avg time as read process.
If we want to verify if the write is correct, more processing time is needed to read the block
Modifying blocks Read the block into main memory. Make changes in main memory Write the new contents back to the disk
Verify the contents if needed.