cs 4432lecture #31 cs4432: database systems ii lecture #3 using the disk, and disk optimizations...

14
CS 4432 lecture #3 1 CS4432: Database Systems II Lecture #3 Using the Disk, and Disk Optimizations Professor Elke A. Rundensteiner

Upload: richard-hutchinson

Post on 22-Dec-2015

214 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: CS 4432lecture #31 CS4432: Database Systems II Lecture #3 Using the Disk, and Disk Optimizations Professor Elke A. Rundensteiner

CS 4432 lecture #3 1

CS4432: Database Systems II

Lecture #3

Using the Disk, and Disk Optimizations

Professor Elke A. Rundensteiner

Page 2: CS 4432lecture #31 CS4432: Database Systems II Lecture #3 Using the Disk, and Disk Optimizations Professor Elke A. Rundensteiner

CS 4432 lecture #3 2

Thus far :

• Hardware: Disks• Architecture: Layers of Access• Access Times and Abstractions

Page 3: CS 4432lecture #31 CS4432: Database Systems II Lecture #3 Using the Disk, and Disk Optimizations Professor Elke A. Rundensteiner

CS 4432 lecture #3 3CS 245 Notes 2 3

Optimizations (in controller or O.S.)

• Disk Scheduling Algorithms– e.g., elevator algorithm

• Larger Buffer• Pre-fetch• Disk Arrays• Disk Cache

Page 4: CS 4432lecture #31 CS4432: Database Systems II Lecture #3 Using the Disk, and Disk Optimizations Professor Elke A. Rundensteiner

CS 4432 lecture #3 4

One Simple Idea : Prefetching

Problem: Have a File» Sequence of Blocks B1, B2

Have a Program» Process B1» Process B2» Process B3

...

Page 5: CS 4432lecture #31 CS4432: Database Systems II Lecture #3 Using the Disk, and Disk Optimizations Professor Elke A. Rundensteiner

CS 4432 lecture #3 5

Single Buffer Solution

(1) Read B1 Buffer(2) Process Data in Buffer(3) Read B2 Buffer(4) Process Data in Buffer ...

Page 6: CS 4432lecture #31 CS4432: Database Systems II Lecture #3 Using the Disk, and Disk Optimizations Professor Elke A. Rundensteiner

CS 4432 lecture #3 6

Say P = time to process/blockR = time to read in 1 blockn = # blocks

Single buffer time = n(P+R)

Page 7: CS 4432lecture #31 CS4432: Database Systems II Lecture #3 Using the Disk, and Disk Optimizations Professor Elke A. Rundensteiner

CS 4432 lecture #3 7

Question: Could the DBMS know something

about behavior of such future block accesses ?

What if: If we knew more about the

sequence of future block accesses, how could we do better ?

Page 8: CS 4432lecture #31 CS4432: Database Systems II Lecture #3 Using the Disk, and Disk Optimizations Professor Elke A. Rundensteiner

CS 4432 lecture #3 8

Idea : Double Buffering/Prefetching

Memory:

Disk: A B C D GE F

A B

done

process

AC

process

B

done

Page 9: CS 4432lecture #31 CS4432: Database Systems II Lecture #3 Using the Disk, and Disk Optimizations Professor Elke A. Rundensteiner

CS 4432 lecture #3 9

Say P R

What is processing time now?

P = Processing time/blockR = IO time/blockn = # blocks

• Double buffering time = ?

Page 10: CS 4432lecture #31 CS4432: Database Systems II Lecture #3 Using the Disk, and Disk Optimizations Professor Elke A. Rundensteiner

CS 4432 lecture #3 10

Say P R P = Processing time/blockR = IO time/blockn = # blocks

• Double buffering time = R + nP

• Single buffering time = n(R+P)

Page 11: CS 4432lecture #31 CS4432: Database Systems II Lecture #3 Using the Disk, and Disk Optimizations Professor Elke A. Rundensteiner

CS 4432 lecture #3 11Notes 2 11

Disk Arrays• RAIDs (various flavors)• Block Striping• Mirrored

logically one disk

Page 12: CS 4432lecture #31 CS4432: Database Systems II Lecture #3 Using the Disk, and Disk Optimizations Professor Elke A. Rundensteiner

CS 4432 lecture #3 12Notes 2 12

On Disk Cache

P

M C ......

cache

cache

Page 13: CS 4432lecture #31 CS4432: Database Systems II Lecture #3 Using the Disk, and Disk Optimizations Professor Elke A. Rundensteiner

CS 4432 lecture #3 13

Block Size Selection?

• Question : Do we want Small or Big Block Sizes ?

• Pros ?• Cons ?

Page 14: CS 4432lecture #31 CS4432: Database Systems II Lecture #3 Using the Disk, and Disk Optimizations Professor Elke A. Rundensteiner

CS 4432 lecture #3 14

Block Size Selection?• Big Block Amortize I/O Cost

– For seek and rotational delays are reduced …

• Big Block Read in more useless stuff!

and takes longer to read

Unfortunately...