Computer timings on human scale – Quizz – Quizz - translate to human scale



Computer timings on human scale – Quizz – Quizz - translate to human scale

0 0


human_scale_quizz

Taken from Erik Meijer's talk in "Principles of Reactive programming" at Coursera.org

On Github kleibl / human_scale_quizz

Computer timings on human scale

Quizz

Taken from Erik Meijer's talk in "Principles of Reactive programming" at Coursera.org

Read and send data

trait Socket { 
 def readFromMemory(): Array[Byte] 
 def sendToEurope(packet: Array[Byte]): Array[Byte] 
} 
 
val socket = Socket() 
val packet = socket.readFromMemory() 
val confirmation = socket.sendToEurope(packet)

Approximate timing for various operations on a typical PC

execute typical instruction 1/1,000,000,000 sec = 1 nanosec fetch from L1 cache memory 0.5 nanosec branch misprediction 5 nanosec fetch from L2 cache memory 7 nanosec Mutex lock/unlock 25 nanosec fetch from main memory 100 nanosec send 2K bytes over 1Gbps network 20,000 nanosec read 1MB sequentially from memory 250,000 nanosec fetch from new disk location (seek) 8,000,000 nanosec read 1MB sequentially from disk 20,000,000 nanosec send packet US to Europe and back 150 milliseconds = 150,000,000 nanosec

© Peter Norvig 2001

Read and send data

trait Socket { 
 def readFromMemory(): Array[Byte] 
 def sendToEurope(packet: Array[Byte]): Array[Byte] 
} 
 
val socket = Socket() 
val packet = socket.readFromMemory() 
// block for 250,000 ns 
// only continue if there is no exception
val confirmation = socket.sendToEurope(packet)
// block for (more than) 150,000,000 ns
// only continue if there is no exception

Translation to human scale

1 nanosecond

->

1 second

(then hours/days/months/years)

Quizz - translate to human scale

1 nanosec -> 1 sec

execute typical instruction 1 nanosec fetch from L1 cache memory 0.5 nanosec branch misprediction 5 nanosec fetch from L2 cache memory 7 nanosec Mutex lock/unlock 25 nanosec fetch from main memory 100 nanosec send 2K bytes over 1Gbps network 20,000 nanosec read 1MB sequentially from memory 250,000 nanosec fetch from new disk location (seek) 8,000,000 nanosec read 1MB sequentially from disk 20,000,000 nanosec send packet US to Europe and back 150 milliseconds = 150,000,000 nanosec

Translation to human scale

1) Execute typical instruction

1 nanosec

->

1 second

Translation to human scale

2) Fetch from L2 cache memory

7 nanosec

->

a) 1 second

b) 17 second

c) 7 second

d) 0.7 second

Translation to human scale

3) Send 2K bytes over 1Gbps network

20,000 nanosec

->

a) 5.5 hours

b) 18 minutes

c) 3 days

d) 1 month

Translation to human scale

4) Read 1MB sequentially from memory

250,000 nanosec

->

a) 1.5 year

b) 19 hours

c) 3 days

d) 7 weeks

Translation to human scale

5) Fetch from new disk location (seek)

8,000,000 nanosec

->

a) 6 days

b) 5 months

c) 13 weeks

d) 3 years

Translation to human scale

6) Read 1MB sequentially from disk

20,000,000 nanosec

->

a) 27 days

b) 6.5 months

c) 9 years

d) 1.5 year

Translation to human scale

7) Send packet US to Europe and back

150 milliseconds = 150,000,000 nanosec

->

a) 5 years

b) 11 months

c) 17 years

d) 3 weeks

And the winner is...

Results

execute typical instruction 1 nanosec 1 sec fetch from L1 cache memory 0.5 nanosec 0.5 sec branch misprediction 5 nanosec 5 sec fetch from L2 cache memory 7 nanosec c) 7 sec Mutex lock/unlock 25 nanosec 0.5 min fetch from main memory 100 nanosec 1.5 min send 2K bytes over 1Gbps network 20,000 nanosec a) 5.5 hours read 1MB sequentially from memory 250,000 nanosec c) 3 days fetch from new disk location (seek) 8,000,000 nanosec c) 13 weeks read 1MB sequentially from disk 20,000,000 nanosec b) 6.5 months send packet US to Europe and back 150 milliseconds a) 5 years

Read and send data

trait Socket { 
 def readFromMemory(): Array[Byte] 
 def sendToEurope(packet: Array[Byte]): Array[Byte] 
} 
 
val socket = Socket() 
val packet = socket.readFromMemory() 
// block for 3 days 
// only continue if there is no exception
val confirmation = socket.sendToEurope(packet)
// block for 5 years
// only continue if there is no exception

Thank you

& have a good time

karol.kleibl@asseco-ce.com