Copyright 2014 – Noah Mendelsohn Performance Analysis Tools Noah Mendelsohn Tufts University Web:

Slides:



Advertisements
Similar presentations
Copyright 2014 – Noah Mendelsohn Performance and Code Tuning Noah Mendelsohn Tufts University Web:
Advertisements

CS1104: Computer Organisation School of Computing National University of Singapore.
Chapter 2 Machine Language.
GNU gprof Profiler Yu Kai Hong Department of Mathematics National Taiwan University July 19, 2008 GNU gprof 1/22.
ICS103 Programming in C Lecture 1: Overview of Computers & Programming
Lecture 1: Overview of Computers & Programming
The Operating System. What is an Operating System? The software which makes it possible for you to use your computer The software which starts up when.
Introduction CSCI 444/544 Operating Systems Fall 2008.
Creating a Program In today’s lesson we will look at: what programming is different types of programs how we create a program installing an IDE to get.
Chapter 2 Machine Language. Machine language The only language a computer can understand directly. Each type of computer has its own unique machine language.
1 Lecture 6 Performance Measurement and Improvement.
Understanding Operating Systems 1 Overview Introduction Operating System Components Machine Hardware Types of Operating Systems Brief History of Operating.
CS 300 – Lecture 19 Intro to Computer Architecture / Assembly Language C Coding & The Simulator Caches.
CS 110 Intro to Computer Science I Sami Rollins Fall 2006.
1 Capstone projects supervised by Yinong Chen (1) Implementation of a Shell on Palm Hand Held Device (2) Building a Programmer’s Interface to the Palm.
Copyright © 1998 Wanda Kunkle Computer Organization 1 Chapter 2.1 Introduction.
Chapter 4 Assessing and Understanding Performance
Performance Improvement
Fall 2001CS 4471 Chapter 2: Performance CS 447 Jason Bakos.
Copyright © 2006 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill Technology Education Copyright © 2006 by The McGraw-Hill Companies,
Performance and Code Tuning Overview CPSC 315 – Programming Studio Fall 2009.
Chapter 9 Overview  Reasons to monitor SQL Server  Performance Monitoring and Tuning  Tools for Monitoring SQL Server  Common Monitoring and Tuning.
1 1 Profiling & Optimization David Geldreich (DREAM)
Copyright 2013 – Noah Mendelsohn Process Memory Noah Mendelsohn Tufts University Web:
P51UST: Unix and Software Tools Unix and Software Tools (P51UST) Compilers, Interpreters and Debuggers Ruibin Bai (Room AB326) Division of Computer Science.
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.
1 Computer Performance: Metrics, Measurement, & Evaluation.
© Janice Regan, CMPT 128, Jan CMPT 128 Introduction to Computing Science for Engineering Students Creating a program.
Offline Performance Monitoring for Linux Abhishek Shukla.
CS 0004 –Lecture 1 Wednesday, Jan 5 th, 2011 Roxana Gheorghiu.
10/19/2015Erkay Savas1 Performance Computer Architecture – CS401 Erkay Savas Sabanci University.
Performance.
CE Operating Systems Lecture 3 Overview of OS functions and structure.
Some Notes on Performance Noah Mendelsohn Tufts University Web: COMP 40: Machine.
Application Profiling Using gprof. What is profiling? Allows you to learn:  where your program is spending its time  what functions called what other.
Introduction Advantages/ disadvantages Code examples Speed Summary Running on the AOD Analysis Platforms 1/11/2007 Andrew Mehta.
CSE 303 Concepts and Tools for Software Development Richard C. Davis UW CSE – 12/6/2006 Lecture 24 – Profilers.
Operating Systems. Overview What is an Operating System (OS) What is an Operating System (OS) What Operating Systems do. What Operating Systems do. Operating.
Debugging and Profiling With some help from Software Carpentry resources.
OSes: 3. OS Structs 1 Operating Systems v Objectives –summarise OSes from several perspectives Certificate Program in Software Development CSE-TC and CSIM,
Timing Programs and Performance Analysis Tools for Analysing and Optimising advanced Simulations.
CS 3500 L Performance l Code Complete 2 – Chapters 25/26 and Chapter 7 of K&P l Compare today to 44 years ago – The Burroughs B1700 – circa 1974.
Adv. UNIX: Profile/151 Advanced UNIX v Objectives –introduce profiling based on execution times and line counts Special Topics in Comp.
Performance Analysis & Code Profiling It’s 2:00AM -- do you know where your program counter is?
System optimisation Unit 11.4A Computer Science Grade 11.
CSE 374 Programming Concepts & Tools Hal Perkins Fall 2015 Lecture 11 – gdb and Debugging.
1 Software. 2 What is software ► Software is the term that we use for all the programs and data on a computer system. ► Two types of software ► Program.
Building Your Own Machine The Universal Machine (UM) Introduction Noah Mendelsohn Tufts University Web:
Performance Tuning John Black CS 425 UNR, Fall 2000.
Copyright 2014 – Noah Mendelsohn Code Tuning Noah Mendelsohn Tufts University Web:
Computer Organization Instruction Set Architecture (ISA) Instruction Set Architecture (ISA), or simply Architecture, of a computer is the.
Lecture 5: 9/10/2002CS170 Fall CS170 Computer Organization and Architecture I Ayman Abdel-Hamid Department of Computer Science Old Dominion University.
Representing Negative Numbers Noah Mendelsohn Tufts University Web: COMP 40: Machine.
EGRE 426 Computer Organization and Design Chapter 4.
Unit 4: Processes, Threads & Deadlocks June 2012 Kaplan University 1.
Chapter Eight Exploring the UNIX Utilities. 2 Lesson A Using the UNIX Utilities.
COMPUTER ARCHITECTURE & OPERATIONS I Instructor: Yaohang Li.
The Universal Machine (UM) Implementing the UM Noah Mendelsohn Tufts University Web:
Introduction to Computer Programming Concepts M. Uyguroğlu R. Uyguroğlu.
OPERATING SYSTEMS DO YOU REQUIRE AN OPERATING SYSTEM IN YOUR SYSTEM?
Introduction to Performance Tuning Chia-heng Tu PAS Lab Summer Workshop 2009 June 30,
Measuring Performance Based on slides by Henri Casanova.
July 10, 2016ISA's, Compilers, and Assembly1 CS232 roadmap In the first 3 quarters of the class, we have covered 1.Understanding the relationship between.
BITS Pilani, Pilani Campus Today’s Agenda Role of Performance.
Computer Architecture & Operations I
Uniprocessor scheduling
CS703 – Advanced Operating Systems
Performance.
Chapter 2: Performance CS 447 Jason Bakos Fall 2001 CS 447.
Computer Organization and Design Chapter 4
Presentation transcript:

Copyright 2014 – Noah Mendelsohn Performance Analysis Tools Noah Mendelsohn Tufts University Web: COMP 40: Machine Structure and Assembly Language Programming (Fall 2015)

© 2010 Noah Mendelsohn 2 Tools for Optimization

© 2010 Noah Mendelsohn Tools for optimizing your code  Tools for creating fast code –Optimizing compilers –Tuned software libraries  Tools for analyzing performance –Timing tools –Profilers –Simulators / emulators –Assembler source code  read it!  Instrumentation –Add instrumentation to your code –OS- or library-provided instrumentation tools 3 We will discuss these next

© 2010 Noah Mendelsohn 4 Compiler Optimization

© 2010 Noah Mendelsohn Optimizing compilers  Modern compilers work hard to generate efficient code  Many compilers let you choose an optimization level: – gcc –c –O1 myprog.c  O1 means basic, reasonable optimization – gcc –c –O2 myprog.c  O2 Try hard: good for production work – gcc –c –O3 myprog.c  O3 Go crazy!  Why not always use O3 ? –Takes longer to compile –Code can be hard to debug (some source lines disappear – can’t set breakpoint!) –Some years O3 is buggy   Why not write assembler? –The compiler can do tricky things you likely would not –As CPUs change, compilers can change code generation strategies: your code still runs fast! 5

© 2010 Noah Mendelsohn 6 Measuring Performance

© 2010 Noah Mendelsohn What are we measuring  Time –Elapsed time  “wall clock” –CPU time from your code (user time) –CPU time from system work on your behalf –Waiting time: suggests I/O problems u 0.077s 0: % 0+0k 0+0io 0pf+0w $ time quick_sort < rand

© 2010 Noah Mendelsohn What are we measuring  Time –Elapsed time  “wall clock” –CPU time from your code (user time) –CPU time from system work on your behalf –Waiting time: suggests I/O problems 8 $ time quick_sort < rand u 0.077s 0: % 0+0k 0+0io 0pf+0w

© 2010 Noah Mendelsohn What are we measuring  Time –Elapsed time  “wall clock” –CPU time from your code (user time) –CPU time from system work on your behalf –Waiting time: suggests I/O problems 9 $ time quick_sort < rand u 0.077s 0: % 0+0k 0+0io 0pf+0w

© 2010 Noah Mendelsohn What are we measuring  Time –Elapsed time  “wall clock” –CPU time from your code (user time) –CPU time from system work on your behalf –Waiting time: suggests I/O problems 10 $ time quick_sort < rand u 0.077s 0: % 0+0k 0+0io 0pf+0w

© 2010 Noah Mendelsohn What are we measuring  Time –Elapsed time  “wall clock” –CPU time from your code (user time) –CPU time from system work on your behalf –Waiting time: suggests I/O problems 11 $ time quick_sort < rand u 0.077s 0: % 0+0k 0+0io 0pf+0w This program took 1.25 seconds to complete. The CPU was working on the program 94.4 % of that time seconds of CPU time was spent in the user’s own code were spend in the operating system doing work for the user (probably code to support file input/output)

© 2010 Noah Mendelsohn What are we measuring  Time –Elapsed time  “wall clock” –CPU time from your code (user time) –CPU time from system work on your behalf –Waiting time: suggests I/O problems 12 Note: The above is based on the built-in tcsh time command. There is also a command /usr/bin/time available from other shells.

© 2010 Noah Mendelsohn What are we measuring  Time –Elapsed time  “wall clock” –CPU time from your code (user time) –CPU time from system work on your behalf –Waiting time: suggests I/O problems 13 Your program can also include timing checks in the code to measure specific sections. For more information, explore: man 2 times man 3 clock man 2 getrusage man 2 clock_gettime  used in COMP 40 CPUTime_T

© 2010 Noah Mendelsohn What are we measuring  Time –Elapsed time  “wall clock” –CPU time from your code –CPU time from system work on your behalf –Waiting time: suggests I/O problems  I/O (amount read/written and rate at which I/O is done)  Paging rates (OS writes data to disk when memory is over-committed)  Contention from other users 14

© 2010 Noah Mendelsohn 15 Measurement and Analysis Techniques

© 2010 Noah Mendelsohn Tools for understanding what your code is doing  Statistics from the OS: –Overview of resources your program uses –Examples: /usr/bin/time command; top ; etc. many others including info in /proc –Also look for tools that can report on I/O or network activity if pertinent 16

© 2010 Noah Mendelsohn OS Performance Displays 17

© 2010 Noah Mendelsohn Tools for understanding what your code is doing  Statistics from the OS: –Overview of resources your program uses –Examples: /usr/bin/time command; top ; etc. many others –Also look for tools that can report on I/O or network activity if pertinent  Profilers: –Typically bill CPU time (or other resources) to specific functions or lines of code –Examples: gprof (older, but simple & fast to use); kcachegrind 18

© 2010 Noah Mendelsohn kcachgrind analysis of a quick sort 19

© 2010 Noah Mendelsohn Tools for understanding what your code is doing  Statistics from the OS: –Overview of resources your program uses –Examples: /usr/bin/time command; top ; etc. many others –Also look for tools that can report on I/O or network activity if pertinent  Profilers: –Typically bill CPU time (or other resources) to specific functions or lines of code –Examples: gprof (older, but simple & fast to use); kcachegrind  Instrument your code –Add counters, etc. for code or I/O events that concern you –Use system calls à la CPUTime_T to do microsecond timing of important sections of code –Print output at end, or (more sophisticated) implement real time monitoring UI –Make sure you understand whether your instrumentation is affecting performance of your code! 20

© 2010 Noah Mendelsohn Tools for understanding what your code is doing  Statistics from the OS: –Overview of resources your program uses –Examples: /usr/bin/time command; top ; etc. many others –Also look for tools that can report on I/O or network activity if pertinent  Profilers: –Typically bill CPU time (or other resources) to specific functions or lines of code –Examples: gprof (older, but simple & fast to use); kcachegrind  Instrument your code –Add counters, etc. for code or I/O events that concern you –Use system calls to do microsecond timing of important sections of code –Print output at end, or (more sophisticated) implement real time monitoring UI –Make sure you understand whether your instrumentation is affecting performance of your code!  Read the generated assembler code 21

© 2010 Noah Mendelsohn Summary  Understand the different reasons that programs run slowly  Don’t guess, measure!  Know how to use performance tools and understand what they tell you  When necessary: read the assembler code 22 Next: we will explore techniques for rewriting your code to run faster.