Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS4432: Database Systems II Data Storage (Better Block Organization) 1.

Similar presentations


Presentation on theme: "CS4432: Database Systems II Data Storage (Better Block Organization) 1."— Presentation transcript:

1 CS4432: Database Systems II Data Storage (Better Block Organization) 1

2 Big Question: What about access time? block x in memory ? I want block X Time = Disk Controller Processing Time + Disk Delay{seek & rotation} + Transfer Time 2

3 Access time, Graphically P MDC... Disk Controller Processing Time Disk Delay Transfer Time 3

4 Disk Controller Processing Time Time = Disk Controller Processing Time + Disk Delay + Transfer Time CPU Request  Disk Controller – Nanoseconds (10 -9 ) Disk Controller Contention – Microseconds (10 -6 ) Bus – Microseconds (10 -6 ) ≈ Microseconds Negligible for our purposes. ≈ Microseconds Negligible for our purposes. 4

5 Transfer Time Time = Disk Controller Processing Time + Disk Delay + Transfer Time Typically 10MB/sec Reading 4K data block takes ~ 0.5 ms Order of 1 millisecond (or less) 5

6 Disk Delay Time = Disk Controller Processing Time + Disk Delay + Transfer Time More complicated Disk Delay = Seek Time + Rotational Latency 6

7 Seek Time Seek time is most critical time in Disk Delay. Average Seek Times: – Maxtor 40GB (IDE) ~10ms – Western Digital (IDE) 20GB ~9ms – Seagate (SCSI) 70 GB ~3.6ms – Maxtor 60GB (SATA) ~9ms Order of 10 milliseconds 7

8 Rotational Latency Head Here Block I Want 8

9 Average Rotational Latency Average latency is about half of the time it takes to make one revolution. 3600 RPM = 8.33 ms 5400 RPM = 5.55 ms 7200 RPM = 4.16 ms 10,000 RPM = 3.0 ms (newer drives) Order of few milliseconds 9

10 Accessing a Disk Block: Summary Time to access (read/write) a disk block: – seek time ( moving arms to position disk head on track ) – rotational latency ( waiting for block to rotate under head ) – transfer time ( actually moving data to/from disk surface ) Seek time and rotational latency dominate. – Seek time varies from about 1 to 20msec – Rotational delay varies from 0 to 10msec – Transfer rate is about 0.5msec per 4KB page Key to lower I/O cost: reduce seek/rotation latency! 10

11 Example Disk Latency Problem Calculate the Minimum, Maximum and Average disk latencies for reading a 4096-byte block on the same hard drive as before: 4 platters 8192 tracks 256 sectors/track 512 bytes/sector Disk rotates at 3840 RPM Seek time: 1 ms (warm-up), + 1ms for every 500 cylinders traveled. Gaps consume 10% of each track Reading one sector 0.06 ms A 4096-byte block is 8 sectors The disk makes one revolution in 1/64 of a second 1 rotation takes: 15.6 ms Moving one track takes 1.002ms. Moving across all tracks takes 17.4ms 11

12 Best Case: Minimum Latency Assume best case: – head is already on block we want! In that case, it is just read time of 8 sectors of 4096-byte block. We will pass over 8 sectors and 7 gaps. That is only the “Transfer Time” ≈ 0.06 ms x 8 = 0.5 ms 12

13 Worst Case: Maximum Latency Now assume worst case: – The disk head is over innermost cylinder and the block we want is on outermost cylinder, – block we want has just passed under the head, so we have to wait a full rotation. Time = Time to move from innermost track to outermost track + Time for one full rotation + Time to read 8 sectors = 17.4 ms (seek time) + 15.6 ms (one rotation) + 0.5ms (transfer time) = 33.5 ms!! 13

14 Average Case: Average Latency Now assume average case: – It will take an average amount of time to seek, and – block we want is ½ of a revolution away from heads. Time =Time to move over tracks + Time for one-half of a rotation + Time to read 8 sectors = 9.2ms (approximation) + 7.8ms (half rotation) + 0.5 ms (from min latency ) = 17.5 ms 14

15 Writing Blocks Same as reading blocks … 15

16 After seeing all of this … Which will be faster Sequential I/O or Random I/O? Sequential I/O – Reading blocks next to each other on the same track Sequential I/O saves seek & rotation latency times Next Question: How to organize the data to avoid/reduce Random I/Os ? 16

17 Accelerating Access to Blocks 17

18 Accelerating Access to Blocks 1.Placing Related Blocks on Cylinders 2.Using Multiple Disks 3.Mirroring 4.Disk Scheduling 5.Prefetching & Buffering 18 Performed by Disk Controller

19 1- Placing Related Blocks on Cylinders If blocks B1, B2, B3, and B4 will be read together But them on the same cylinder to read them at once. Keep additional related blocks on the next sectors on the same track 19 B4 B3 B2 B1

20 2- Using Multiple Disks: Striping Use multiple smaller disks instead of one large disk Each disk can access its data independently – N disks  N times faster access 20 B4 B3B2B1 B5B6 Disk 1Disk 2Disk 3

21 3- Mirroring Use pairs of disks that are mirrors t each other Good for failure & Good for faster access Higher overhead under writing operations 21

22 4- Disk Scheduling Disk Controller may have a sequence of block requests Not necessary serve requests in their arrival order (FIFO)  Use better scheduling policy Elevator & SCAN policies 22

23 4- Disk Scheduling: SCAN When starting a sweep (inward or outward) – Complete the sweep until the end – skip any newly arrived requests after the start 23

24 5- Prefetching & Buffering If DBMS can predict the sequence of access – It can pre-fetch and buffer more blocks even before requesting them. Example: Have a File » Sequence of Blocks B1, B2, … Have a Program » Process B1 » Process B2 » Process B3 … 24

25 25 Naïve Single Buffer Solution (1) Read B1  Buffer (2) Process Data in Buffer (3) Read B2  Buffer (4) Process Data in Buffer...

26 Cost of Naïve Solution 26 SayP = time to process/block R = time to read in 1 block n = # blocks Single buffer time = n(P+R)

27 27 Double Buffering Memory: Disk: ABCDGEF process

28 28 Double Buffering Memory: Disk: ABCDGEF B done process A

29 29 Double Buffering Memory: Disk: ABCDGEF A C process B done

30 Cost of Double Buffering In Double Buffering – R does not involve seek or latency times (except for the first block) 30 What is processing time? P = Processing time/block R = IO time/block n = # blocks

31 Cost of Double Buffering 31 P = Processing time/block R = IO time/block n = # blocks Double Buffering time = R + nP Single Buffering time = n(R+P)

32 Accelerating Access to Blocks: Covered 1.Placing Related Blocks on Cylinders 2.Using Multiple Disks 3.Mirroring 4.Disk Scheduling 5.Prefetching & Buffering 32

33 CS4432: Database Systems II Verification & Disk Failure 33

34 Intermittent Failures If we try to read the sector but the correct content of that sector is not delivered to the disk controller Check for the good or bad sector To check write is correct: Read is performed Good sector and bad sector is known by the Disk Controller 34

35 Checksums Each sector has some additional bits, called the checksums (or parity bits) Checksums are set depending on the values of the data bits stored in that sector Probability of reading bad sector is less if we use checksums Checksum 35

36 Checksums For Odd parity: Odd number of 1’s – Add a parity bit 1 For Even parity: Even number of 1’s – add a parity bit 0 So, number of 1’s becomes always even Sequence : 01101000-> odd no of 1’s parity bit: 1 -> 011010001 Sequence : 11101110->even no of 1’s parity bit: 0 -> 111011100 What is the probability of not detecting a failure? 36

37 Assume we use N parity bits Probability of not detecting a failure is – 1/ 2 N – E.g., for one byte  1/2 8 = 1/256 37 Checksums

38 Permanent Failure E.g., Disk damage Use or redundant disks and mirroring 38


Download ppt "CS4432: Database Systems II Data Storage (Better Block Organization) 1."

Similar presentations


Ads by Google