visualizing dynamic metrics with profiling blueprints

40
Visualizing Dynamic Metrics with Profiling Blueprints Alexandre Bergel, Romain Robbes, Walter Binder University of Chile University of Chile Lugano

Upload: esug

Post on 06-May-2015

443 views

Category:

Technology


1 download

DESCRIPTION

Visualizing Dynamic Metrics with Profiling Blueprints. Alexandre Bergel, Romain Robbes, Walter Binder. ESUG 2010, Barcelona, Spain

TRANSCRIPT

Page 1: Visualizing Dynamic Metrics with Profiling Blueprints

Visualizing Dynamic Metrics with Profiling

BlueprintsAlexandre Bergel, Romain Robbes, Walter Binder

University of Chile University of Chile Lugano

Page 2: Visualizing Dynamic Metrics with Profiling Blueprints

“software profiling is the investigation of a program's behavior using information gathered as the program executes”

- Wikipedia

2

Page 3: Visualizing Dynamic Metrics with Profiling Blueprints

3

}

{

}

{

}

{}

{

}

{

Page 4: Visualizing Dynamic Metrics with Profiling Blueprints

4

}

{

}

{

}

{}

{

}

{

Page 5: Visualizing Dynamic Metrics with Profiling Blueprints

5

}

{

}

{

}

{}

{

}

{

1.4

Page 6: Visualizing Dynamic Metrics with Profiling Blueprints

6

}

{

}

{

}

{}

{

}

{

1.45.2

Page 7: Visualizing Dynamic Metrics with Profiling Blueprints

7

}

{

}

{

}

{}

{

}

{

1.45.25.6

Page 8: Visualizing Dynamic Metrics with Profiling Blueprints

8

}

{

}

{

}

{}

{

}

{

1.45.25.62.3

Page 9: Visualizing Dynamic Metrics with Profiling Blueprints

9

}

{

}

{

}

{}

{

}

{

1.45.25.62.30.5...

Page 10: Visualizing Dynamic Metrics with Profiling Blueprints

10

}

{

}

{

}

{}

{

}

{

}

{

}

{

}

{

}

{

}

{

1.45.25.62.30.5... Understanding why

Page 11: Visualizing Dynamic Metrics with Profiling Blueprints

gprof: flat profile

Flat profile:

Each sample counts as 0.01 seconds.

% cumulative self self total

time seconds seconds calls ms/call ms/call name

33.34 0.02 0.02 7208 0.00 0.00 open

16.67 0.03 0.01 244 0.04 0.12 offtime

16.67 0.04 0.01 8 1.25 1.25 memccpy

16.67 0.05 0.01 7 1.43 1.43 write

16.67 0.06 0.01 mcount

0.00 0.06 0.00 236 0.00 0.00 tzset

0.00 0.06 0.00 192 0.00 0.00 tolower

0.00 0.06 0.00 47 0.00 0.00 strlen

0.00 0.06 0.00 45 0.00 0.00 strchr

11

Page 12: Visualizing Dynamic Metrics with Profiling Blueprints

gprof: call graph (~1984)

index % time self children called name <spontaneous>[1] 100.0 0.00 0.05 start [1] 0.00 0.05 1/1 main [2] 0.00 0.00 1/2 on_exit [28] 0.00 0.00 1/1 exit [59]----------------------------------------------- 0.00 0.05 1/1 start [1][2] 100.0 0.00 0.05 1 main [2] 0.00 0.05 1/1 report [3]----------------------------------------------- 0.00 0.05 1/1 main [2][3] 100.0 0.00 0.05 1 report [3] 0.00 0.03 8/8 timelocal [6] 0.00 0.01 1/1 print [9] 0.00 0.01 9/9 fgets [12] 0.00 0.00 12/34 strncmp <cycle 1> [40] 0.00 0.00 8/8 lookup [20] 0.00 0.00 1/1 fopen [21] 0.00 0.00 8/8 chewtime [24] 0.00 0.00 8/16 skipspace [44]-----------------------------------------------[4] 59.8 0.01 0.02 8+472 <cycle 2 as a whole>! [4] 0.01 0.02 244+260 offtime <cycle 2> [7] 0.00 0.00 236+1 tzset <cycle 2> [26]-----------------------------------------------

12

Page 13: Visualizing Dynamic Metrics with Profiling Blueprints

YourKit

13

Page 14: Visualizing Dynamic Metrics with Profiling Blueprints

YourKit

14

Page 15: Visualizing Dynamic Metrics with Profiling Blueprints

JProfiler

15

Page 16: Visualizing Dynamic Metrics with Profiling Blueprints

JProfiler

16

Page 17: Visualizing Dynamic Metrics with Profiling Blueprints

JProfiler

17

Page 18: Visualizing Dynamic Metrics with Profiling Blueprints

Retrospective on profiling

18

Information conveyed hasn’t evolved since gprof

Useful to understand what happened

But is of little help to understand why and how

Page 19: Visualizing Dynamic Metrics with Profiling Blueprints

Roadmap

1.Polymetric views

2.Profiling Blueprint

3.Implementation

19

Page 20: Visualizing Dynamic Metrics with Profiling Blueprints

Polymetric view can map up to 5 dimensions

width property

heightproperty

colorproperty

X property

Yproperty

20[Lanza 2003]

Page 21: Visualizing Dynamic Metrics with Profiling Blueprints

21

KaiProfiler viewProfiling: [ | view |! view := MOViewRenderer new.! view nodes: (1 to: 100) forEach: [:each | view nodes: (1 to: 100)].! view root applyLayout ! ]

Page 22: Visualizing Dynamic Metrics with Profiling Blueprints

Structural blueprint

legend for methods

(color)

#different

receiver

# executions

execution

time

22

Page 23: Visualizing Dynamic Metrics with Profiling Blueprints

Structural blueprint

legend for methods

(color)

#different

receiver

# executions

execution

time

bounds

23

Page 24: Visualizing Dynamic Metrics with Profiling Blueprints

Behavioral blueprint

legend for methods

gray = return self

yellow = constant on return

value

# executions

execution time

m2

m1 invokes

m2 and m3

m1 m3

24

Page 25: Visualizing Dynamic Metrics with Profiling Blueprints

Behavioral blueprint

legend for methods

gray = return self

yellow = constant on return

value

# executions

execution time

m2

m1 invokes

m2 and m3

m1 m3

bounds25

Page 26: Visualizing Dynamic Metrics with Profiling Blueprints

Detailed behavioral blueprint

MOGraphElement>>

origin

shapeBoundsAt:ifPresent:Called by #bounds

Calling #bounds

bounds

computeExtentHavingChildrenFor:

26

Page 27: Visualizing Dynamic Metrics with Profiling Blueprints

Code of the bounds method

MOGraphElement>>bounds "Answer the bounds of the receiver."

| basicBounds |

self shapeBoundsAt: self shape ifPresent: [ :b | ^ b ].

basicBounds := shape computeBoundsFor: self. self shapeBoundsAt: self shape put: basicBounds.

^ basicBounds

27

Page 28: Visualizing Dynamic Metrics with Profiling Blueprints

Memoizing

MOGraphElement>>bounds "Answer the bounds of the receiver."

| basicBounds | boundsCache ifNotNil: [ ^ boundsCache ]. self shapeBoundsAt: self shape ifPresent: [ :b | ^ b ].

basicBounds := shape computeBoundsFor: self. self shapeBoundsAt: self shape put: basicBounds.

^ boundsCache := basicBounds

28

Page 29: Visualizing Dynamic Metrics with Profiling Blueprints

A

B

C

Upgrading MOGraphElement>>bounds

29

Page 30: Visualizing Dynamic Metrics with Profiling Blueprints

A

B

C

Upgrading MOGraphElement>>bounds

43%speedup

30

Page 31: Visualizing Dynamic Metrics with Profiling Blueprints

B

A

Upgrading MOGraphElement>>bounds

31

Page 32: Visualizing Dynamic Metrics with Profiling Blueprints

AB C D

cached

absoluteBoundsmake display:on:

call absoluteBoundsinstead of absoluteBoundsFor:

A'

C'

B'

C'

32

Page 33: Visualizing Dynamic Metrics with Profiling Blueprints

Implementation

We use the following metrics:

execution time for a method (% and ms)

number of executions

number of different object receivers

Dynamic properties

a method performs a side effect

a method is void (i.e., return self in Pharo)

33

Page 34: Visualizing Dynamic Metrics with Profiling Blueprints

Naive (but effective) implementation

Code to profile is executed twice

using a sampling method to get the execution time

instrumentation to get all the remaining metrics

Use hash values to distinguish between different receiver objects

Built a kind of AOP mechanism for the low level instrumentation

34

Page 35: Visualizing Dynamic Metrics with Profiling Blueprints

Implementation techniques

Visualizations are generated using a scripting languages

... in Mondrian

Limitation

hash code collisions (problem in Pharo)

need to do execute the code to profile twice (sampling and instrumentation)

35

Page 36: Visualizing Dynamic Metrics with Profiling Blueprints

Implemented in Pharo

Smalltalk dialect

Dynamically typed language

36

Page 37: Visualizing Dynamic Metrics with Profiling Blueprints

Conclusion

Effective visualizations

Smooth integration in the programming environment

Implemented in Pharo

37

Page 38: Visualizing Dynamic Metrics with Profiling Blueprints

Conclusion

A number of bottlenecks were identified

No general rule for pattern identification

Visualizations are effective for identifying potential candidate for optimization

38

Page 39: Visualizing Dynamic Metrics with Profiling Blueprints

Conclusion

Future work

close integration in the programming environment

dedicated visualization for comparison

additional metrics, e.g., the number of executed bytecodes, memory usage

39

Page 40: Visualizing Dynamic Metrics with Profiling Blueprints

A

B

C

Visualizing Dynamic Metrics with Profiling Blueprints

www.moosetechnology.org/tools/Spy

Alexandre Bergel, Romain Robbes, Walter Binder

[email protected]

40