A Case of Performance Tuning In a semi-realistic desktop app.

Slides:



Advertisements
Similar presentations
A Short Review Arrays, Pointers and Structures. What is an Array? An array is a collection of variables of the same type and placed in memory contiguously.
Advertisements

Section 10.2: Tests of Significance
If you are viewing this slideshow within a browser window, select File/Save as… from the toolbar and save the slideshow to your computer, then open it.
Experimental Probability.
CHAPTER 11: Sampling Distributions
Design Project (Last updated: Nov. 22/2010) Change since August 31: added the notes to the presentation in the next slide.
An Introduction to Matching and Layout Alan Hastings Texas Instruments
Hashing.
1 CS533 Modeling and Performance Evaluation of Network and Computer Systems Capacity Planning and Benchmarking (Chapter 9)
CHAPTER 14: Confidence Intervals: The Basics
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 18 Sampling Distribution Models.
Data Mining Methodology 1. Why have a Methodology  Don’t want to learn things that aren’t true May not represent any underlying reality ○ Spurious correlation.
Agile Planning. The problem with documentation Argument: “Heavy” documentation too much for most business-style projects.
Chapter 18 Sampling Distribution Models
Simulation Where real stuff starts. ToC 1.What, transience, stationarity 2.How, discrete event, recurrence 3.Accuracy of output 4.Monte Carlo 5.Random.
1 Chapter 9 Maps and Dictionaries. 2 A basic problem We have to store some records and perform the following: add new record add new record delete record.
Three kinds of learning
Copyright © 2008 Pearson Addison-Wesley. All rights reserved. Chapter 9 Pointers and Dynamic Arrays.
Pointers and Dynamic Variables. Objectives on completion of this topic, students should be able to: Correctly allocate data dynamically * Use the new.
Xtreme Programming. Software Life Cycle The activities that take place between the time software program is first conceived and the time it is finally.
INFERENTIAL STATISTICS – Samples are only estimates of the population – Sample statistics will be slightly off from the true values of its population’s.
Answering questions about life with statistics ! The results of many investigations in biology are collected as numbers known as _____________________.
Introduction to Statistical Inferences
Chocolate Bar! luqili. Milestone 3 Speed 11% of final mark 7%: path quality and speed –Some cleverness required for full marks –Implement some A* techniques.
Simulation II IE 2030 Lecture 18. Outline: Simulation II Advanced simulation demo Review of concepts from Simulation I How to perform a simulation –concepts:
Review C++ exception handling mechanism Try-throw-catch block How does it work What is exception specification? What if a exception is not caught?
1 Validation & Verification Chapter VALIDATION & VERIFICATION Very Difficult Very Important Conceptually distinct, but performed simultaneously.
Chapter 11 Randomness. Randomness Random outcomes –Tossing coins –Rolling dice –Spinning spinners They must be fair.
Chasing those perfect Hash functions… by DANIEL “3ICE” BEREZVAI ELTE.3ICE.HU/ /ALG2/GY/ALG2 GY 2 HF.
Stochastic Algorithms Some of the fastest known algorithms for certain tasks rely on chance Stochastic/Randomized Algorithms Two common variations – Monte.
Timing Trials An investigation arising out of the Assignment CS32310 – Nov 2013 H Holstein 1.
A Real-time Cargo Damage Management System via a Sorting Array Triangulation (SAT) Technique 1 Philip B. Alipour 2 Matteus Magnusson 3 Martin W. Olsson.
Chapter 1 - Getting to know Greenfoot
Chapter 5 Comparing Two Means or Two Medians
CSE 303 Concepts and Tools for Software Development Richard C. Davis UW CSE – 12/6/2006 Lecture 24 – Profilers.
M ONTE C ARLO SIMULATION Modeling and Simulation CS
Spreadsheet Models for Managers: Session 14 14/1 Copyright © Richard Brenner Spreadsheet Models for Managers Session 14 Using Macros II Function.
CSE 374 Programming Concepts & Tools Hal Perkins Fall 2015 Lecture 11 – gdb and Debugging.
Sampling Distributions Chapter 18. Sampling Distributions A parameter is a measure of the population. This value is typically unknown. (µ, σ, and now.
Recitation 7 Collections. Array List and Linked List Array List and Linked List are implementations of the same interface: List. As a result, they have.
1 the hash table. hash table A hash table consists of two major components …
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 9 Pointers and Dynamic Arrays.
Copyright © 2014 Pearson Addison-Wesley. All rights reserved. Chapter 9 Pointers and Dynamic Arrays.
Onlinedeeneislam.blogspot.com1 Design and Analysis of Algorithms Slide # 1 Download From
1 Chapter 11 Understanding Randomness. 2 Why Be Random? What is it about chance outcomes being random that makes random selection seem fair? Two things:
Problems with Variance ©2005 Dr. B. C. Paul. Determining What To Do We have looked at techniques that depend on normally distributed data with variance.
Simulation. Types of simulation Discrete-event simulation – Used for modeling of a system as it evolves over time by a representation in which the state.
Copyright © 2009 Pearson Education, Inc. Chapter 11 Understanding Randomness.
Get your software working before putting it on the robot!
Sampling Distributions Chapter 18. Sampling Distributions A parameter is a number that describes the population. In statistical practice, the value of.
World of Wokcraft The very best in Single pan cooking themed fantasy gaming!
Sampling Distributions – Sample Means & Sample Proportions
Mobile Testing - Bug Report
Measuring Where CPU Time Goes
Part III – Gathering Data
1. Welcome to Software Construction
While Loops in Python.
Sampling Distribution Models
LESSON 12 - Loops and Simulations
CSC 143 Queues [Chapter 7].
Reasoning in Psychology Using Statistics
Using Significance Tests
Ch13 Empirical Methods.
Suppose I want to add all the even integers from 1 to 100 (inclusive)
Reasoning in Psychology Using Statistics
Min Heap Update E.g. remove smallest item 1. Pop off top (smallest) 3
Data Structures & Algorithms
While Loops in Python.
Software Development Techniques
Presentation transcript:

A Case of Performance Tuning In a semi-realistic desktop app.

The Application: Simulation of a Computer-Integrated-Manufacturing (CIM) System. There are thousands of Jobs. Each Job consists of several Operations. Each Operation consists of several Tasks (such as machining) and several Material Handling steps (transporting the workpiece).

Objective: Speed up the simulation. Method: Random Pausing, over multiple iterations. Result: 2-3 Orders of Magnitude Speedup The method: 1.Run the program with enough workload so it can be paused. 2.Pause the program 3.Understand what it is doing at that point in time, including examining the call stack 4.Repeat 1-3 enough times (typically 3 to 20) to see things that could be changed to save time.

How is it different from Profiling? - Precision of Measurement (of time spent in routines or even lines of code) is less important. - Precision of Understanding what is happening is more important. Example: An activity of some description, that could be avoided, is seen on 3 out of 5 samples, in different functions. If it could be removed, a mean savings of roughly (3+1)/(5+2) could be achieved. (Rule of Succession). Since the activity is not localized to a particular function, let alone a particular line of code, a summarizing profiler is less likely to draw attention to it. - Stack-sampling profilers collect, summarize, and then discard, the information you need without letting you see it, on the assumption that statistics are more important. Other kinds of profilers dont even collect it.

So the Scenario Follows Starting with running and sampling the first iteration of the program.

Result: Time goes from 2700 usec down to 1800 usec / job Now take more samples:

Result: 1500 usec/job Take more samples. Heres what I see: Conclusions: (out of 10) 3 delete 2 new 2 Add 1 RemoveAt 1 cout 1 my code Not sure what to do next. I could make do-it-yourself arrays to help with the Add & RemoveAt time, or maybe form the objects into linked lists, because I'm not really accessing them randomly. I could harvest used objects & not spend so much time in new and delete. Decision: Make linked-lists, and pool used objects.

Results: After putting in linked-lists: 1300 usec/job After pooling used objects: 440 usec/job ! Take more samples. See: samples, 3 in NTH, 1 in cout, 1 in entering a routine (NTH is a macro for indexing a linked list.) Suggests: Use pointer directly into list, rather than integer index.

Result: After using pointer into list: 170 usec/job - Take more samples. Out of 4 samples, every sample is in cout. Suppress the output. Result: After suppressing output: 3.7 usec/job Thats a total speedup of 2700/3.7 = 730 times !

How is this speedup possible? % in push_back % in out-of-line indexing % in add/remove % in new/delete % in getting Nth list element % in cout > 99% in activities that could be removed!

Common Objection: Too Few Samples! Answer: You Dont Need Them! The cost (i.e. potential savings) x is a distribution x ~ beta( hits + 1, N – hits + 1) Precision depends on N, but expected savings varies little. Notice the Speedup Ratio 1/(1-x) is heavily right-skewed. An incorrect estimate carries little downside risk with high upside benefit.

What NOT to Learn From This Each iteration consisted of Two Phases –A : Diagnosis, via random pausing –B : Intervention, to get the speedup Whats the important thing to learn? The important thing to learn is that A is more important than B. So many times I see people skip A and go directly to B, and get little or no speedup.

Conclusion Random-Pausing should be in every programmers toolkit.