SlideShare ist ein Scribd-Unternehmen logo
1 von 55
CS162
Operating Systems and
Systems Programming
Lecture 19
Filesystems 1: Performance (Con’t),
Queueing Theory, Filesystem Design
April 5th, 2022
Prof. Anthony Joseph and John Kubiatowicz
http://cs162.eecs.Berkeley.edu
Lec 19.2
4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022
Recall: Magnetic Disks
• Cylinders: all the tracks under the
head at a given point on all surfaces
• Read/write data is a three-stage process:
– Seek time: position the head/arm over the proper track
– Rotational latency: wait for desired sector to rotate under r/w head
– Transfer time: transfer a block of bits (sector) under r/w head
Sector
Track
Cylinder
Head
Platter
Software
Queue
(Device Driver)
Hardware
Controller Media Time
(Seek+Rot+Xfer)
Request
Result
Disk Latency = Queueing Time + Controller time +
Seek Time + Rotation Time + Xfer Time
Lec 19.3
4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022
Recall: Typical Numbers for Magnetic Disk
Parameter Info/Range
Space/Density Space: 18TB (Seagate), 9 platters, in 3½ inch form factor!
Areal Density: ≥ 1 Terabit/square inch! (PMR, Helium, …)
Average Seek Time Typically 4-6 milliseconds
Average Rotational Latency Most laptop/desktop disks rotate at 3600-7200 RPM
(16-8 ms/rotation). Server disks up to 15,000 RPM.
Average latency is halfway around disk so 4-8 milliseconds
Controller Time Depends on controller hardware
Transfer Time Typically 50 to 250 MB/s. Depends on:
• Transfer size (usually a sector): 512B – 1KB per sector
• Rotation speed: 3600 RPM to 15000 RPM
• Recording density: bits per inch on a track
• Diameter: ranges from 1 in to 5.25 in
Cost Used to drop by a factor of two every 1.5 years (or faster), now slowing down
Lec 19.4
4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022
Recall: FLASH Memory
• Like a normal transistor but:
– Has a floating gate that can hold charge
– To write: raise or lower wordline high enough to cause charges to tunnel
– To read: turn on wordline as if normal transistor
» presence of charge changes threshold and thus measured current
• Two varieties:
– NAND: denser, must be read and written in blocks
– NOR: much less dense, fast to read and write
• V-NAND: 3D stacking (Samsung claims 1TB possible in 1 chip)
Samsung 2015:
512GB, NAND Flash
Lec 19.5
4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022
Recall: SSD Summary
• Pros (vs. hard disk drives):
– Low latency, high throughput (eliminate seek/rotational delay)
– No moving parts:
» Very light weight, low power, silent, very shock insensitive
– Read at memory speeds (limited by controller and I/O bus)
• Cons
– Small storage (0.1-0.5x disk), expensive (3-20x disk)
» Hybrid alternative: combine small SSD with large HDD
Lec 19.6
4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022
Recall: SSD Summary
• Pros (vs. hard disk drives):
– Low latency, high throughput (eliminate seek/rotational delay)
– No moving parts:
» Very light weight, low power, silent, very shock insensitive
– Read at memory speeds (limited by controller and I/O bus)
• Cons
– Small storage (0.1-0.5x disk), expensive (3-20x disk)
» Hybrid alternative: combine small SSD with large HDD
– Asymmetric block write performance: read pg/erase/write pg
» Controller garbage collection (GC) algorithms have major effect on performance
– Limited drive lifetime
» 1-10K writes/page for MLC NAND
» Avg failure rate is 6 years, life expectancy is 9–11 years
• These are changing rapidly!
No
longer
true!
Lec 19.7
4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022
Nano-Tube Memory (NANTERO)
• Yet another possibility: Nanotube memory
– NanoTubes between two electrodes, slight conductivity difference between ones
and zeros
– No wearout!
• Better than DRAM?
– Speed of DRAM, no wearout, non-volatile!
– Nantero promises 512Gb/dice for 8Tb/chip! (with 16 die stacking)
Lec 19.8
4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022
Ways of Measuring Performance: Times (s) and Rates (op/s)
• Latency – time to complete a task
– Measured in units of time (s, ms, us, …, hours, years)
• Response Time - time to initiate and operation and get its response
– Able to issue one that depends on the result
– Know that it is done (anti-dependence, resource usage)
• Throughput or Bandwidth – rate at which tasks are performed
– Measured in units of things per unit time (ops/s, GFLOP/s)
• Start up or “Overhead” – time to initiate an operation
• Most I/O operations are roughly linear in b bytes
– Latency(b) = Overhead + b/TransferCapacity
• Performance???
– Operation time (4 mins to run a mile…)
– Rate (mph, mpg, …)
Lec 19.9
4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022
Example: Overhead in Fast Network
• Consider a 1 Gb/s link (𝐵𝑤 = 125 MB/s)
with startup cost 𝑆 = 1 ms
• Latency: 𝐿 𝑥 = 𝑆 +
𝑥
𝐵𝑤
• Effective Bandwidth:
𝐸 𝑥 =
𝑥
𝑆 +
𝑥
𝐵𝑤
=
𝐵𝑤 ⋅ 𝑥
𝐵𝑤 ⋅ 𝑆 + 𝑥
=
𝐵𝑤
𝐵𝑤 ⋅ 𝑆
𝑥
+ 1
• Half-power Bandwidth: 𝐸 𝑥 =
𝐵𝑥
2
• For this example, half-power bandwidth
occurs at x = 125 KB
Length (x)
Lec 19.10
4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022
Example: 10 ms Startup Cost (e.g., Disk)
• Half-power bandwidth at x = 1.25 MB
• Large startup cost can degrade
effective bandwidth
• Amortize it by performing I/O in larger
blocks
0
5
10
15
20
25
30
35
40
45
50
0
2,000
4,000
6,000
8,000
10,000
12,000
14,000
16,000
18,000
0 50,000 100,000 150,000 200,000 250,000 300,000 350,000 400,000 450,000 500,000
Bandwidth
(mB/s)
Latency
(us)
Length (b)
Performance of gbps link with 10 ms startup
Half-power x = 1,250,000 bytes!
Length (x)
Lec 19.11
4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022
What Determines Peak BW for I/O?
• Bus Speed
– PCI-X: 1064 MB/s = 133 MHz x 64 bit (per lane)
– ULTRA WIDE SCSI: 40 MB/s
– Serial Attached SCSI & Serial ATA & IEEE 1394 (firewire): 1.6 Gb/s full duplex
(200 MB/s)
– USB 3.0 – 5 Gb/s
– Thunderbolt 3 – 40 Gb/s
• Device Transfer Bandwidth
– Rotational speed of disk
– Write / Read rate of NAND flash
– Signaling rate of network link
• Whatever is the bottleneck in the path…
Lec 19.12
4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022
Sequential Server Performance
• Single sequential “server” that can deliver a task in time 𝐿 operates at
rate ≤
1
𝐿
(on average, in steady state, …)
– 𝐿 = 10 ms → 𝐵 = 100
op
s
– 𝐿 = 2 yr → 𝐵 = 0.5
op
yr
• Applies to a processor, a disk drive, a person, a TA, …
L L L L
…
time
L
Lec 19.13
4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022
Single Pipelined Server
• Single pipelined server of 𝑘 stages for tasks of length 𝐿 (i.e., time 𝐿
𝑘 per
stage) delivers at rate ≤ 𝑘
𝐿.
– 𝐿 = 10 ms, 𝑘 = 4 → 𝐵 = 400
op
s
– 𝐿 = 2 yr, 𝑘 = 2 → 𝐵 = 1
op
yr
L
…
L
L L L L L L L
logical operation
divided over distinct resources
time
Lec 19.14
4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022
Example Systems “Pipelines”
• Anything with queues between operational process behaves roughly
“pipeline like”
• Important difference is that “initiations” are decoupled from processing
– May have to queue up a burst of operations
– Not synchronous and deterministic like in 61C
User Process
syscall
File
System
Upper
Driver
Lower
Driver
I/O Processing
Communication
Lec 19.15
4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022
Multiple Servers
• 𝑘 servers handling tasks of length 𝐿 delivers at rate ≤ 𝑘
𝐿.
– 𝐿 = 10 ms, 𝑘 = 4 → 𝐵 = 400
op
s
– 𝐿 = 2 yr, 𝑘 = 2 → 𝐵 = 1
op
yr
• In 61C you saw multiple processors (cores)
– Systems present lots of multiple parallel servers
– Often with lots of queues
L
… k
Lec 19.16
4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022
Example Systems “Parallelism”
User Process
syscall File
System
Upper
Driver
Lower
Driver
I/O Processing
Communication
User Process
User Process
Parallel Computation, Databases, …
Lec 19.17
4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022
I/O Performance
Response Time = Queue + I/O device service time
User
Thread
Queue
[OS Paths]
Controller
I/O
device
• Performance of I/O subsystem
– Metrics: Response Time, Throughput
– Effective BW per op = transfer size / response time
» EffBW(n) = n / (S + n/B) = B / (1 + SB/n )
100%
Response
Time (ms)
Throughput (Utilization)
(% total BW)
0
100
200
300
0%
# of ops
Fixed overhead
time per op
Lec 19.18
4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022
I/O Performance
Response Time = Queue + I/O device service time
User
Thread
Queue
[OS Paths]
Controller
I/O
device
• Performance of I/O subsystem
– Metrics: Response Time, Throughput
– Effective BW per op = transfer size / response time
» EffBW(n) = n / (S + n/B) = B / (1 + SB/n )
– Contributing factors to latency:
» Software paths (can be loosely modeled by a queue)
» Hardware controller
» I/O device service time
• Queuing behavior:
– Can lead to big increases of latency as utilization increases
– Solutions?
100%
Response
Time (ms)
Throughput (Utilization)
(% total BW)
0
100
200
300
0%
Lec 19.19
4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022
A Simple Deterministic World
• Assume requests arrive at regular intervals, take a fixed
time to process, with plenty of time between …
• Service rate (μ = 1/TS) - operations per second
• Arrival rate: (λ = 1/TA) - requests per second
• Utilization: U = λ/μ , where λ < μ
• Average rate is the complete story
Queue Server
arrivals departures
TQ TS
TA TA TA
TS
Tq
Lec 19.20
4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022
A Ideal Linear World
• What does the queue wait time look like?
– Grows unbounded at a rate ~ (Ts/TA) till request rate subsides
Offered Load (TS/TA)
Delivered
Throughput
0 1
1
time
Queue
delay
Delivered
Throughput
0 1
1
Offered Load (TS/TA)
Empty Queue
Saturation
Unbounded
time
Queue
delay
Lec 19.21
4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022
A Bursty World
• Requests arrive in a burst, must queue up till served
• Same average arrival time, but almost all of the requests
experience large queue delays
• Even though average utilization is low
Queue Server
arrivals departures
TQ TS
Q depth
Server
Arrivals
Lec 19.22
4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022
• Elegant mathematical framework if you start with
exponential distribution
– Probability density function of a continuous random variable
with a mean of 1/λ
– f(x) = λe-λx
– “Memoryless”
0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
0 2 4 6 8 10
Likelihood of an event
occurring is independent of
how long we’ve been waiting
So how do we model the burstiness of arrival?
Lots of short arrival
intervals (i.e., high
instantaneous rate)
Few long gaps (i.e., low
instantaneous rate)
x (λ)
mean arrival interval (1/λ)
Lec 19.23
4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022
Background:
General Use of Random Distributions
• Server spends variable time (T) with customers
– Mean (Average) m = p(T)T
– Variance (stddev2) 2 = p(T)(T-m)2 = p(T)T2-m2
– Squared coefficient of variance: C = 2/m2
Aggregate description of the distribution
• Important values of C:
– No variance or deterministic  C=0
– “Memoryless” or exponential  C=1
» Past tells nothing about future
» Poisson process – purely or completely random process
» Many complex systems (or aggregates)
are well described as memoryless
– Disk response times C  1.5 (majority seeks < average)
Mean
(m)
mean
Memoryless
Distribution
of service times

Lec 19.24
4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022
Departures
Arrivals
Queuing System
Introduction to Queuing Theory
• What about queuing time??
– Let’s apply some queuing theory
– Queuing Theory applies to long term, steady state behavior 
Arrival rate = Departure rate
• Arrivals characterized by some probabilistic distribution
• Departures characterized by some probabilistic
distribution
Queue
Controller
Disk
Lec 19.25
4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022
Little’s Law
• In any stable system
– Average arrival rate = Average departure rate
• The average number of jobs/tasks in the system (N) is equal to
arrival time / throughput (λ) times the response time (L)
– N (jobs) = λ (jobs/s) x L (s)
• Regardless of structure, bursts of requests, variation in service
– Instantaneous variations, but it washes out in the average
– Overall, requests match departures
arrivals departures
N
λ
L
Lec 19.26
4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022
Example
λ = 1
L = 5
0 1 2 3 4 5 6 7 8 16
9 10 11 12 13 14 15 time
Jobs
L = 5
N = 5 jobs
A: N = λ x L
• E.g., N = λ x L = 5
Lec 19.27
4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022
Little’s Theorem: Proof Sketch
time
T
arrivals departures
N
λ
L
N(t)
L(i) = response time of job i
N(t) = number of jobs in system
at time t
Job i
L(1)
Lec 19.28
4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022
Little’s Theorem: Proof Sketch
time
T
arrivals departures
N
λ
L
N(t)
L(i) = response time of job i
N(t) = number of jobs in system
at time t
What is the system occupancy, i.e., average
number of jobs in the system?
Job i
Lec 19.29
4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022
Little’s Theorem: Proof Sketch
time
T
arrivals departures
N
λ
L
N(t)
L(i) = response time of job i
N(t) = number of jobs in system
at time t
S(i) = L(i) * 1 = L(i)
Job i
S(1)
S(2)
S = S(1) + S(2) + … + S(k) = L(1) + L(2) + … + L(k)
S(k)
Lec 19.30
4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022
Little’s Theorem: Proof Sketch
time
T
arrivals departures
N
λ
L
N(t)
L(i) = response time of job i
N(t) = number of jobs in system
at time t
S(i) = L(i) * 1 = L(i)
Average occupancy (Navg) = S/T
Job i
S= area
Lec 19.31
4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022
Little’s Theorem: Proof Sketch
time
T
arrivals departures
N
λ
L
N(t)
L(i) = response time of job i
N(t) = number of jobs in system
at time t
S(i) = L(i) * 1 = L(i)
Job i
S(1)
S(2)
Navg = S/T = (L(1) + … + L(k))/T
S(k)
Lec 19.32
4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022
Little’s Theorem: Proof Sketch
time
T
arrivals departures
N
λ
L
N(t)
L(i) = response time of job i
N(t) = number of jobs in system
at time t
S(i) = L(i) * 1 = L(i)
Job i
S(1)
S(2)
Navg = (L(1) + … + L(k))/T = (Ntotal/T)*(L(1) + … + L(k))/Ntotal
S(k)
Lec 19.33
4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022
Little’s Theorem: Proof Sketch
time
T
arrivals departures
N
λ
L
N(t)
L(i) = response time of job i
N(t) = number of jobs in system
at time t
S(i) = L(i) * 1 = L(i)
Job i
S(1)
S(2)
Navg = (Ntotal/T)*(L(1) + … + L(k))/Ntotal = λavg × Lavg
S(k)
Lec 19.34
4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022
Little’s Theorem: Proof Sketch
time
T
arrivals departures
N
λ
L
N(t)
L(i) = response time of job i
N(t) = number of jobs in system
at time t
S(i) = L(i) * 1 = L(i)
Job i
S(1)
S(2)
Navg = λavg × Lavg
S(k)
Lec 19.35
4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022
Little’s Law Applied to a Queue
• When Little’s Law applied to a queue, we get:
Average length of
the queue
Average Arrival Rate
Average time “waiting”
in queue
𝐿𝑄 = 𝜆𝑇𝑄
Lec 19.36
4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022
A Little Queuing Theory: Computing TQ
• Assumptions:
– System in equilibrium; No limit to the queue
– Time between successive arrivals is random and memoryless
• Parameters that describe our system:
– : mean number of arriving customers/second
– Tser: mean time to service a customer (“m1”)
– C: squared coefficient of variance = 2/m12
– μ: service rate = 1/Tser
– u: server utilization (0u1): u = /μ =   Tser
• Results:
– Memoryless service distribution (C = 1): (an “M/M/1 queue”):
» Tq = Tser x u/(1 – u)
– General service distribution, 1 server (an “M/G/1 queue”):
» Tq = Tser x ½(1+C) x u/(1 – u)
Arrival Rate

Queue Server
Service Rate
μ=1/Tser
Why does response/queueing
delay grow unboundedly even
though the utilization is < 1 ?
100%
Response
Time (ms)
Throughput (Utilization)
(% total BW)
0
100
200
300
0%
Lec 19.37
4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022
System Performance In presence of a Queue
Request Rate ( 𝜆 ) - “offered load”
Service
Rate
(𝜇)
-
“delivered
load”
𝜇𝑚𝑎𝑥
𝜇𝑚𝑎𝑥
Latency (𝜆)
Operation Time
Time
“Half-Power Point” : load at which system delivers half of peak performance
- Design and provision systems to operate roughly in this regime
- Latency low and predictable, utilization good: ~50%
• 𝑇𝑄~
𝑢
1−𝑢
, u = 𝜆
𝜇𝑚𝑎𝑥
• Why does latency
blow up as we
approach 100%
utilization?
• Queue builds up on
each burst
• But very rarely (or
never) gets a
chance to drain
Lec 19.38
4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022
Why unbounded response time?
• Assume deterministic arrival process and service time
– Possible to sustain utilization = 1 with bounded response time!
time
arrival
time
service
time
Lec 19.39
4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022
Why unbounded response time?
• Assume stochastic arrival process
(and service time)
– No longer possible to achieve
utilization = 1
100%
Response
Time (ms)
Throughput (Utilization)
(% total BW)
0
100
200
300
0%
time
This wasted time can
never be reclaimed!
So cannot achieve u = 1!
Lec 19.40
4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022
A Little Queuing Theory: An Example
• Example Usage Statistics:
– User requests 10 x 8KB disk I/Os per second
– Requests & service exponentially distributed (C=1.0)
– Avg. service = 20 ms (From controller+seek+rot+trans)
• Questions:
– How utilized is the disk?
» Ans: server utilization, u = Tser
– What is the average time spent in the queue?
» Ans: Tq
– What is the number of requests in the queue?
» Ans: Lq
– What is the avg response time for disk request?
» Ans: Tsys = Tq + Tser
• Computation:
 (avg # arriving customers/s) = 10/s
Tser (avg time to service customer) = 20 ms (0.02s)
u (server utilization) =  x Tser= 10/s x .02s = 0.2
Tq (avg time/customer in queue) = Tser x u/(1 – u)
= 20 x 0.2/(1-0.2) = 20 x 0.25 = 5 ms (0 .005s)
Lq (avg length of queue) =  x Tq=10/s x .005s = 0.05
Tsys (avg time/customer in system) =Tq + Tser= 25 ms
Lec 19.41
4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022
Queuing Theory Resources
• Resources page contains Queueing Theory Resources (under
Readings):
– Scanned pages from Patterson and Hennessy book that gives further
discussion and simple proof for general equation:
https://cs162.eecs.berkeley.edu/static/readings/patterson_queue.pdf
– A complete website full of resources:
http://web2.uwindsor.ca/math/hlynka/qonline.html
• Some previous midterms with queueing theory questions
• Assume that Queueing Theory is fair game for Midterm III!
Lec 19.42
4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022
Optimize I/O Performance
• How to improve performance?
– Make everything faster 
– More Decoupled (Parallelism) systems
» multiple independent buses or controllers
– Optimize the bottleneck to increase service rate
» Use the queue to optimize the service
– Do other useful work while waiting
• Queues absorb bursts and smooth the flow
• Admissions control (finite queues)
– Limits delays, but may introduce unfairness and livelock
Response Time =
Queue + I/O device service time
User
Thread
Queue
[OS Paths]
Controller
I/O
device
100%
Response
Time (ms)
Throughput (Utilization)
(% total BW)
0
100
200
300
0%
Lec 19.43
4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022
When is Disk Performance Highest?
• When there are big sequential reads, or
• When there is so much work to do that they can be piggy
backed (reordering queues—one moment)
• OK to be inefficient when things are mostly idle
• Bursts are both a threat and an opportunity
• <your idea for optimization goes here>
– Waste space for speed?
• Other techniques:
– Reduce overhead through user level drivers
– Reduce the impact of I/O delays by doing other useful work
in the meantime
Lec 19.44
4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022
Disk Scheduling (1/3)
• Disk can do only one request at a time; What order do you
choose to do queued requests?
• FIFO Order
– Fair among requesters, but order of arrival may be
to random spots on the disk  Very long seeks
• SSTF: Shortest seek time first
– Pick the request that’s closest on the disk
– Although called SSTF, today must include
rotational delay in calculation, since
rotation can be as long as seek
– Con: SSTF good at reducing seeks, but
may lead to starvation
2,3
2,1
3,10
7,2
5,2
2,2
Head
User
Requests
1
4
2
Disk
Head
3
Lec 19.45
4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022
Disk Scheduling (2/3)
• Disk can do only one request at a time; What order do you
choose to do queued requests?
• SCAN: Implements an Elevator Algorithm: take the closest
request in the direction of travel
– No starvation, but retains flavor of SSTF
2,3
2,1
3,10
7,2
5,2
2,2
Head
User
Requests
Lec 19.46
4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022
Disk Scheduling (3/3)
• Disk can do only one request at a time; What order do you
choose to do queued requests?
• C-SCAN: Circular-Scan: only goes in one direction
– Skips any requests on the way back
– Fairer than SCAN, not biased towards pages in middle
2,3
2,1
3,10
7,2
5,2
2,2
Head
User
Requests
Lec 19.47
4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022
Recall: How do we Hide I/O Latency?
• Blocking Interface: “Wait”
– When request data (e.g., read() system call), put process to sleep until
data is ready
– When write data (e.g., write() system call), put process to sleep until
device is ready for data
• Non-blocking Interface: “Don’t Wait”
– Returns quickly from read or write request with count of bytes
successfully transferred to kernel
– Read may return nothing, write may write nothing
• Asynchronous Interface: “Tell Me Later”
– When requesting data, take pointer to user’s buffer, return
immediately; later kernel fills buffer and notifies user
– When sending data, take pointer to user’s buffer, return immediately;
later kernel takes data and notifies user
Lec 19.48
4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022
Recall: I/O and Storage Layers
High Level I/O
Low Level I/O
Syscall
File System
I/O Driver
Application / Service
Streams
File Descriptors
open(), read(), write(), close(), …
Files/Directories/Indexes
Commands and Data Transfers
Disks, Flash, Controllers, DMA
What we covered in Lecture 4
Open File Descriptions
What we just covered…
What we will cover next…
Lec 19.49
4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022
From Storage to File Systems
I/O API and
syscalls
Variable-Size Buffer
File System Block
Logical Index,
Typically 4 KB
Hardware
Devices
Memory Address
HDD
Sector(s)
Physical Index,
512B or 4KB
SSD
Flash Trans. Layer
Phys. Block Phys Index.,
4KB
Sector(s)
Sector(s)
Erasure Page
Lec 19.50
4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022
Building a File System
• File System: Layer of OS that transforms block interface of disks (or other
block devices) into Files, Directories, etc.
• Classic OS situation: Take limited hardware interface (array of blocks) and
provide a more convenient/useful interface with:
– Naming: Find file by name, not block numbers
– Organize file names with directories
– Organization: Map files to blocks
– Protection: Enforce access restrictions
– Reliability: Keep files intact despite crashes, hardware failures, etc.
Lec 19.51
4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022
Recall: User vs. System View of a File
• User’s view:
– Durable Data Structures
• System’s view (system call interface):
– Collection of Bytes (UNIX)
– Doesn’t matter to system what kind of data structures you want to store on disk!
• System’s view (inside OS):
– Collection of blocks (a block is a logical transfer unit, while a sector is the physical
transfer unit)
– Block size  sector size; in UNIX, block size is 4KB
Lec 19.52
4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022
Translation from User to System View
• What happens if user says: “give me bytes 2 – 12?”
– Fetch block corresponding to those bytes
– Return just the correct portion of the block
• What about writing bytes 2 – 12?
– Fetch block, modify relevant portion, write out block
• Everything inside file system is in terms of whole-size blocks
– Actual disk I/O happens in blocks
– read/write smaller than block size needs to translate and buffer
File
System
File
(Bytes)
Lec 19.53
4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022
Disk Management
• Basic entities on a disk:
– File: user-visible group of blocks arranged sequentially in logical space
– Directory: user-visible index mapping names to files
• The disk is accessed as linear array of sectors
• How to identify a sector?
–Physical position
» Sectors is a vector [cylinder, surface, sector]
» Not used anymore
» OS/BIOS must deal with bad sectors
–Logical Block Addressing (LBA)
» Every sector has integer address
» Controller translates from address  physical position
» Shields OS from structure of disk
Lec 19.54
4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022
What Does the File System Need?
• Track free disk blocks
–Need to know where to put newly written data
• Track which blocks contain data for which files
–Need to know where to read a file from
• Track files in a directory
–Find list of file's blocks given its name
• Where do we maintain all of this?
–Somewhere on disk
Lec 19.55
4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022
Conclusion
• Disk Performance:
– Queuing time + Controller + Seek + Rotational + Transfer
– Rotational latency: on average ½ rotation
– Transfer time: spec of disk depends on rotation speed and bit storage density
• Devices have complex interaction and performance characteristics
– Response time (Latency) = Queue + Overhead + Transfer
» Effective BW = BW * T/(S+T)
– HDD: Queuing time + controller + seek + rotation + transfer
– SDD: Queuing time + controller + transfer (erasure & wear)
• Systems (e.g., file system) designed to optimize performance and reliability
– Relative to performance characteristics of underlying device
• Bursts & High Utilization introduce queuing delays
• Queuing Latency:
– M/M/1 and M/G/1 queues: simplest to analyze
– As utilization approaches 100%, latency  
Tq = Tser x ½(1+C) x u/(1 – u))

Weitere ähnliche Inhalte

Ähnlich wie 19th Session.pptx

Ceph Day Netherlands - Ceph @ BIT
Ceph Day Netherlands - Ceph @ BIT Ceph Day Netherlands - Ceph @ BIT
Ceph Day Netherlands - Ceph @ BIT Ceph Community
 
40 Powers of 10 - Simulating the Universe with the DiRAC HPC Facility
40 Powers of 10 - Simulating the Universe with the DiRAC HPC Facility40 Powers of 10 - Simulating the Universe with the DiRAC HPC Facility
40 Powers of 10 - Simulating the Universe with the DiRAC HPC Facilityinside-BigData.com
 
High Performance & High Throughput Computing - EUDAT Summer School (Giuseppe ...
High Performance & High Throughput Computing - EUDAT Summer School (Giuseppe ...High Performance & High Throughput Computing - EUDAT Summer School (Giuseppe ...
High Performance & High Throughput Computing - EUDAT Summer School (Giuseppe ...EUDAT
 
L14-Embedded.ppt
L14-Embedded.pptL14-Embedded.ppt
L14-Embedded.pptAashuSah2
 
Introduction to DPDK
Introduction to DPDKIntroduction to DPDK
Introduction to DPDKKernel TLV
 
Journey to Stability: Petabyte Ceph Cluster in OpenStack Cloud
Journey to Stability: Petabyte Ceph Cluster in OpenStack CloudJourney to Stability: Petabyte Ceph Cluster in OpenStack Cloud
Journey to Stability: Petabyte Ceph Cluster in OpenStack CloudCeph Community
 
Journey to Stability: Petabyte Ceph Cluster in OpenStack Cloud
Journey to Stability: Petabyte Ceph Cluster in OpenStack CloudJourney to Stability: Petabyte Ceph Cluster in OpenStack Cloud
Journey to Stability: Petabyte Ceph Cluster in OpenStack CloudPatrick McGarry
 
TritonSort: A Balanced Large-Scale Sorting System (NSDI 2011)
TritonSort: A Balanced Large-Scale Sorting System (NSDI 2011)TritonSort: A Balanced Large-Scale Sorting System (NSDI 2011)
TritonSort: A Balanced Large-Scale Sorting System (NSDI 2011)Alex Rasmussen
 
Automotive network and gateway simulation
Automotive network and gateway simulationAutomotive network and gateway simulation
Automotive network and gateway simulationDeepak Shankar
 
Understanding and Measuring I/O Performance
Understanding and Measuring I/O PerformanceUnderstanding and Measuring I/O Performance
Understanding and Measuring I/O PerformanceGlenn K. Lockwood
 
Red Hat Storage Day Seattle: Stabilizing Petabyte Ceph Cluster in OpenStack C...
Red Hat Storage Day Seattle: Stabilizing Petabyte Ceph Cluster in OpenStack C...Red Hat Storage Day Seattle: Stabilizing Petabyte Ceph Cluster in OpenStack C...
Red Hat Storage Day Seattle: Stabilizing Petabyte Ceph Cluster in OpenStack C...Red_Hat_Storage
 
Memory, Big Data, NoSQL and Virtualization
Memory, Big Data, NoSQL and VirtualizationMemory, Big Data, NoSQL and Virtualization
Memory, Big Data, NoSQL and VirtualizationBigstep
 
High-performance 32G Fibre Channel Module on MDS 9700 Directors:
High-performance 32G Fibre Channel Module on MDS 9700 Directors:High-performance 32G Fibre Channel Module on MDS 9700 Directors:
High-performance 32G Fibre Channel Module on MDS 9700 Directors:Tony Antony
 
lec12-pipelining.ppt
lec12-pipelining.pptlec12-pipelining.ppt
lec12-pipelining.pptManimegalaM3
 
Accelerating HBase with NVMe and Bucket Cache
Accelerating HBase with NVMe and Bucket CacheAccelerating HBase with NVMe and Bucket Cache
Accelerating HBase with NVMe and Bucket CacheNicolas Poggi
 
“Show Me the Garbage!”, Garbage Collection a Friend or a Foe
“Show Me the Garbage!”, Garbage Collection a Friend or a Foe“Show Me the Garbage!”, Garbage Collection a Friend or a Foe
“Show Me the Garbage!”, Garbage Collection a Friend or a FoeHaim Yadid
 

Ähnlich wie 19th Session.pptx (20)

Overview of HPC Interconnects
Overview of HPC InterconnectsOverview of HPC Interconnects
Overview of HPC Interconnects
 
lec16-memory.ppt
lec16-memory.pptlec16-memory.ppt
lec16-memory.ppt
 
Ceph Day Netherlands - Ceph @ BIT
Ceph Day Netherlands - Ceph @ BIT Ceph Day Netherlands - Ceph @ BIT
Ceph Day Netherlands - Ceph @ BIT
 
40 Powers of 10 - Simulating the Universe with the DiRAC HPC Facility
40 Powers of 10 - Simulating the Universe with the DiRAC HPC Facility40 Powers of 10 - Simulating the Universe with the DiRAC HPC Facility
40 Powers of 10 - Simulating the Universe with the DiRAC HPC Facility
 
Exascale Capabl
Exascale CapablExascale Capabl
Exascale Capabl
 
High Performance & High Throughput Computing - EUDAT Summer School (Giuseppe ...
High Performance & High Throughput Computing - EUDAT Summer School (Giuseppe ...High Performance & High Throughput Computing - EUDAT Summer School (Giuseppe ...
High Performance & High Throughput Computing - EUDAT Summer School (Giuseppe ...
 
L14-Embedded.ppt
L14-Embedded.pptL14-Embedded.ppt
L14-Embedded.ppt
 
Introduction to DPDK
Introduction to DPDKIntroduction to DPDK
Introduction to DPDK
 
Journey to Stability: Petabyte Ceph Cluster in OpenStack Cloud
Journey to Stability: Petabyte Ceph Cluster in OpenStack CloudJourney to Stability: Petabyte Ceph Cluster in OpenStack Cloud
Journey to Stability: Petabyte Ceph Cluster in OpenStack Cloud
 
Journey to Stability: Petabyte Ceph Cluster in OpenStack Cloud
Journey to Stability: Petabyte Ceph Cluster in OpenStack CloudJourney to Stability: Petabyte Ceph Cluster in OpenStack Cloud
Journey to Stability: Petabyte Ceph Cluster in OpenStack Cloud
 
TritonSort: A Balanced Large-Scale Sorting System (NSDI 2011)
TritonSort: A Balanced Large-Scale Sorting System (NSDI 2011)TritonSort: A Balanced Large-Scale Sorting System (NSDI 2011)
TritonSort: A Balanced Large-Scale Sorting System (NSDI 2011)
 
Automotive network and gateway simulation
Automotive network and gateway simulationAutomotive network and gateway simulation
Automotive network and gateway simulation
 
Understanding and Measuring I/O Performance
Understanding and Measuring I/O PerformanceUnderstanding and Measuring I/O Performance
Understanding and Measuring I/O Performance
 
Red Hat Storage Day Seattle: Stabilizing Petabyte Ceph Cluster in OpenStack C...
Red Hat Storage Day Seattle: Stabilizing Petabyte Ceph Cluster in OpenStack C...Red Hat Storage Day Seattle: Stabilizing Petabyte Ceph Cluster in OpenStack C...
Red Hat Storage Day Seattle: Stabilizing Petabyte Ceph Cluster in OpenStack C...
 
Memory, Big Data, NoSQL and Virtualization
Memory, Big Data, NoSQL and VirtualizationMemory, Big Data, NoSQL and Virtualization
Memory, Big Data, NoSQL and Virtualization
 
High-performance 32G Fibre Channel Module on MDS 9700 Directors:
High-performance 32G Fibre Channel Module on MDS 9700 Directors:High-performance 32G Fibre Channel Module on MDS 9700 Directors:
High-performance 32G Fibre Channel Module on MDS 9700 Directors:
 
lec12-pipelining.ppt
lec12-pipelining.pptlec12-pipelining.ppt
lec12-pipelining.ppt
 
Accelerating HBase with NVMe and Bucket Cache
Accelerating HBase with NVMe and Bucket CacheAccelerating HBase with NVMe and Bucket Cache
Accelerating HBase with NVMe and Bucket Cache
 
“Show Me the Garbage!”, Garbage Collection a Friend or a Foe
“Show Me the Garbage!”, Garbage Collection a Friend or a Foe“Show Me the Garbage!”, Garbage Collection a Friend or a Foe
“Show Me the Garbage!”, Garbage Collection a Friend or a Foe
 
Corralling Big Data at TACC
Corralling Big Data at TACCCorralling Big Data at TACC
Corralling Big Data at TACC
 

Kürzlich hochgeladen

Low Rate Call Girls Nashik Vedika 7001305949 Independent Escort Service Nashik
Low Rate Call Girls Nashik Vedika 7001305949 Independent Escort Service NashikLow Rate Call Girls Nashik Vedika 7001305949 Independent Escort Service Nashik
Low Rate Call Girls Nashik Vedika 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
(ANIKA) Wanwadi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(ANIKA) Wanwadi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(ANIKA) Wanwadi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(ANIKA) Wanwadi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...ranjana rawat
 
Book Paid Lohegaon Call Girls Pune 8250192130Low Budget Full Independent High...
Book Paid Lohegaon Call Girls Pune 8250192130Low Budget Full Independent High...Book Paid Lohegaon Call Girls Pune 8250192130Low Budget Full Independent High...
Book Paid Lohegaon Call Girls Pune 8250192130Low Budget Full Independent High...ranjana rawat
 
定制加拿大滑铁卢大学毕业证(Waterloo毕业证书)成绩单(文凭)原版一比一
定制加拿大滑铁卢大学毕业证(Waterloo毕业证书)成绩单(文凭)原版一比一定制加拿大滑铁卢大学毕业证(Waterloo毕业证书)成绩单(文凭)原版一比一
定制加拿大滑铁卢大学毕业证(Waterloo毕业证书)成绩单(文凭)原版一比一zul5vf0pq
 
Thane Escorts, (Pooja 09892124323), Thane Call Girls
Thane Escorts, (Pooja 09892124323), Thane Call GirlsThane Escorts, (Pooja 09892124323), Thane Call Girls
Thane Escorts, (Pooja 09892124323), Thane Call GirlsPooja Nehwal
 
VIP Call Girls Hitech City ( Hyderabad ) Phone 8250192130 | ₹5k To 25k With R...
VIP Call Girls Hitech City ( Hyderabad ) Phone 8250192130 | ₹5k To 25k With R...VIP Call Girls Hitech City ( Hyderabad ) Phone 8250192130 | ₹5k To 25k With R...
VIP Call Girls Hitech City ( Hyderabad ) Phone 8250192130 | ₹5k To 25k With R...Suhani Kapoor
 
Develop Keyboard Skill.pptx er power point
Develop Keyboard Skill.pptx er power pointDevelop Keyboard Skill.pptx er power point
Develop Keyboard Skill.pptx er power pointGetawu
 
VIP Call Girls Kavuri Hills ( Hyderabad ) Phone 8250192130 | ₹5k To 25k With ...
VIP Call Girls Kavuri Hills ( Hyderabad ) Phone 8250192130 | ₹5k To 25k With ...VIP Call Girls Kavuri Hills ( Hyderabad ) Phone 8250192130 | ₹5k To 25k With ...
VIP Call Girls Kavuri Hills ( Hyderabad ) Phone 8250192130 | ₹5k To 25k With ...Suhani Kapoor
 
Call Girls in Thane 9892124323, Vashi cAll girls Serivces Juhu Escorts, powai...
Call Girls in Thane 9892124323, Vashi cAll girls Serivces Juhu Escorts, powai...Call Girls in Thane 9892124323, Vashi cAll girls Serivces Juhu Escorts, powai...
Call Girls in Thane 9892124323, Vashi cAll girls Serivces Juhu Escorts, powai...Pooja Nehwal
 
Call Girls In Andheri East Call 9892124323 Book Hot And Sexy Girls,
Call Girls In Andheri East Call 9892124323 Book Hot And Sexy Girls,Call Girls In Andheri East Call 9892124323 Book Hot And Sexy Girls,
Call Girls In Andheri East Call 9892124323 Book Hot And Sexy Girls,Pooja Nehwal
 
presentation about microsoft power point
presentation about microsoft power pointpresentation about microsoft power point
presentation about microsoft power pointchhavia330
 
Top Rated Pune Call Girls Chakan ⟟ 6297143586 ⟟ Call Me For Genuine Sex Serv...
Top Rated  Pune Call Girls Chakan ⟟ 6297143586 ⟟ Call Me For Genuine Sex Serv...Top Rated  Pune Call Girls Chakan ⟟ 6297143586 ⟟ Call Me For Genuine Sex Serv...
Top Rated Pune Call Girls Chakan ⟟ 6297143586 ⟟ Call Me For Genuine Sex Serv...Call Girls in Nagpur High Profile
 
Call Girls in Vashi Escorts Services - 7738631006
Call Girls in Vashi Escorts Services - 7738631006Call Girls in Vashi Escorts Services - 7738631006
Call Girls in Vashi Escorts Services - 7738631006Pooja Nehwal
 
Pallawi 9167673311 Call Girls in Thane , Independent Escort Service Thane
Pallawi 9167673311  Call Girls in Thane , Independent Escort Service ThanePallawi 9167673311  Call Girls in Thane , Independent Escort Service Thane
Pallawi 9167673311 Call Girls in Thane , Independent Escort Service ThanePooja Nehwal
 
VIP Call Girl Saharanpur Aashi 8250192130 Independent Escort Service Saharanpur
VIP Call Girl Saharanpur Aashi 8250192130 Independent Escort Service SaharanpurVIP Call Girl Saharanpur Aashi 8250192130 Independent Escort Service Saharanpur
VIP Call Girl Saharanpur Aashi 8250192130 Independent Escort Service SaharanpurSuhani Kapoor
 
哪里办理美国宾夕法尼亚州立大学毕业证(本硕)psu成绩单原版一模一样
哪里办理美国宾夕法尼亚州立大学毕业证(本硕)psu成绩单原版一模一样哪里办理美国宾夕法尼亚州立大学毕业证(本硕)psu成绩单原版一模一样
哪里办理美国宾夕法尼亚州立大学毕业证(本硕)psu成绩单原版一模一样qaffana
 
9892124323, Call Girl in Juhu Call Girls Services (Rate ₹8.5K) 24×7 with Hote...
9892124323, Call Girl in Juhu Call Girls Services (Rate ₹8.5K) 24×7 with Hote...9892124323, Call Girl in Juhu Call Girls Services (Rate ₹8.5K) 24×7 with Hote...
9892124323, Call Girl in Juhu Call Girls Services (Rate ₹8.5K) 24×7 with Hote...Pooja Nehwal
 
Call Girls in Nagpur Sakshi Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Sakshi Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Sakshi Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Sakshi Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
High Profile Call Girls In Andheri 7738631006 Call girls in mumbai Mumbai ...
High Profile Call Girls In Andheri 7738631006 Call girls in mumbai  Mumbai ...High Profile Call Girls In Andheri 7738631006 Call girls in mumbai  Mumbai ...
High Profile Call Girls In Andheri 7738631006 Call girls in mumbai Mumbai ...Pooja Nehwal
 

Kürzlich hochgeladen (20)

Low Rate Call Girls Nashik Vedika 7001305949 Independent Escort Service Nashik
Low Rate Call Girls Nashik Vedika 7001305949 Independent Escort Service NashikLow Rate Call Girls Nashik Vedika 7001305949 Independent Escort Service Nashik
Low Rate Call Girls Nashik Vedika 7001305949 Independent Escort Service Nashik
 
(ANIKA) Wanwadi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(ANIKA) Wanwadi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(ANIKA) Wanwadi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(ANIKA) Wanwadi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
 
Book Paid Lohegaon Call Girls Pune 8250192130Low Budget Full Independent High...
Book Paid Lohegaon Call Girls Pune 8250192130Low Budget Full Independent High...Book Paid Lohegaon Call Girls Pune 8250192130Low Budget Full Independent High...
Book Paid Lohegaon Call Girls Pune 8250192130Low Budget Full Independent High...
 
定制加拿大滑铁卢大学毕业证(Waterloo毕业证书)成绩单(文凭)原版一比一
定制加拿大滑铁卢大学毕业证(Waterloo毕业证书)成绩单(文凭)原版一比一定制加拿大滑铁卢大学毕业证(Waterloo毕业证书)成绩单(文凭)原版一比一
定制加拿大滑铁卢大学毕业证(Waterloo毕业证书)成绩单(文凭)原版一比一
 
Thane Escorts, (Pooja 09892124323), Thane Call Girls
Thane Escorts, (Pooja 09892124323), Thane Call GirlsThane Escorts, (Pooja 09892124323), Thane Call Girls
Thane Escorts, (Pooja 09892124323), Thane Call Girls
 
VIP Call Girls Hitech City ( Hyderabad ) Phone 8250192130 | ₹5k To 25k With R...
VIP Call Girls Hitech City ( Hyderabad ) Phone 8250192130 | ₹5k To 25k With R...VIP Call Girls Hitech City ( Hyderabad ) Phone 8250192130 | ₹5k To 25k With R...
VIP Call Girls Hitech City ( Hyderabad ) Phone 8250192130 | ₹5k To 25k With R...
 
🔝 9953056974🔝 Delhi Call Girls in Ajmeri Gate
🔝 9953056974🔝 Delhi Call Girls in Ajmeri Gate🔝 9953056974🔝 Delhi Call Girls in Ajmeri Gate
🔝 9953056974🔝 Delhi Call Girls in Ajmeri Gate
 
Develop Keyboard Skill.pptx er power point
Develop Keyboard Skill.pptx er power pointDevelop Keyboard Skill.pptx er power point
Develop Keyboard Skill.pptx er power point
 
VIP Call Girls Kavuri Hills ( Hyderabad ) Phone 8250192130 | ₹5k To 25k With ...
VIP Call Girls Kavuri Hills ( Hyderabad ) Phone 8250192130 | ₹5k To 25k With ...VIP Call Girls Kavuri Hills ( Hyderabad ) Phone 8250192130 | ₹5k To 25k With ...
VIP Call Girls Kavuri Hills ( Hyderabad ) Phone 8250192130 | ₹5k To 25k With ...
 
Call Girls in Thane 9892124323, Vashi cAll girls Serivces Juhu Escorts, powai...
Call Girls in Thane 9892124323, Vashi cAll girls Serivces Juhu Escorts, powai...Call Girls in Thane 9892124323, Vashi cAll girls Serivces Juhu Escorts, powai...
Call Girls in Thane 9892124323, Vashi cAll girls Serivces Juhu Escorts, powai...
 
Call Girls In Andheri East Call 9892124323 Book Hot And Sexy Girls,
Call Girls In Andheri East Call 9892124323 Book Hot And Sexy Girls,Call Girls In Andheri East Call 9892124323 Book Hot And Sexy Girls,
Call Girls In Andheri East Call 9892124323 Book Hot And Sexy Girls,
 
presentation about microsoft power point
presentation about microsoft power pointpresentation about microsoft power point
presentation about microsoft power point
 
Top Rated Pune Call Girls Chakan ⟟ 6297143586 ⟟ Call Me For Genuine Sex Serv...
Top Rated  Pune Call Girls Chakan ⟟ 6297143586 ⟟ Call Me For Genuine Sex Serv...Top Rated  Pune Call Girls Chakan ⟟ 6297143586 ⟟ Call Me For Genuine Sex Serv...
Top Rated Pune Call Girls Chakan ⟟ 6297143586 ⟟ Call Me For Genuine Sex Serv...
 
Call Girls in Vashi Escorts Services - 7738631006
Call Girls in Vashi Escorts Services - 7738631006Call Girls in Vashi Escorts Services - 7738631006
Call Girls in Vashi Escorts Services - 7738631006
 
Pallawi 9167673311 Call Girls in Thane , Independent Escort Service Thane
Pallawi 9167673311  Call Girls in Thane , Independent Escort Service ThanePallawi 9167673311  Call Girls in Thane , Independent Escort Service Thane
Pallawi 9167673311 Call Girls in Thane , Independent Escort Service Thane
 
VIP Call Girl Saharanpur Aashi 8250192130 Independent Escort Service Saharanpur
VIP Call Girl Saharanpur Aashi 8250192130 Independent Escort Service SaharanpurVIP Call Girl Saharanpur Aashi 8250192130 Independent Escort Service Saharanpur
VIP Call Girl Saharanpur Aashi 8250192130 Independent Escort Service Saharanpur
 
哪里办理美国宾夕法尼亚州立大学毕业证(本硕)psu成绩单原版一模一样
哪里办理美国宾夕法尼亚州立大学毕业证(本硕)psu成绩单原版一模一样哪里办理美国宾夕法尼亚州立大学毕业证(本硕)psu成绩单原版一模一样
哪里办理美国宾夕法尼亚州立大学毕业证(本硕)psu成绩单原版一模一样
 
9892124323, Call Girl in Juhu Call Girls Services (Rate ₹8.5K) 24×7 with Hote...
9892124323, Call Girl in Juhu Call Girls Services (Rate ₹8.5K) 24×7 with Hote...9892124323, Call Girl in Juhu Call Girls Services (Rate ₹8.5K) 24×7 with Hote...
9892124323, Call Girl in Juhu Call Girls Services (Rate ₹8.5K) 24×7 with Hote...
 
Call Girls in Nagpur Sakshi Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Sakshi Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Sakshi Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Sakshi Call 7001035870 Meet With Nagpur Escorts
 
High Profile Call Girls In Andheri 7738631006 Call girls in mumbai Mumbai ...
High Profile Call Girls In Andheri 7738631006 Call girls in mumbai  Mumbai ...High Profile Call Girls In Andheri 7738631006 Call girls in mumbai  Mumbai ...
High Profile Call Girls In Andheri 7738631006 Call girls in mumbai Mumbai ...
 

19th Session.pptx

  • 1. CS162 Operating Systems and Systems Programming Lecture 19 Filesystems 1: Performance (Con’t), Queueing Theory, Filesystem Design April 5th, 2022 Prof. Anthony Joseph and John Kubiatowicz http://cs162.eecs.Berkeley.edu
  • 2. Lec 19.2 4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022 Recall: Magnetic Disks • Cylinders: all the tracks under the head at a given point on all surfaces • Read/write data is a three-stage process: – Seek time: position the head/arm over the proper track – Rotational latency: wait for desired sector to rotate under r/w head – Transfer time: transfer a block of bits (sector) under r/w head Sector Track Cylinder Head Platter Software Queue (Device Driver) Hardware Controller Media Time (Seek+Rot+Xfer) Request Result Disk Latency = Queueing Time + Controller time + Seek Time + Rotation Time + Xfer Time
  • 3. Lec 19.3 4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022 Recall: Typical Numbers for Magnetic Disk Parameter Info/Range Space/Density Space: 18TB (Seagate), 9 platters, in 3½ inch form factor! Areal Density: ≥ 1 Terabit/square inch! (PMR, Helium, …) Average Seek Time Typically 4-6 milliseconds Average Rotational Latency Most laptop/desktop disks rotate at 3600-7200 RPM (16-8 ms/rotation). Server disks up to 15,000 RPM. Average latency is halfway around disk so 4-8 milliseconds Controller Time Depends on controller hardware Transfer Time Typically 50 to 250 MB/s. Depends on: • Transfer size (usually a sector): 512B – 1KB per sector • Rotation speed: 3600 RPM to 15000 RPM • Recording density: bits per inch on a track • Diameter: ranges from 1 in to 5.25 in Cost Used to drop by a factor of two every 1.5 years (or faster), now slowing down
  • 4. Lec 19.4 4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022 Recall: FLASH Memory • Like a normal transistor but: – Has a floating gate that can hold charge – To write: raise or lower wordline high enough to cause charges to tunnel – To read: turn on wordline as if normal transistor » presence of charge changes threshold and thus measured current • Two varieties: – NAND: denser, must be read and written in blocks – NOR: much less dense, fast to read and write • V-NAND: 3D stacking (Samsung claims 1TB possible in 1 chip) Samsung 2015: 512GB, NAND Flash
  • 5. Lec 19.5 4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022 Recall: SSD Summary • Pros (vs. hard disk drives): – Low latency, high throughput (eliminate seek/rotational delay) – No moving parts: » Very light weight, low power, silent, very shock insensitive – Read at memory speeds (limited by controller and I/O bus) • Cons – Small storage (0.1-0.5x disk), expensive (3-20x disk) » Hybrid alternative: combine small SSD with large HDD
  • 6. Lec 19.6 4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022 Recall: SSD Summary • Pros (vs. hard disk drives): – Low latency, high throughput (eliminate seek/rotational delay) – No moving parts: » Very light weight, low power, silent, very shock insensitive – Read at memory speeds (limited by controller and I/O bus) • Cons – Small storage (0.1-0.5x disk), expensive (3-20x disk) » Hybrid alternative: combine small SSD with large HDD – Asymmetric block write performance: read pg/erase/write pg » Controller garbage collection (GC) algorithms have major effect on performance – Limited drive lifetime » 1-10K writes/page for MLC NAND » Avg failure rate is 6 years, life expectancy is 9–11 years • These are changing rapidly! No longer true!
  • 7. Lec 19.7 4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022 Nano-Tube Memory (NANTERO) • Yet another possibility: Nanotube memory – NanoTubes between two electrodes, slight conductivity difference between ones and zeros – No wearout! • Better than DRAM? – Speed of DRAM, no wearout, non-volatile! – Nantero promises 512Gb/dice for 8Tb/chip! (with 16 die stacking)
  • 8. Lec 19.8 4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022 Ways of Measuring Performance: Times (s) and Rates (op/s) • Latency – time to complete a task – Measured in units of time (s, ms, us, …, hours, years) • Response Time - time to initiate and operation and get its response – Able to issue one that depends on the result – Know that it is done (anti-dependence, resource usage) • Throughput or Bandwidth – rate at which tasks are performed – Measured in units of things per unit time (ops/s, GFLOP/s) • Start up or “Overhead” – time to initiate an operation • Most I/O operations are roughly linear in b bytes – Latency(b) = Overhead + b/TransferCapacity • Performance??? – Operation time (4 mins to run a mile…) – Rate (mph, mpg, …)
  • 9. Lec 19.9 4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022 Example: Overhead in Fast Network • Consider a 1 Gb/s link (𝐵𝑤 = 125 MB/s) with startup cost 𝑆 = 1 ms • Latency: 𝐿 𝑥 = 𝑆 + 𝑥 𝐵𝑤 • Effective Bandwidth: 𝐸 𝑥 = 𝑥 𝑆 + 𝑥 𝐵𝑤 = 𝐵𝑤 ⋅ 𝑥 𝐵𝑤 ⋅ 𝑆 + 𝑥 = 𝐵𝑤 𝐵𝑤 ⋅ 𝑆 𝑥 + 1 • Half-power Bandwidth: 𝐸 𝑥 = 𝐵𝑥 2 • For this example, half-power bandwidth occurs at x = 125 KB Length (x)
  • 10. Lec 19.10 4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022 Example: 10 ms Startup Cost (e.g., Disk) • Half-power bandwidth at x = 1.25 MB • Large startup cost can degrade effective bandwidth • Amortize it by performing I/O in larger blocks 0 5 10 15 20 25 30 35 40 45 50 0 2,000 4,000 6,000 8,000 10,000 12,000 14,000 16,000 18,000 0 50,000 100,000 150,000 200,000 250,000 300,000 350,000 400,000 450,000 500,000 Bandwidth (mB/s) Latency (us) Length (b) Performance of gbps link with 10 ms startup Half-power x = 1,250,000 bytes! Length (x)
  • 11. Lec 19.11 4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022 What Determines Peak BW for I/O? • Bus Speed – PCI-X: 1064 MB/s = 133 MHz x 64 bit (per lane) – ULTRA WIDE SCSI: 40 MB/s – Serial Attached SCSI & Serial ATA & IEEE 1394 (firewire): 1.6 Gb/s full duplex (200 MB/s) – USB 3.0 – 5 Gb/s – Thunderbolt 3 – 40 Gb/s • Device Transfer Bandwidth – Rotational speed of disk – Write / Read rate of NAND flash – Signaling rate of network link • Whatever is the bottleneck in the path…
  • 12. Lec 19.12 4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022 Sequential Server Performance • Single sequential “server” that can deliver a task in time 𝐿 operates at rate ≤ 1 𝐿 (on average, in steady state, …) – 𝐿 = 10 ms → 𝐵 = 100 op s – 𝐿 = 2 yr → 𝐵 = 0.5 op yr • Applies to a processor, a disk drive, a person, a TA, … L L L L … time L
  • 13. Lec 19.13 4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022 Single Pipelined Server • Single pipelined server of 𝑘 stages for tasks of length 𝐿 (i.e., time 𝐿 𝑘 per stage) delivers at rate ≤ 𝑘 𝐿. – 𝐿 = 10 ms, 𝑘 = 4 → 𝐵 = 400 op s – 𝐿 = 2 yr, 𝑘 = 2 → 𝐵 = 1 op yr L … L L L L L L L L logical operation divided over distinct resources time
  • 14. Lec 19.14 4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022 Example Systems “Pipelines” • Anything with queues between operational process behaves roughly “pipeline like” • Important difference is that “initiations” are decoupled from processing – May have to queue up a burst of operations – Not synchronous and deterministic like in 61C User Process syscall File System Upper Driver Lower Driver I/O Processing Communication
  • 15. Lec 19.15 4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022 Multiple Servers • 𝑘 servers handling tasks of length 𝐿 delivers at rate ≤ 𝑘 𝐿. – 𝐿 = 10 ms, 𝑘 = 4 → 𝐵 = 400 op s – 𝐿 = 2 yr, 𝑘 = 2 → 𝐵 = 1 op yr • In 61C you saw multiple processors (cores) – Systems present lots of multiple parallel servers – Often with lots of queues L … k
  • 16. Lec 19.16 4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022 Example Systems “Parallelism” User Process syscall File System Upper Driver Lower Driver I/O Processing Communication User Process User Process Parallel Computation, Databases, …
  • 17. Lec 19.17 4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022 I/O Performance Response Time = Queue + I/O device service time User Thread Queue [OS Paths] Controller I/O device • Performance of I/O subsystem – Metrics: Response Time, Throughput – Effective BW per op = transfer size / response time » EffBW(n) = n / (S + n/B) = B / (1 + SB/n ) 100% Response Time (ms) Throughput (Utilization) (% total BW) 0 100 200 300 0% # of ops Fixed overhead time per op
  • 18. Lec 19.18 4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022 I/O Performance Response Time = Queue + I/O device service time User Thread Queue [OS Paths] Controller I/O device • Performance of I/O subsystem – Metrics: Response Time, Throughput – Effective BW per op = transfer size / response time » EffBW(n) = n / (S + n/B) = B / (1 + SB/n ) – Contributing factors to latency: » Software paths (can be loosely modeled by a queue) » Hardware controller » I/O device service time • Queuing behavior: – Can lead to big increases of latency as utilization increases – Solutions? 100% Response Time (ms) Throughput (Utilization) (% total BW) 0 100 200 300 0%
  • 19. Lec 19.19 4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022 A Simple Deterministic World • Assume requests arrive at regular intervals, take a fixed time to process, with plenty of time between … • Service rate (μ = 1/TS) - operations per second • Arrival rate: (λ = 1/TA) - requests per second • Utilization: U = λ/μ , where λ < μ • Average rate is the complete story Queue Server arrivals departures TQ TS TA TA TA TS Tq
  • 20. Lec 19.20 4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022 A Ideal Linear World • What does the queue wait time look like? – Grows unbounded at a rate ~ (Ts/TA) till request rate subsides Offered Load (TS/TA) Delivered Throughput 0 1 1 time Queue delay Delivered Throughput 0 1 1 Offered Load (TS/TA) Empty Queue Saturation Unbounded time Queue delay
  • 21. Lec 19.21 4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022 A Bursty World • Requests arrive in a burst, must queue up till served • Same average arrival time, but almost all of the requests experience large queue delays • Even though average utilization is low Queue Server arrivals departures TQ TS Q depth Server Arrivals
  • 22. Lec 19.22 4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022 • Elegant mathematical framework if you start with exponential distribution – Probability density function of a continuous random variable with a mean of 1/λ – f(x) = λe-λx – “Memoryless” 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 0 2 4 6 8 10 Likelihood of an event occurring is independent of how long we’ve been waiting So how do we model the burstiness of arrival? Lots of short arrival intervals (i.e., high instantaneous rate) Few long gaps (i.e., low instantaneous rate) x (λ) mean arrival interval (1/λ)
  • 23. Lec 19.23 4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022 Background: General Use of Random Distributions • Server spends variable time (T) with customers – Mean (Average) m = p(T)T – Variance (stddev2) 2 = p(T)(T-m)2 = p(T)T2-m2 – Squared coefficient of variance: C = 2/m2 Aggregate description of the distribution • Important values of C: – No variance or deterministic  C=0 – “Memoryless” or exponential  C=1 » Past tells nothing about future » Poisson process – purely or completely random process » Many complex systems (or aggregates) are well described as memoryless – Disk response times C  1.5 (majority seeks < average) Mean (m) mean Memoryless Distribution of service times 
  • 24. Lec 19.24 4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022 Departures Arrivals Queuing System Introduction to Queuing Theory • What about queuing time?? – Let’s apply some queuing theory – Queuing Theory applies to long term, steady state behavior  Arrival rate = Departure rate • Arrivals characterized by some probabilistic distribution • Departures characterized by some probabilistic distribution Queue Controller Disk
  • 25. Lec 19.25 4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022 Little’s Law • In any stable system – Average arrival rate = Average departure rate • The average number of jobs/tasks in the system (N) is equal to arrival time / throughput (λ) times the response time (L) – N (jobs) = λ (jobs/s) x L (s) • Regardless of structure, bursts of requests, variation in service – Instantaneous variations, but it washes out in the average – Overall, requests match departures arrivals departures N λ L
  • 26. Lec 19.26 4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022 Example λ = 1 L = 5 0 1 2 3 4 5 6 7 8 16 9 10 11 12 13 14 15 time Jobs L = 5 N = 5 jobs A: N = λ x L • E.g., N = λ x L = 5
  • 27. Lec 19.27 4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022 Little’s Theorem: Proof Sketch time T arrivals departures N λ L N(t) L(i) = response time of job i N(t) = number of jobs in system at time t Job i L(1)
  • 28. Lec 19.28 4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022 Little’s Theorem: Proof Sketch time T arrivals departures N λ L N(t) L(i) = response time of job i N(t) = number of jobs in system at time t What is the system occupancy, i.e., average number of jobs in the system? Job i
  • 29. Lec 19.29 4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022 Little’s Theorem: Proof Sketch time T arrivals departures N λ L N(t) L(i) = response time of job i N(t) = number of jobs in system at time t S(i) = L(i) * 1 = L(i) Job i S(1) S(2) S = S(1) + S(2) + … + S(k) = L(1) + L(2) + … + L(k) S(k)
  • 30. Lec 19.30 4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022 Little’s Theorem: Proof Sketch time T arrivals departures N λ L N(t) L(i) = response time of job i N(t) = number of jobs in system at time t S(i) = L(i) * 1 = L(i) Average occupancy (Navg) = S/T Job i S= area
  • 31. Lec 19.31 4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022 Little’s Theorem: Proof Sketch time T arrivals departures N λ L N(t) L(i) = response time of job i N(t) = number of jobs in system at time t S(i) = L(i) * 1 = L(i) Job i S(1) S(2) Navg = S/T = (L(1) + … + L(k))/T S(k)
  • 32. Lec 19.32 4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022 Little’s Theorem: Proof Sketch time T arrivals departures N λ L N(t) L(i) = response time of job i N(t) = number of jobs in system at time t S(i) = L(i) * 1 = L(i) Job i S(1) S(2) Navg = (L(1) + … + L(k))/T = (Ntotal/T)*(L(1) + … + L(k))/Ntotal S(k)
  • 33. Lec 19.33 4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022 Little’s Theorem: Proof Sketch time T arrivals departures N λ L N(t) L(i) = response time of job i N(t) = number of jobs in system at time t S(i) = L(i) * 1 = L(i) Job i S(1) S(2) Navg = (Ntotal/T)*(L(1) + … + L(k))/Ntotal = λavg × Lavg S(k)
  • 34. Lec 19.34 4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022 Little’s Theorem: Proof Sketch time T arrivals departures N λ L N(t) L(i) = response time of job i N(t) = number of jobs in system at time t S(i) = L(i) * 1 = L(i) Job i S(1) S(2) Navg = λavg × Lavg S(k)
  • 35. Lec 19.35 4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022 Little’s Law Applied to a Queue • When Little’s Law applied to a queue, we get: Average length of the queue Average Arrival Rate Average time “waiting” in queue 𝐿𝑄 = 𝜆𝑇𝑄
  • 36. Lec 19.36 4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022 A Little Queuing Theory: Computing TQ • Assumptions: – System in equilibrium; No limit to the queue – Time between successive arrivals is random and memoryless • Parameters that describe our system: – : mean number of arriving customers/second – Tser: mean time to service a customer (“m1”) – C: squared coefficient of variance = 2/m12 – μ: service rate = 1/Tser – u: server utilization (0u1): u = /μ =   Tser • Results: – Memoryless service distribution (C = 1): (an “M/M/1 queue”): » Tq = Tser x u/(1 – u) – General service distribution, 1 server (an “M/G/1 queue”): » Tq = Tser x ½(1+C) x u/(1 – u) Arrival Rate  Queue Server Service Rate μ=1/Tser Why does response/queueing delay grow unboundedly even though the utilization is < 1 ? 100% Response Time (ms) Throughput (Utilization) (% total BW) 0 100 200 300 0%
  • 37. Lec 19.37 4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022 System Performance In presence of a Queue Request Rate ( 𝜆 ) - “offered load” Service Rate (𝜇) - “delivered load” 𝜇𝑚𝑎𝑥 𝜇𝑚𝑎𝑥 Latency (𝜆) Operation Time Time “Half-Power Point” : load at which system delivers half of peak performance - Design and provision systems to operate roughly in this regime - Latency low and predictable, utilization good: ~50% • 𝑇𝑄~ 𝑢 1−𝑢 , u = 𝜆 𝜇𝑚𝑎𝑥 • Why does latency blow up as we approach 100% utilization? • Queue builds up on each burst • But very rarely (or never) gets a chance to drain
  • 38. Lec 19.38 4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022 Why unbounded response time? • Assume deterministic arrival process and service time – Possible to sustain utilization = 1 with bounded response time! time arrival time service time
  • 39. Lec 19.39 4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022 Why unbounded response time? • Assume stochastic arrival process (and service time) – No longer possible to achieve utilization = 1 100% Response Time (ms) Throughput (Utilization) (% total BW) 0 100 200 300 0% time This wasted time can never be reclaimed! So cannot achieve u = 1!
  • 40. Lec 19.40 4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022 A Little Queuing Theory: An Example • Example Usage Statistics: – User requests 10 x 8KB disk I/Os per second – Requests & service exponentially distributed (C=1.0) – Avg. service = 20 ms (From controller+seek+rot+trans) • Questions: – How utilized is the disk? » Ans: server utilization, u = Tser – What is the average time spent in the queue? » Ans: Tq – What is the number of requests in the queue? » Ans: Lq – What is the avg response time for disk request? » Ans: Tsys = Tq + Tser • Computation:  (avg # arriving customers/s) = 10/s Tser (avg time to service customer) = 20 ms (0.02s) u (server utilization) =  x Tser= 10/s x .02s = 0.2 Tq (avg time/customer in queue) = Tser x u/(1 – u) = 20 x 0.2/(1-0.2) = 20 x 0.25 = 5 ms (0 .005s) Lq (avg length of queue) =  x Tq=10/s x .005s = 0.05 Tsys (avg time/customer in system) =Tq + Tser= 25 ms
  • 41. Lec 19.41 4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022 Queuing Theory Resources • Resources page contains Queueing Theory Resources (under Readings): – Scanned pages from Patterson and Hennessy book that gives further discussion and simple proof for general equation: https://cs162.eecs.berkeley.edu/static/readings/patterson_queue.pdf – A complete website full of resources: http://web2.uwindsor.ca/math/hlynka/qonline.html • Some previous midterms with queueing theory questions • Assume that Queueing Theory is fair game for Midterm III!
  • 42. Lec 19.42 4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022 Optimize I/O Performance • How to improve performance? – Make everything faster  – More Decoupled (Parallelism) systems » multiple independent buses or controllers – Optimize the bottleneck to increase service rate » Use the queue to optimize the service – Do other useful work while waiting • Queues absorb bursts and smooth the flow • Admissions control (finite queues) – Limits delays, but may introduce unfairness and livelock Response Time = Queue + I/O device service time User Thread Queue [OS Paths] Controller I/O device 100% Response Time (ms) Throughput (Utilization) (% total BW) 0 100 200 300 0%
  • 43. Lec 19.43 4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022 When is Disk Performance Highest? • When there are big sequential reads, or • When there is so much work to do that they can be piggy backed (reordering queues—one moment) • OK to be inefficient when things are mostly idle • Bursts are both a threat and an opportunity • <your idea for optimization goes here> – Waste space for speed? • Other techniques: – Reduce overhead through user level drivers – Reduce the impact of I/O delays by doing other useful work in the meantime
  • 44. Lec 19.44 4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022 Disk Scheduling (1/3) • Disk can do only one request at a time; What order do you choose to do queued requests? • FIFO Order – Fair among requesters, but order of arrival may be to random spots on the disk  Very long seeks • SSTF: Shortest seek time first – Pick the request that’s closest on the disk – Although called SSTF, today must include rotational delay in calculation, since rotation can be as long as seek – Con: SSTF good at reducing seeks, but may lead to starvation 2,3 2,1 3,10 7,2 5,2 2,2 Head User Requests 1 4 2 Disk Head 3
  • 45. Lec 19.45 4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022 Disk Scheduling (2/3) • Disk can do only one request at a time; What order do you choose to do queued requests? • SCAN: Implements an Elevator Algorithm: take the closest request in the direction of travel – No starvation, but retains flavor of SSTF 2,3 2,1 3,10 7,2 5,2 2,2 Head User Requests
  • 46. Lec 19.46 4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022 Disk Scheduling (3/3) • Disk can do only one request at a time; What order do you choose to do queued requests? • C-SCAN: Circular-Scan: only goes in one direction – Skips any requests on the way back – Fairer than SCAN, not biased towards pages in middle 2,3 2,1 3,10 7,2 5,2 2,2 Head User Requests
  • 47. Lec 19.47 4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022 Recall: How do we Hide I/O Latency? • Blocking Interface: “Wait” – When request data (e.g., read() system call), put process to sleep until data is ready – When write data (e.g., write() system call), put process to sleep until device is ready for data • Non-blocking Interface: “Don’t Wait” – Returns quickly from read or write request with count of bytes successfully transferred to kernel – Read may return nothing, write may write nothing • Asynchronous Interface: “Tell Me Later” – When requesting data, take pointer to user’s buffer, return immediately; later kernel fills buffer and notifies user – When sending data, take pointer to user’s buffer, return immediately; later kernel takes data and notifies user
  • 48. Lec 19.48 4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022 Recall: I/O and Storage Layers High Level I/O Low Level I/O Syscall File System I/O Driver Application / Service Streams File Descriptors open(), read(), write(), close(), … Files/Directories/Indexes Commands and Data Transfers Disks, Flash, Controllers, DMA What we covered in Lecture 4 Open File Descriptions What we just covered… What we will cover next…
  • 49. Lec 19.49 4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022 From Storage to File Systems I/O API and syscalls Variable-Size Buffer File System Block Logical Index, Typically 4 KB Hardware Devices Memory Address HDD Sector(s) Physical Index, 512B or 4KB SSD Flash Trans. Layer Phys. Block Phys Index., 4KB Sector(s) Sector(s) Erasure Page
  • 50. Lec 19.50 4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022 Building a File System • File System: Layer of OS that transforms block interface of disks (or other block devices) into Files, Directories, etc. • Classic OS situation: Take limited hardware interface (array of blocks) and provide a more convenient/useful interface with: – Naming: Find file by name, not block numbers – Organize file names with directories – Organization: Map files to blocks – Protection: Enforce access restrictions – Reliability: Keep files intact despite crashes, hardware failures, etc.
  • 51. Lec 19.51 4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022 Recall: User vs. System View of a File • User’s view: – Durable Data Structures • System’s view (system call interface): – Collection of Bytes (UNIX) – Doesn’t matter to system what kind of data structures you want to store on disk! • System’s view (inside OS): – Collection of blocks (a block is a logical transfer unit, while a sector is the physical transfer unit) – Block size  sector size; in UNIX, block size is 4KB
  • 52. Lec 19.52 4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022 Translation from User to System View • What happens if user says: “give me bytes 2 – 12?” – Fetch block corresponding to those bytes – Return just the correct portion of the block • What about writing bytes 2 – 12? – Fetch block, modify relevant portion, write out block • Everything inside file system is in terms of whole-size blocks – Actual disk I/O happens in blocks – read/write smaller than block size needs to translate and buffer File System File (Bytes)
  • 53. Lec 19.53 4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022 Disk Management • Basic entities on a disk: – File: user-visible group of blocks arranged sequentially in logical space – Directory: user-visible index mapping names to files • The disk is accessed as linear array of sectors • How to identify a sector? –Physical position » Sectors is a vector [cylinder, surface, sector] » Not used anymore » OS/BIOS must deal with bad sectors –Logical Block Addressing (LBA) » Every sector has integer address » Controller translates from address  physical position » Shields OS from structure of disk
  • 54. Lec 19.54 4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022 What Does the File System Need? • Track free disk blocks –Need to know where to put newly written data • Track which blocks contain data for which files –Need to know where to read a file from • Track files in a directory –Find list of file's blocks given its name • Where do we maintain all of this? –Somewhere on disk
  • 55. Lec 19.55 4/5/2022 Joseph & Kubiatowicz CS162 © UCB Spring 2022 Conclusion • Disk Performance: – Queuing time + Controller + Seek + Rotational + Transfer – Rotational latency: on average ½ rotation – Transfer time: spec of disk depends on rotation speed and bit storage density • Devices have complex interaction and performance characteristics – Response time (Latency) = Queue + Overhead + Transfer » Effective BW = BW * T/(S+T) – HDD: Queuing time + controller + seek + rotation + transfer – SDD: Queuing time + controller + transfer (erasure & wear) • Systems (e.g., file system) designed to optimize performance and reliability – Relative to performance characteristics of underlying device • Bursts & High Utilization introduce queuing delays • Queuing Latency: – M/M/1 and M/G/1 queues: simplest to analyze – As utilization approaches 100%, latency   Tq = Tser x ½(1+C) x u/(1 – u))