domain-specific profiling - tools 2011

53
Domain-Specific Profiling Alexandre Bergel, Oscar Nierstrasz, Lukas Renggli and Jorge Ressia

Upload: jorge-ressia

Post on 29-Jan-2018

1.391 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Domain-Specific Profiling - TOOLS 2011

Domain-Specific

Profiling

Alexandre Bergel, Oscar Nierstrasz, Lukas Renggli and Jorge Ressia

Page 2: Domain-Specific Profiling - TOOLS 2011

Profiling:Is the activity of analyzing a program execution.

Page 3: Domain-Specific Profiling - TOOLS 2011

Traditional Profilers

Page 4: Domain-Specific Profiling - TOOLS 2011

Source Report

Profile

Page 5: Domain-Specific Profiling - TOOLS 2011

Examples

Page 6: Domain-Specific Profiling - TOOLS 2011

CPU time

Page 7: Domain-Specific Profiling - TOOLS 2011

Mondrian

Page 8: Domain-Specific Profiling - TOOLS 2011
Page 9: Domain-Specific Profiling - TOOLS 2011

System Complexity

Lanza and Ducasse 2003

Page 10: Domain-Specific Profiling - TOOLS 2011

D omain-Sp ecific P rofiling 3

C P U t i m e p rofi li ng

Mondrian [9] is an open and agile visualiza t ion engine. Mondrian describes avisualiza t ion using a graph of (possibly nested) nodes and edges. In June 2010a serious performance issue was raised1 . Tracking down t he cause of t he poorperformance was not t rivial. We first used a st andard sample-based profiler.

E xecu t ion sampling approxima tes t he t ime spent in an applica t ion’s met hodsby periodically stopping a program and recording t he current set of met hodsunder execu t ions. Such a profiling technique is rela t ively accurate since i t hasli t t le impact on t he overall execu t ion. T his sampling technique is used by almostall mainst ream profilers, such as J P rofiler, Your K i t , xprof [10], and hprof.

M essage Tally, t he st andard sampling-based profiler in P haro Small t alk2 , tex-t ually describes t he execu t ion in terms of C P U consump t ion and invocat ion foreach met hod of Mondrian:

54.8% {11501ms} MOCanvas> >drawOn:54.8% {11501ms} MORoot(MONode) > >displayOn:30.9% {6485ms} MONode > >displayOn:

| 18.1% {3799ms} MOEdge > >displayOn:...

| 8.4% {1763ms} MOEdge> >displayOn:| | 8.0% {1679ms} MOStraightLineShape > >display:on:| | 2.6% {546ms} FormCanvas> > line:to:width:color:...

23.4% {4911ms} MOEdge > >displayOn:...

We can observe t hat t he vir t ual machine spent abou t 54% of i ts t ime int he met hod displayOn: defined in t he class MORoot. A root is t he unique non-nested node t hat cont ains all t he nodes of t he edges of t he visualizat ion. T hisgeneral profiling informat ion says t hat rendering nodes and edges consumes agrea t share of t he C P U t ime, bu t i t does not help in pinpoint ing which nodesand edges are responsible for t he t ime spent . Not all graphical elements equallyconsume resources.

Tradi t ional execu t ion sampling profilers center t heir resul t on t he frames oft he execu t ion st ack and completely ignore t he ident i ty of t he ob ject t hat receivedt he met hod call and i ts arguments. A s a consequence, i t is hard to t rack downwhich ob jects cause t he slowdown. For t he example above, t he t radi t ional profilersays t ha t we spent 30.9% in MONode > >displayOn: wi t hou t saying which nodeswere act ually refreshed too often.

C over age

Pet i t Parser is a parsing framework combining ideas from scannerless parsing,parser combinators, parsing expression grammars and packrat parsers to modelgrammars and parsers as ob jects t hat can be reconfigured dynamically [11].1 h t t p : / / f o r um . wo r l d . s t / Mond r i an - i s - s l ow - nex t - s t ep - t c2257050 . h t m l #

a22611162 h t t p : / / www . pha r o - p r o j ec t . o r g /

Page 11: Domain-Specific Profiling - TOOLS 2011

Which is the relationship?

D omain-Sp ecific P rofiling 3

C P U t i m e p rofi li ng

Mondrian [9] is an open and agile visualiza t ion engine. Mondrian describes avisualiza t ion using a graph of (possibly nested) nodes and edges. In June 2010a serious performance issue was raised1 . Tracking down t he cause of t he poorperformance was not t rivial. We first used a st andard sample-based profiler.

E xecu t ion sampling approximates t he t ime spent in an applica t ion’s met hodsby periodically stopping a program and recording t he current set of met hodsunder execu t ions. Such a profiling technique is rela t ively accurate since i t hasli t t le impact on t he overall execu t ion. T his sampling technique is used by almostall mainst ream profilers, such as J P rofiler, Your K i t , xprof [10], and hprof.

M essage Tally, t he st andard sampling-based profiler in P haro Small t alk2 , tex-t ually describes t he execu t ion in terms of C P U consump t ion and invocat ion foreach met hod of Mondrian:

54.8% {11501ms} MOCanvas> >drawOn:54.8% {11501ms} MORoot(MONode) > >displayOn:30.9% {6485ms} MONode > >displayOn:

| 18.1% {3799ms} MOEdge > >displayOn:...

| 8.4% {1763ms} MOEdge> >displayOn:| | 8.0% {1679ms} MOStraightLineShape > >display:on:| | 2.6% {546ms} FormCanvas> > line:to:width:color:...

23.4% {4911ms} MOEdge > >displayOn:...

We can observe t hat t he vir t ual machine spent abou t 54% of i ts t ime int he met hod displayOn: defined in t he class MORoot. A root is t he unique non-nested node t hat cont ains all t he nodes of t he edges of t he visualizat ion. T hisgeneral profiling informa t ion says t ha t rendering nodes and edges consumes agrea t share of t he C P U t ime, bu t i t does not help in pinpoint ing which nodesand edges are responsible for t he t ime spent . Not all graphical elements equallyconsume resources.

Tradi t ional execu t ion sampling profilers center t heir resul t on t he frames oft he execu t ion st ack and completely ignore t he ident i ty of t he ob ject t ha t receivedt he met hod call and i ts arguments. A s a consequence, i t is hard to t rack downwhich ob jects cause t he slowdown. For t he example above, t he t radi t ional profilersays t ha t we spent 30.9% in MONode > >displayOn: wi t hou t saying which nodeswere act ually refreshed too often.

C over age

Pet i t Parser is a parsing framework combining ideas from scannerless parsing,parser combinators, parsing expression grammars and packrat parsers to modelgrammars and parsers as ob jects t ha t can be reconfigured dynamically [11].1 h t t p : / / f o r um . wo r l d . s t / Mond r i an - i s - s l ow - nex t - s t ep - t c2257050 . h t m l #

a22611162 h t t p : / / www . pha r o - p r o j ec t . o r g /

?

Page 12: Domain-Specific Profiling - TOOLS 2011

Coverage

Page 13: Domain-Specific Profiling - TOOLS 2011

scg.unibe.ch/research/helvetia/petitparser

Page 14: Domain-Specific Profiling - TOOLS 2011

210 Methods

Java Grammar

100% coverage to build grammar

Page 15: Domain-Specific Profiling - TOOLS 2011
Page 16: Domain-Specific Profiling - TOOLS 2011

210 Methods

Java Grammar

100% coverage to build grammar

Is each production of the grammar covered?

Page 17: Domain-Specific Profiling - TOOLS 2011

Source Report

Domain

Profile

Page 18: Domain-Specific Profiling - TOOLS 2011

SourceCode

Domain

TraditionalProfilers

Page 19: Domain-Specific Profiling - TOOLS 2011

SourceCode

Domain

TraditionalProfilers

Domain-SpecificProfilers

Page 20: Domain-Specific Profiling - TOOLS 2011

What does it

mean?

Page 21: Domain-Specific Profiling - TOOLS 2011

Specify

Page 22: Domain-Specific Profiling - TOOLS 2011

Capture

Page 23: Domain-Specific Profiling - TOOLS 2011

Present

Page 24: Domain-Specific Profiling - TOOLS 2011

MetaSpy

Page 25: Domain-Specific Profiling - TOOLS 2011

ProfilerInstrumenter

Page 26: Domain-Specific Profiling - TOOLS 2011

DomainObject

DomainObject

DomainObject

Domain

��������

�������

Page 27: Domain-Specific Profiling - TOOLS 2011

DomainObject

DomainObject

DomainObject

Domain

��������

�������

Page 28: Domain-Specific Profiling - TOOLS 2011

DomainObject

DomainObject

DomainObject

Domain

��������

�������

Page 29: Domain-Specific Profiling - TOOLS 2011

MetaInstrumenter

installsetUptearDownuninstall

handler

installuninstall

announcer

AnnouncementInstrumenter

doesNotUnderstand:run:with:in:installsetUptearDownuninstall

theClassselectormethdo

MethodInstrumenter

installuninstall

parsergrammarreplacement

ParserInstrumenter

Profiler

observeClass:do:observeClass:selector:doobservePackage:do:observePackagesMatching:do:observeParser:in:do:installsetUptearDownuninstall

modelstrategies

setUpvisualize

MondrianProfilersetUpvisualize

OmniBrowserProfilersetUpvisualize

PetitParserProfiler

Instrumentation strategies Profilers

User provided classes

Page 30: Domain-Specific Profiling - TOOLS 2011

Specify the Domain interests

Capture the runtime

information

Present the results

Page 31: Domain-Specific Profiling - TOOLS 2011

Mondrian Profiler

Page 32: Domain-Specific Profiling - TOOLS 2011
Page 33: Domain-Specific Profiling - TOOLS 2011

System Complexity

Lanza, Ducasse 2003

Page 34: Domain-Specific Profiling - TOOLS 2011

MondrianProfiler>>setUp self model root allNodes do: [ :node | self observeObject: node selector: #displayOn: do: [ ... counting ... ] ]

Page 35: Domain-Specific Profiling - TOOLS 2011
Page 36: Domain-Specific Profiling - TOOLS 2011

Profiler

Page 37: Domain-Specific Profiling - TOOLS 2011

PetitParserProfiler>>setUp self model allParsers

do: [ :parser | self

observeParser: parser in: self grammar do: [ ... counting ... ] ]

Page 38: Domain-Specific Profiling - TOOLS 2011
Page 39: Domain-Specific Profiling - TOOLS 2011

Implementation

Page 40: Domain-Specific Profiling - TOOLS 2011

Instrumentation

Page 41: Domain-Specific Profiling - TOOLS 2011

Two options

Hooking to the Domain

Reflection

Page 42: Domain-Specific Profiling - TOOLS 2011

Reflection

Page 43: Domain-Specific Profiling - TOOLS 2011

scg.unibe.ch/research/bifrost

Page 44: Domain-Specific Profiling - TOOLS 2011

Organize the Meta-level

Page 45: Domain-Specific Profiling - TOOLS 2011

ExplicitMeta-objects

Page 46: Domain-Specific Profiling - TOOLS 2011

Object

InstrumentationMeta-object

Class

Page 47: Domain-Specific Profiling - TOOLS 2011

Object

InstrumentationMeta-object

Class

Page 48: Domain-Specific Profiling - TOOLS 2011

Instrumented Object

InstrumentationMeta-object

Class

Page 49: Domain-Specific Profiling - TOOLS 2011

Partial ReflectionSelective Reifications

UnanticipatedRuntime Integration

Adaptation Composition

Page 50: Domain-Specific Profiling - TOOLS 2011

Source

Profile

Page 51: Domain-Specific Profiling - TOOLS 2011

Source

Profile

Page 52: Domain-Specific Profiling - TOOLS 2011

Domain-specific

Information

Page 53: Domain-Specific Profiling - TOOLS 2011

MetaSpy

SourceCode

Domain

TraditionalProfilers

Domain-SpecificProfilers