Performance Measurement 2 Lab Schedule Activities Assignments - - PowerPoint PPT Presentation

performance measurement
SMART_READER_LITE
LIVE PREVIEW

Performance Measurement 2 Lab Schedule Activities Assignments - - PowerPoint PPT Presentation

Computer Systems and Networks ECPE 170 Jeff Shafer University of the Pacific Performance Measurement 2 Lab Schedule Activities Assignments Due Today Lab 4 Due by Feb 19 th 5:00am Discussion on Performance


slide-1
SLIDE 1

ì

Computer Systems and Networks

ECPE 170 – Jeff Shafer – University of the Pacific

Performance Measurement

slide-2
SLIDE 2

Lab Schedule

Activities

ì

Today

ì

Discussion on Performance Measurement (Lab 5)

ì

Finish Lab 4! ì

Next Week

ì

Lab 5 – Performance Measurement

Assignments Due

ì

Lab 4

ì

Due by Feb 19th 5:00am ì

Lab 5

ì

Due by Feb 26th 5:00am

Spring 2019 Computer Systems and Networks

2

slide-3
SLIDE 3

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

Spring 2019 Computer Systems and Networks

3

slide-4
SLIDE 4

ì

Memory Leaks

Spring 2019 Computer Systems and Networks

4

slide-5
SLIDE 5

Problem 1

int main() { int *array; array=(int *)malloc(sizeof(int)*1000); for(i=0;i<1000;i++) array[i] = i; return 0; }

Spring 2019 Computer Systems and Networks

5

P1

Where is the Memory Leak?

slide-6
SLIDE 6

Problem 2

int main() { int **array; array=(int **)malloc(sizeof(int *)*1000); for(i=0;i<1000;i++) array[i] = (int *)malloc(sizeof(int)*500); free(array); return 0; }

Spring 2019 Computer Systems and Networks

6

P2

(a) Where is the Memory Leak? (b) How do you fix it?

slide-7
SLIDE 7

ì

Performance Measurement

Spring 2019 Computer Systems and Networks

7

slide-8
SLIDE 8

Lab 5 Goals

1.

Measure program execution time

2.

Break down program execution time by specific subroutines / lines of code

3.

Monitor program for memory leaks

ì

Not really “performance”, but uses same tool

Spring 2019 Computer Systems and Networks

8

slide-9
SLIDE 9

Performance Measurement

ì Why is it important to measure application

performance in detail?

Spring 2019 Computer Systems and Networks

9

slide-10
SLIDE 10

Valgrind

Spring 2019 Computer Systems and Networks

10

http://valgrind.org/

slide-11
SLIDE 11

Valgrind Features

ì Memcheck module – Memory error detector ì Access 1 beyond the beginning / end of your array? ì Access un-initialized memory? ì Reading/writing memory after calling free()? ì Memory leak? (Lost pointer to a malloc() block) ì Valgrind produces a report that identifies these

errors

Spring 2019 Computer Systems and Networks

11

slide-12
SLIDE 12

Valgrind Features

ì Callgrind module – Program profiler ì Callgraph shows you what function called what

  • ther functions

ì How much CPU time does each function / code line

consume?

ì Valgrind produces a report that summarizes CPU

usage of your program

Spring 2019 Computer Systems and Networks

12

slide-13
SLIDE 13

Valgrind Features

ì Massif module – Heap profiler

ì

Optimize your program to use less memory (by identifying where memory is being used) ì Helgrind module – Threading profiler

ì

Bugs in multi-threaded programs are especially difficult to find! ì … and more modules …

Spring 2019 Computer Systems and Networks

13

slide-14
SLIDE 14

Valgrind Common Uses

ì Your program runs and suddenly segfaults

ì

Recall a segfault means a memory address was accessed 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 static variables and dynamic memory regions

Spring 2019 Computer Systems and Networks

14

slide-15
SLIDE 15

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

Spring 2019 Computer Systems and Networks

15

slide-16
SLIDE 16

Valgrind Behind-the-Scenes

ì Just-in time 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 machine instruction level

ì Drawback – Slow! (5x slower than normal)

ì

But it’s still better than fixing bugs without a tool…

Spring 2019 Computer Systems and Networks

16

slide-17
SLIDE 17

ì

Profiling Basics

Spring 2019 Computer Systems and Networks

17

slide-18
SLIDE 18

Profiling Basics

ì The next labs (5-7) ask you to measure application

performance by conducting experiments

ì

Execution time

ì

Processor usage

ì

Memory usage ì Which of these system configuration do you think

would be best in terms of producing the cleanest, most accurate, most reproducible results?

Spring 2019 Computer Systems and Networks

18

slide-19
SLIDE 19

Spring 2019 Computer Systems and Networks

19

Program to Benchmark

slide-20
SLIDE 20

Spring 2019 Computer Systems and Networks

20

Program to Benchmark

slide-21
SLIDE 21

Spring 2019 Computer Systems and Networks

21

Program to Benchmark

slide-22
SLIDE 22

Profiling Basics

ì The best approach (directly booting Linux) may not

be convenient to achieve for this class

ì But you can *definitely* avoid the worst

configuration!

ì

Keep your system simple when benchmarking

Spring 2019 Computer Systems and Networks

22