+ All Categories
Home > Documents > Lecture 5: 90-10 Rule

Lecture 5: 90-10 Rule

Date post: 14-Feb-2016
Category:
Upload: alessa
View: 34 times
Download: 1 times
Share this document with a friend
Description:
Computer Science 313 – Advanced Programming Topics. Lecture 5: 90-10 Rule. The first 90% of the code accounts for the first 90% of the development time . The remaining 10% of the code accounts for the other 90% of the development time. Tom Cargill. Let’s Get Coding. - PowerPoint PPT Presentation
Popular Tags:
29
LECTURE 5: 90-10 RULE Computer Science 313 – Advanced Programming Topics
Transcript
Page 1: Lecture 5: 90-10 Rule

LECTURE 5:90-10 RULE

Computer Science 313 – Advanced Programming Topics

Page 2: Lecture 5: 90-10 Rule

Tom Cargill

The first 90% of the code accounts

for thefirst 90% of the

development time. The

remaining 10% of the code

accounts for the other 90% of the

development time.

Page 3: Lecture 5: 90-10 Rule

Let’s Get Coding

Who will write next lab in assembly? Can only use assembly code for entire lab

pushl %ebp movl %esp, %ebp subl $24, %esp movl 8(%ebp), %eax movl %eax, -4(%ebp) cmpl $0, -4(%ebp)

Page 4: Lecture 5: 90-10 Rule

Let’s Get Coding

Who will write next lab in assembly? Can only use assembly code for entire lab

During the first pass, apply standard optimizations

pushl %ebp movl %esp, %ebp subl $24, %esp movl 8(%ebp), %eax movl %eax, -4(%ebp) cmpl $0, -4(%ebp)

Page 5: Lecture 5: 90-10 Rule

Let’s Get Coding

Who will write next lab in assembly? Can only use assembly code for entire lab

During the first pass, apply standard optimizations

Every method should be tuned to maximize branches

pushl %ebp movl %esp, %ebp subl $24, %esp movl 8(%ebp), %eax movl %eax, -4(%ebp) cmpl $0, -4(%ebp)

Page 6: Lecture 5: 90-10 Rule

Let’s Get Coding

Who will write next lab in assembly? Can only use assembly code for entire lab

During the first pass, apply standard optimizations

Every method should be tuned to maximize branches

Necessary to achieve top performance

pushl %ebp movl %esp, %ebp subl $24, %esp movl 8(%ebp), %eax movl %eax, -4(%ebp) cmpl $0, -4(%ebp)

Page 7: Lecture 5: 90-10 Rule

Promise of Perfect Debugging Programs just λ-calculus equations Use Java, but instead prove program

correct Translate program into λ-calculus Specify theorem & prove program

correctness

Page 8: Lecture 5: 90-10 Rule

Fewest Lectures Ever

What if guaranteed A for student doing this? Would still need to submit assignment

on time Working assembly needed (with

optimizations) Code should work, but proof must be

perfect

Any takers?

Page 9: Lecture 5: 90-10 Rule

Fewest Lectures Ever

What if guaranteed A for student doing this? Would still need to submit assignment

on time Working assembly needed (with

optimizations) Code should work, but proof must be

perfect

Any takers? Why not?

Page 10: Lecture 5: 90-10 Rule

Why Isn’t This Done?

Almost never use these techniques Low-level device drivers use some C (or

similar) Rare for partial proof of correctness to

be used Simple result from easy cost-benefit

analysis Techniques requires massive amounts of

time Time is money; these are very, very

expensive The provided benefits just not worth it

Page 11: Lecture 5: 90-10 Rule

What’s The Secret?How do I know

when to optimize? I

need to know. Please, please,

please?

Page 12: Lecture 5: 90-10 Rule

Problem is Universal

Frequent need to make optimal decision Using reagents during chemical

synthesis Take power plant offline & perform

maintenance Fastest torrent from which to download

Cannot optimize everything Instead we only focus efforts where it

matters

Page 13: Lecture 5: 90-10 Rule

Problem is Universal

Frequent need to make optimal decision Using reagents during chemical

synthesis Take power plant offline & perform

maintenance Fastest torrent from which to download

Cannot optimize everything Instead we only focus efforts where it

matters

But how can I know what is important?

Page 14: Lecture 5: 90-10 Rule

Are Graphics Important?

Rewrite Swing to improve its performance?

Page 15: Lecture 5: 90-10 Rule

Are Graphics Important?

Rewrite Swing to improve its performance? Hells, yes. We

need 60 fps for new games.

Page 16: Lecture 5: 90-10 Rule

Are Graphics Important?

Rewrite Swing to improve its performance? Hells, yes. We

need 60 fps for new games.

%#$ no. What does it do for search speed?

Page 17: Lecture 5: 90-10 Rule

Critical Paths

All that is important is code along critical path Determines time needed and not just

the fluff Graphics are not critical for Google

Major graphics improvements are nice… …but have zero affect on search times

Bungie’s critical path is graphics package Games performance limited by graphic

times Would hate GPU for search – slows them

down

Page 18: Lecture 5: 90-10 Rule

Guess the Critical Path

$ java -Xprof edu.canisius.ann.NetworkFlat profile of 16.4 secs (956 total ticks): main Compiled + native Method35.6% 282 + 58 Neuron.getWeightedError21.1% 187 + 15 Neuron.updateWeights13.0% 124 + 0 Network.trainNetwork 9.5% 0 + 91 java.lang.StrictMath.exp 9.5% 91 + 0 Neuron.compute 4.5% 22 + 21 Network.setNetworkInput 3.6% 34 + 0 Network.runOneInput 2.0% 0 + 19 java.util.ArrayList.<init> 0.8% 8 + 0 Network.main99.6% 748 + 204 Total compiled

Page 19: Lecture 5: 90-10 Rule

Still a Cost-Benefit Trade

Great. More useless geekery.

When will it make a difference?

When is it worth my time?

Page 20: Lecture 5: 90-10 Rule

Amdahl’s Law

Determines how much faster program can go Use this to answer question that matters

Speedup calculated by this equation Speedup of 2 means program twice as

fast Need 1/10 the time, 10 is speedup factor of

approach When speedup is 1, time taken

unchanged Speedup of ½ == twice as long as past

approach

Page 21: Lecture 5: 90-10 Rule

Amdahl’s Law

Determines how much faster program can go Use this to answer question that matters

Speedup calculated by this equation Speedup of 2 means program twice as

fast Need 1/10 the time, 10 is speedup factor of

approach When speedup is 1, time taken

unchanged Speedup of ½ == twice as long as past

approach(But usually say slowdown factor of 2)

Page 22: Lecture 5: 90-10 Rule

Amdahl’s Law

Determines how much faster program can go Use this to answer question that matters

Speedup calculated by this equation Speedup of 2 means program twice as

fast Need 1/10 the time, 10 is speedup factor of

approach When speedup is 1, time taken

unchanged Speedup of ½ == twice as long as past

approach(But usually say slowdown factor of 2)(Or hide report that shows this sucks)

Page 23: Lecture 5: 90-10 Rule

Amdahl’s Law Equation

%changed of time in methods to be optimized Expressed as decimal between 0 - 1

All other time from run is %unchanged Another decimal from 0 – 1

If %changed + %unchanged ≠ 1, you FAIL

Page 24: Lecture 5: 90-10 Rule

Applying Amdahl’s Law

Made getWeightedError twice as fast Speedupchanged = 2, since now twice as fast Took 16.4 seconds before, what will it take

now?

Get execution times using java –Xprof

35.6% 282 + 58 Neuron.getWeightedError

%changed = 0.356%unchanged= 1 - 0.356 =

0.644

Page 25: Lecture 5: 90-10 Rule

Amdahl’s Law

Speedup = 1.21

Page 26: Lecture 5: 90-10 Rule

Applying Amdahl’s Law

Move Neuron.compute off critical path? Removes it from program execution time Speedupchanged = ∞

Get execution times from java –Xprof

9.5% 91 + 0 Neuron.compute

%changed = 0.095%unchanged= 1 - 0.095 =

0.905

Page 27: Lecture 5: 90-10 Rule

Amdahl’s Law

Speedup = 1.10

Page 28: Lecture 5: 90-10 Rule

20%

43%

56%

64%

69%

73%

76%

79%

81%

83%

84%

85%

0%10%20%30%40%50%60%70%80%90%

5%10%25%50%75%90%

%Faster Optimized Section Runs

Ove

rall

Redu

ctio

n In

Tim

eWhat Amdahl’s Law Means

Page 29: Lecture 5: 90-10 Rule

For Next Class

Lab #2 on web/Angel in 1 hour I will be in lab from 12 - 1 – feel free to

stop by Read pages 37 – 55 in book

Get back into code & design patterns How could we handle 1-to-many

communication? Why not have cycles in UML class

diagram? What is secret to Lindsay Lohan's

success?


Recommended