Presentation is loading. Please wait.

Presentation is loading. Please wait.

Tom Cargill 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.

Similar presentations


Presentation on theme: "Tom Cargill 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."— Presentation transcript:

1 Tom Cargill 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.

2 Computer Science 313 – Advanced Programming Topics

3 Tom Cargill 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.

4 Let’s Get Coding  Who will write next lab in assembly?  Write entire program in assembly  Apply standard optimizations for first pass  Finally, hand tune every method & every class  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)

5  Programs just λ-calculus equations  Can use this to prove program correct  Translate program into λ-calculus  Specify and prove program correctness theorem  What if I guarantee student an A? Promise of Perfect Debugging

6 Why Isn’t This Done?  Almost never use these techniques  Even device drivers not entirely in assembly  Rare to develop even partial proof of correctness  Perform a cost-benefit analysis  Techniques requires massive amounts of time  Time is money; these are very, very expensive  Simply not worth the benefits provided

7 What’s The Secret? How do I know when to optimize? I need to know. Please, please, please?

8 Problem is Universal  Making optimal decisions occurs frequently  Using reagents during chemical synthesis  When to perform maintenance on power plant  Which ski lift line will be fastest  Cannot optimize everything  Must focus on where it matters most But how can I know what is important?

9 Are Graphics Important?  Rewrite Swing to improve its performance? Hells, yes. We need the 30 fps gamers demand. Hells, no. What does it do for search speed?

10 Critical Paths  Only consider code along critical path  Process which determines time required  Graphics are not critical for Google  Could dramatically improve graphics…  …but would not effect how long search takes  Bungie’s critical path is graphics package  Graphics limits program performance  No impact from improvements to file searching

11 Guess the Critical Path $ java -Xprof edu.canisius.ann.Network Flat profile of 16.4 secs (956 total ticks): main Compiled + native Method 35.6% 282 + 58 Neuron.getWeightedError 21.1% 187 + 15 Neuron.updateWeights 13.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. 0.8% 8 + 0 Network.main 99.6% 748 + 204 Total compiled

12 Still a Cost-Benefit Trade Great. More useless geekery. When will it make a difference? When is it worth my time?

13 Amdahl’s Law  Determines how much faster program can go  Can finally answer the question that matters  Equation’s result is program speedup  Speedup of 2 when program twice as fast  Program runs in 1 / 10 the time, then speedup is 10  Execution time unchanged with speedup of 1  Needs twice as long when speedup is ½

14 Amdahl’s Law Equation

15 Applying Amdahl’s Law  Made getWeightedError twice as fast  Speedup changed = 2, since now twice as fast  Took 16.4 seconds before, what will it take now?  Get execution times from java –Xprof 35.6% 282 + 58 Neuron.getWeightedError %changed = 0.356 %unchanged = 1 - 0.356 = 0.644

16 Amdahl’s Law Speedup = 1.21

17 Applying Amdahl’s Law  Move Neuron.compute off critical path?  Removes it from program execution time  Speedup changed = ∞  Get execution times from java –Xprof 9.5% 91 + 0 Neuron.compute %changed = 0.095 %unchanged = 1 - 0.095 = 0.905

18 Amdahl’s Law Speedup = 1.10

19 For Next Class  Lab #4 on web/Angel & due before next lab  Midterm #1 in class on Monday  Will be open-note, open-book, & open-reports  But closed-friend, closed-slide, & closed-activity  Most questions resemble in-class activities  Could also ask to implement design pattern  Use design patterns to develop solution to sample problem

20 Midterm Preparation  When/where to use a design pattern  Determine pattern used by real-world example  Understand what the design principles mean  Explain how a design pattern follows a principle  Convert method to be tail recursive  Make tail recursive method iterative  Use Stack to eliminate recursion from method  Compute speedup using Amdahl’s law  Use speedup to determine new execution time


Download ppt "Tom Cargill 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."

Similar presentations


Ads by Google