performance! measurement - ecs...

19
Computer Systems and Networks ECPE 170 – Jeff Shafer – University of the Pacific Performance Measurement

Upload: doannguyet

Post on 06-Feb-2018

219 views

Category:

Documents


4 download

TRANSCRIPT

Page 1: Performance! Measurement - ECS Networkingecs-network.serv.pacific.edu/...ecpe.../06performancemeasurement.pdf · ComputerSystems)and)Networks) ECPE!170!–Jeff!Shafer!–University!of!the!Pacific!

ì  Computer  Systems  and  Networks  ECPE  170  –  Jeff  Shafer  –  University  of  the  Pacific  

Performance  Measurement  

Page 2: Performance! Measurement - ECS Networkingecs-network.serv.pacific.edu/...ecpe.../06performancemeasurement.pdf · ComputerSystems)and)Networks) ECPE!170!–Jeff!Shafer!–University!of!the!Pacific!

Lab  Schedule  

Ac?vi?es  ì  Today  

ì  Background  discussion  ì  Lab  4  –  Performance  

Measurement  

ì  Next  Tuesday  ì  Lab  4  –  Performance  

Measurement  

ì  Next  Thursday  ì  Lab  5  –  Performance  

Op<miza<on  

Assignments  Due  ì  Today  

ì  Prelab  –  Due  now  

ì  Sunday  ì  Lab  Report  for  Lab  3  due  

by  11:59pm  ì  Includes  programming  

project  

Fall  2012  Computer  Systems  and  Networks  

2  

Page 3: Performance! Measurement - ECS Networkingecs-network.serv.pacific.edu/...ecpe.../06performancemeasurement.pdf · ComputerSystems)and)Networks) ECPE!170!–Jeff!Shafer!–University!of!the!Pacific!

Person  of  the  Day:  Bill  Joy  

ì  Co-­‐founder  of  Sun  Microsystems  

ì  Author  of  vi  text  editor  

ì  Key  contributor  to  original  BSD  Unix  while  a  Berkeley  grad  student  ì  First  open-­‐source  OS  with  

TCP/IP  

Fall  2012  Computer  Systems  and  Networks  

3  

Page 4: Performance! Measurement - ECS Networkingecs-network.serv.pacific.edu/...ecpe.../06performancemeasurement.pdf · ComputerSystems)and)Networks) ECPE!170!–Jeff!Shafer!–University!of!the!Pacific!

ì  Performance  Measurement  

Fall  2012  Computer  Systems  and  Networks  

4  

Page 5: Performance! Measurement - ECS Networkingecs-network.serv.pacific.edu/...ecpe.../06performancemeasurement.pdf · ComputerSystems)and)Networks) ECPE!170!–Jeff!Shafer!–University!of!the!Pacific!

Lab  4  Goals  

1.  Measure  program  execu<on  <me  

2.  Break  down  program  execu?on  ?me  by  specific  subrou<nes  /  lines  of  code  

3.  Measure  program  memory  usage  ì  Heap  and  stack  

4.  Monitor  program  for  memory  leaks  ì  Not  really  “performance”,  but  uses  same  tool  

Fall  2012  Computer  Systems  and  Networks  

5  

Page 6: Performance! Measurement - ECS Networkingecs-network.serv.pacific.edu/...ecpe.../06performancemeasurement.pdf · ComputerSystems)and)Networks) ECPE!170!–Jeff!Shafer!–University!of!the!Pacific!

Performance  Measurement  

ì  Why  is  it  important  to  measure  applica<on  performance  in  detail?  

Fall  2012  Computer  Systems  and  Networks  

6  

Page 7: Performance! Measurement - ECS Networkingecs-network.serv.pacific.edu/...ecpe.../06performancemeasurement.pdf · ComputerSystems)and)Networks) ECPE!170!–Jeff!Shafer!–University!of!the!Pacific!

Valgrind  

Fall  2012  Computer  Systems  and  Networks  

7  

hZp://valgrind.org/    

Page 8: Performance! Measurement - ECS Networkingecs-network.serv.pacific.edu/...ecpe.../06performancemeasurement.pdf · ComputerSystems)and)Networks) ECPE!170!–Jeff!Shafer!–University!of!the!Pacific!

Valgrind  Features  

ì  Memcheck  module  –  Memory  error  detector  

ì  Access  1  beyond  the  beginning  /  end  of  your  array?  

ì  Access  un-­‐ini?alized  memory?  

ì  Reading/wri?ng  memory  a_er  calling  free()?  

ì  Memory  leak?  (Lost  pointer  to  a  malloc()  block)  

ì  Valgrind  produces  a  report  that  iden<fies  these  errors  

Fall  2012  Computer  Systems  and  Networks  

8  

Page 9: Performance! Measurement - ECS Networkingecs-network.serv.pacific.edu/...ecpe.../06performancemeasurement.pdf · ComputerSystems)and)Networks) ECPE!170!–Jeff!Shafer!–University!of!the!Pacific!

Valgrind  Features  

ì  Callgrind  module  –  Program  profiler  

ì  Callgraph  shows  you  what  func?on  called  what  other  func?ons  

ì  How  much  CPU  ?me  does  each  func?on  /  code  line  consume?  

ì  Valgrind  produces  a  report  that  summarizes  CPU  usage  of  your  program  

Fall  2012  Computer  Systems  and  Networks  

9  

Page 10: Performance! Measurement - ECS Networkingecs-network.serv.pacific.edu/...ecpe.../06performancemeasurement.pdf · ComputerSystems)and)Networks) ECPE!170!–Jeff!Shafer!–University!of!the!Pacific!

Valgrind  Features  

ì  Massif  module  –  Heap  profiler  ì  Op?mize  your  program  to  use  less  memory  (by  

iden?fying  where  memory  is  being  used)  

ì  Helgrind  module  –  Threading  profiler  ì  Bugs  in  mul?-­‐threaded  programs  are  especially  

difficult  to  find!  

ì  …  and  more  modules  …  

Fall  2012  Computer  Systems  and  Networks  

10  

Page 11: Performance! Measurement - ECS Networkingecs-network.serv.pacific.edu/...ecpe.../06performancemeasurement.pdf · ComputerSystems)and)Networks) ECPE!170!–Jeff!Shafer!–University!of!the!Pacific!

Valgrind  Common  Uses  

ì  Your  program  runs  and  suddenly  segfaults  ì  Segfault  means  you  accessed  a  memory  address  

that  doesn’t  exist  for  your  program  

ì  How  do  I  find  where  this  error  is?  ì  Valgrind  can  monitor  your  program  and  detect  

accesses  outside  of  legit  sta?c  variables  and  dynamic  memory  regions  

Fall  2012  Computer  Systems  and  Networks  

11  

Page 12: Performance! Measurement - ECS Networkingecs-network.serv.pacific.edu/...ecpe.../06performancemeasurement.pdf · ComputerSystems)and)Networks) ECPE!170!–Jeff!Shafer!–University!of!the!Pacific!

Valgrind  Common  Uses  

ì  Your  program  gets  slower  and  slower  the  longer  it  runs  ì  Memory  leak?  (Slowing  running  out  of  heap  

memory  because  you  malloc()  without  ever  calling  free())  

ì  How  do  I  find  where  this  error  is?  ì  Valgrind  can  monitor  your  program.  It  can’t  tell  you  

where  you  should  free  it,  but  it  will  tell  you  where  you  originally  called  malloc(),  or  where  the  pointer  was  lost  

Fall  2012  Computer  Systems  and  Networks  

12  

Page 13: Performance! Measurement - ECS Networkingecs-network.serv.pacific.edu/...ecpe.../06performancemeasurement.pdf · ComputerSystems)and)Networks) ECPE!170!–Jeff!Shafer!–University!of!the!Pacific!

Valgrind  Behind-­‐the-­‐Scenes  

ì  Just-­‐in  <me  compiler  ì  Your  program  is  re-­‐compiled  onto  a  virtual  

(simulated  processor)  ì  Another  example  of  a  virtual  machine!  

ì  Benefit  –  Valgrind  can  observe  your  program  running  at  the  (assembly)  instruc?on  level  

ì  Drawback  –  Slow!    (5x  slower  than  normal)  ì  But  it’s  s,ll  be/er  than  fixing  bugs  without  a  tool…  

Fall  2012  Computer  Systems  and  Networks  

13  

Page 14: Performance! Measurement - ECS Networkingecs-network.serv.pacific.edu/...ecpe.../06performancemeasurement.pdf · ComputerSystems)and)Networks) ECPE!170!–Jeff!Shafer!–University!of!the!Pacific!

ì  Profiling  Basics  

Fall  2012  Computer  Systems  and  Networks  

14  

Page 15: Performance! Measurement - ECS Networkingecs-network.serv.pacific.edu/...ecpe.../06performancemeasurement.pdf · ComputerSystems)and)Networks) ECPE!170!–Jeff!Shafer!–University!of!the!Pacific!

Profiling  Basics  

ì  The  next  labs  (4-­‐7)  will  ask  you  to  measure  applica<on  performance  by  conduc?ng  experiments  ì  Execu?on  ?me  ì  Processor  usage  ì  Memory  usage  

ì  What  system  configura<on  do  you  think  would  be  best  in  terms  of  producing  the  cleanest,  most  accurate,  most  reproducible  results?  ì  Three  choices  to  choose  from…  

Fall  2012  Computer  Systems  and  Networks  

15  

Page 16: Performance! Measurement - ECS Networkingecs-network.serv.pacific.edu/...ecpe.../06performancemeasurement.pdf · ComputerSystems)and)Networks) ECPE!170!–Jeff!Shafer!–University!of!the!Pacific!

Fall  2012  Computer  Systems  and  Networks  

16  

Program  to  Benchmark  

Page 17: Performance! Measurement - ECS Networkingecs-network.serv.pacific.edu/...ecpe.../06performancemeasurement.pdf · ComputerSystems)and)Networks) ECPE!170!–Jeff!Shafer!–University!of!the!Pacific!

Fall  2012  Computer  Systems  and  Networks  

17  

Program  to  Benchmark  

Page 18: Performance! Measurement - ECS Networkingecs-network.serv.pacific.edu/...ecpe.../06performancemeasurement.pdf · ComputerSystems)and)Networks) ECPE!170!–Jeff!Shafer!–University!of!the!Pacific!

Fall  2012  Computer  Systems  and  Networks  

18  

Program  to  Benchmark  

Page 19: Performance! Measurement - ECS Networkingecs-network.serv.pacific.edu/...ecpe.../06performancemeasurement.pdf · ComputerSystems)and)Networks) ECPE!170!–Jeff!Shafer!–University!of!the!Pacific!

Profiling  Basics  

ì  The  best  approach  (directly  boo<ng  Linux)  may  not  be  convenient  to  achieve  for  this  class  

ì  But  you  can  *definitely*  avoid  the  worst  configura<on!  

ì  Keep  your  system  simple  when  benchmarking  

Fall  2012  Computer  Systems  and  Networks  

19