Published on

  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide


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