SlideShare a Scribd company logo
1 of 40
Download to read offline
Profiler Zoo
    Alexandre Bergel
 abergel@dcc.uchile.cl
Pleiad lab, UChile, Chile
2
Test coverage

Problem:
  Traditional code coverage tools have a binary view of the world

Why the problem is important:
  Which method should you test first in order to increase the
 coverage?

  Is my code well covered or not?

Solution:
  An intuitive visual representation of a qualitative assessment of the
 coverage



                                                                          3
Test blueprint

C1


            Legend for methods (inner boxes)
                 # calling methods

d            complexity       # executions
     c
                             invocation on self
C2                          red = not executed
                            blue = abstract




                                                  4
Successive improvement




Version 2.2   Version 2.3   Version 2.4   Version 2.5
 27.27%        54.54%        87.71%         100%




                                                        5
4 patterns




             6
Moose-Test-Core.13                                 Moose-Test-Core.48
          Moose-Core.313                                     Moose-Core.326


                      21.42%
                                                                        100%




                               56.86%                                            100%




                                        73.58%                                          100%




68.25%                                             96.66%
                                          36.78%                                         64.55%


   0%                                               100%




                                                                                          7
Reducing code complexity

 Version 1.58.1     Version 1.58.9
Coverage: 40.57%   Coverage: 60.60%




                                      8
Reducing code complexity




        Version 2.10




        Version 2.17
                           9
Execution profiling


Problem:
  Traditional code profilers are driven by the method stack,
 discarding the notion of sending messages

Why the problem is important:
  How to answer to “Is there a slow function that is called too
 often?”

Solution:
  An intuitive visual representation of the execution that visually
 compare the time spent and the number of executions



                                                                      10
Structural profiling blueprint




                      legend for methods
                                     # executions




                                         (color)
                        execution
                                       #different
                          time
                                        receiver




                                                    11
Structural profiling blueprint




bounds



                           legend for methods
                                          # executions




                                              (color)
                             execution
                                            #different
                               time
                                             receiver




                                                         12
Behavioral profiling blueprint




                  legend for methods
                                 # executions


                                    gray =
                                    return      m1     m3
                                     self
                    execution                           m1
                      time         yellow =           invokes
                                   constant     m2   m2 and m3
                                   on return
                                    value
                                                                 13
Behavioral profiling blueprint




                  legend for methods
                                 # executions


                                    gray =
                                    return      m1     m3
                                     self
                    execution                           m1
                      time         yellow =           invokes
                                                m2   m2 and m3
bounds
                                   constant
                                   on return
                                    value
                                                                 14
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


                                                           15
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


                                                           16
Upgrading
        MOGraphElement>>bounds


A

    B
                     C




                                 17
43%
speedup             Upgrading
              MOGraphElement>>bounds


      A

          B
                           C




                                       18
A




      Upgrading
MOGraphElement>>bounds




                             B




                                 19
B                  C
                      A




    cached
absoluteBounds
                                                 instea




                 A'

                                        C'



                                   B'




                              C'


                                             20
Measuring execution time


Problem:
  Traditional code profilers sample program execution at a regular
 interval. This is inaccurate, non portable and non deterministic

Why the problem is important:
  all profiles are meaningless if I get a new laptop or change the
 virtual machine

  cannot profile short execution time

Solution:
  counting messages as a proxy for execution time


                                                                    21
Counting messages

Wallet >> increaseByOne
   money := money + 1

Wallet >> increaseBy3
   self
     increaseByOne;
     increaseByOne;
     increaseByOne.


aWallet increaseBy3
=> 6 messages sent




                               22
Execution time and number of
                         message sends
                        6
                 400 x 10
message sends



                400000000

                        6
                 300 x 10
                300000000

                        6
                 200 x 10
                200000000

                        6
                 100 x 10
                100000000


                        0
                            0   10000   20000   30000    40000

                                                    times (ms)
                                                                 23
Counting Messages to Identify
                      Execution Bottlenecks
                              6
number of method



                   10000000
                   10.0 x 10
   invocations




                              6
                    7500000
                    7.5 x 10

                              6
                    5.0 x 10
                    5000000

                              6
                    2.5 x 10
                    2500000


                          0
                               0   75   150   225        300
                                                    time (ms)
                                                                24
Contrasting Execution Sampling with
         Message Counting



No need for sampling
Independent from the execution environment
Stable measurements




                                             25
Counting messages in unit testing




CollectionTest>>testInsertion
   self
     assert: [ Set new add: 1 ]
     fasterThan: [Set new add: 1; add: 2 ]




                                             26
Counting messages in unit testing

MondrianSpeedTest>> testLayout2
  | view1 view2 |
  view1 := MOViewRenderer new.
  view1 nodes: (Collection allSubclasses).
  view1 edgesFrom: #superclass.
  view1 treeLayout.

  view2   := MOViewRenderer new.
  view2   nodes: (Collection withAllSubclasses).
  view2   edgesFrom: #superclass.
  view2   treeLayout.

  self
   assertIs: [ view1 root applyLayout ]
   fasterThan: [ view2 root applyLayout ]
                                                   27
Assessing profiler stability




                              28
Identifying redundant computation

Problem:
  Traditional code profiler cannot determine whether the same
 computation is realized twice or more

Why the problem is important:
  Redundant computation cannot be identified and removed without
 heavily involving programmer imagination

Solution:
  Finding side-effect-free methods that are executed more than
 once




                                                                  29
Example

MOGraphElement>> absoluteBounds
   ^ self shape absoluteBoundsFor: self




MOGraphElement>> absoluteBounds
   boundsCache ifNotNil: [ ^ boundsCache ].
   ^ boundsCache := self shape absoluteBoundsFor: self

MONode>> translateBy: realStep
   boundsCache := nil.
   ...




                                                         30
Example


AbstractNautilusUI>>packageIconFor: aPackage
   |t|
   (packageIconCache notNil
      and: [ packageIconCache includesKey: aPackage ])
         ifTrue: [ ˆ packageIconCache at: aPackage ].
   packageIconCache
      ifNil: [ packageIconCache := IdentityDictionary
    new ].

   aPackage isDirty ifTrue: [ ˆ IconicButton new ].
   t := self iconClass iconNamed: #packageIcon.

   packageIconCache at: aPackage put: t.
   ˆt

                                                      31
Identifying memoization candidate



A method is candidate for being memoized if
  it is executed more than once on a particular object

  it returns the same value per receiver and arguments

  it does not any “perceptible” side effect

  its execution is sufficiently long




                                                         32
Experiment



We took 11 applications and profiled their unit tests
We identified candidates for each of them
We memoized some of the candidates
The tests are kept green




                                                       33
34
Execution time



In some case we reduce the execution time by 20%
  e.g., Nautilus

In some other case, the execution time increased (!)
  This is the case for very short methods




                                                       35
Research questions



 Is there a general way to identify redundant messages
by monitoring program execution?


 Can redundant messages be removed while
preserving the overall program behavior?




                                                         36
The Spy profiling framework
Core

                                                                           MethodSpy
            Profiler                                              methodName
   packages                                      ClassSpy        class
   currentTest               PackageSpy      spyClassForMethod   originalMethod
   profile: aBlock         spyClassForClass   package             outgoingCalls
   runTests: tests        packageName        superclass          incomingCalls
   spyClassForPackage     classes            metaclass           timeExecution
   allMethods                                methods             afterRun:with: in:
   registryName                                                  beforeRun:with:in:
                                                                 run:with:in:

TestCoverage
                                                                            TCMethod
                                                                 numberOfExectutions
        TestCoverage
                                                                 receiverTable
   spyClassForPackage
                                                                 beforeRun:with:in:
   view                      TCPackage            TCClass
                                                                 numberOfDifferentReceivers
   ratioExecutedMethods   spyClassForClass   spyClassForMethod
                                                                 nbOfExecutions
   ratioCoveredClasses
                                                                 isCovered
   viewBasicOn:
                                                                 initialize
   registryName
                                                                 viewBasicOn:




                                                                                              37
Closing words




Little innovation in the tools we commonly use
  Profilers & debuggers have not significantly evolves

Fantastic opportunities for improvement




                                                       38
Thanks to




Laurent Laffont, RMoD inria group
all the people who participated in our experiments



                                                     39
Test coverage with Hapao                     Moose-Test-Core.13                                 Moose-Test-Core.48



Profiling blueprints
                                              Moose-Core.313                                     Moose-Core.326


                                                          21.42%
                                                                                                            100%




Proxy for execution time
Identifying redundant computation
                                                                   56.86%                                            100%




                                                                            73.58%                                          100%




                                    68.25%                                             96.66%
                                                                              36.78%                                         64.55%


                                       0%                                               100%




                        Profiler Zoo



http://bergel.eu
http://hapao.dcc.uchile.cl
http://moosetechnology.org/tools/spy
                                                                                                                            40

More Related Content

What's hot

Multidisciplinary Design Optimization of Supersonic Transport Wing Using Surr...
Multidisciplinary Design Optimization of Supersonic Transport Wing Using Surr...Multidisciplinary Design Optimization of Supersonic Transport Wing Using Surr...
Multidisciplinary Design Optimization of Supersonic Transport Wing Using Surr...Masahiro Kanazaki
 
Reconsidering Custom Memory Allocation
Reconsidering Custom Memory AllocationReconsidering Custom Memory Allocation
Reconsidering Custom Memory AllocationEmery Berger
 
Resource to Performance Tradeoff Adjustment for Fine-Grained Architectures ─A...
Resource to Performance Tradeoff Adjustment for Fine-Grained Architectures ─A...Resource to Performance Tradeoff Adjustment for Fine-Grained Architectures ─A...
Resource to Performance Tradeoff Adjustment for Fine-Grained Architectures ─A...Fahad Cheema
 
Team Developpement with Mercurial - april 2011
Team Developpement with Mercurial - april 2011Team Developpement with Mercurial - april 2011
Team Developpement with Mercurial - april 2011Logilab
 
225.doc
225.doc225.doc
225.docbutest
 
Design of Optimal Linear Phase FIR High Pass Filter using Improved Particle S...
Design of Optimal Linear Phase FIR High Pass Filter using Improved Particle S...Design of Optimal Linear Phase FIR High Pass Filter using Improved Particle S...
Design of Optimal Linear Phase FIR High Pass Filter using Improved Particle S...IDES Editor
 

What's hot (7)

Multidisciplinary Design Optimization of Supersonic Transport Wing Using Surr...
Multidisciplinary Design Optimization of Supersonic Transport Wing Using Surr...Multidisciplinary Design Optimization of Supersonic Transport Wing Using Surr...
Multidisciplinary Design Optimization of Supersonic Transport Wing Using Surr...
 
Reconsidering Custom Memory Allocation
Reconsidering Custom Memory AllocationReconsidering Custom Memory Allocation
Reconsidering Custom Memory Allocation
 
Resource to Performance Tradeoff Adjustment for Fine-Grained Architectures ─A...
Resource to Performance Tradeoff Adjustment for Fine-Grained Architectures ─A...Resource to Performance Tradeoff Adjustment for Fine-Grained Architectures ─A...
Resource to Performance Tradeoff Adjustment for Fine-Grained Architectures ─A...
 
Team Developpement with Mercurial - april 2011
Team Developpement with Mercurial - april 2011Team Developpement with Mercurial - april 2011
Team Developpement with Mercurial - april 2011
 
225.doc
225.doc225.doc
225.doc
 
Design of Optimal Linear Phase FIR High Pass Filter using Improved Particle S...
Design of Optimal Linear Phase FIR High Pass Filter using Improved Particle S...Design of Optimal Linear Phase FIR High Pass Filter using Improved Particle S...
Design of Optimal Linear Phase FIR High Pass Filter using Improved Particle S...
 
Solido Pvt Corner Package Datasheet
Solido Pvt Corner Package DatasheetSolido Pvt Corner Package Datasheet
Solido Pvt Corner Package Datasheet
 

Similar to Profilling Zoo

Graph Neural Network #2-1 (PinSage)
Graph Neural Network #2-1 (PinSage)Graph Neural Network #2-1 (PinSage)
Graph Neural Network #2-1 (PinSage)seungwoo kim
 
Roassal presentation
Roassal presentationRoassal presentation
Roassal presentationbergel
 
Bifrost: Setting Smalltalk Loose
Bifrost: Setting Smalltalk LooseBifrost: Setting Smalltalk Loose
Bifrost: Setting Smalltalk LooseJorge Ressia
 
Class 6: Programming with Data
Class 6: Programming with DataClass 6: Programming with Data
Class 6: Programming with DataDavid Evans
 
So You Want To Write Your Own Benchmark
So You Want To Write Your Own BenchmarkSo You Want To Write Your Own Benchmark
So You Want To Write Your Own BenchmarkDror Bereznitsky
 
A Performance Study of BDD-Based Model Checking
A Performance Study of BDD-Based Model CheckingA Performance Study of BDD-Based Model Checking
A Performance Study of BDD-Based Model CheckingOlivier Coudert
 
%w(map reduce).first - A Tale About Rabbits, Latency, and Slim Crontabs
%w(map reduce).first - A Tale About Rabbits, Latency, and Slim Crontabs%w(map reduce).first - A Tale About Rabbits, Latency, and Slim Crontabs
%w(map reduce).first - A Tale About Rabbits, Latency, and Slim CrontabsPaolo Negri
 
PR-297: Training data-efficient image transformers & distillation through att...
PR-297: Training data-efficient image transformers & distillation through att...PR-297: Training data-efficient image transformers & distillation through att...
PR-297: Training data-efficient image transformers & distillation through att...Jinwon Lee
 
The Ultimate Question of Programming, Refactoring, and Everything
The Ultimate Question of Programming, Refactoring, and EverythingThe Ultimate Question of Programming, Refactoring, and Everything
The Ultimate Question of Programming, Refactoring, and EverythingAndrey Karpov
 
The Ultimate Question of Programming, Refactoring, and Everything
The Ultimate Question of Programming, Refactoring, and EverythingThe Ultimate Question of Programming, Refactoring, and Everything
The Ultimate Question of Programming, Refactoring, and EverythingPVS-Studio
 
Introducing LCS to Digital Design Verification
Introducing LCS to Digital Design VerificationIntroducing LCS to Digital Design Verification
Introducing LCS to Digital Design VerificationDaniele Loiacono
 
Semi-supervised concept detection by learning the structure of similarity graphs
Semi-supervised concept detection by learning the structure of similarity graphsSemi-supervised concept detection by learning the structure of similarity graphs
Semi-supervised concept detection by learning the structure of similarity graphsSymeon Papadopoulos
 
Object Centric Reflection
Object Centric ReflectionObject Centric Reflection
Object Centric ReflectionESUG
 
Rubinius - Improving the Rails ecosystem
Rubinius - Improving the Rails ecosystemRubinius - Improving the Rails ecosystem
Rubinius - Improving the Rails ecosystemevanphx
 
ModRef'09: Gecode support for MCP
ModRef'09: Gecode support for MCPModRef'09: Gecode support for MCP
ModRef'09: Gecode support for MCPpwuille
 
Lightspeed Preprint
Lightspeed PreprintLightspeed Preprint
Lightspeed Preprintjustanimate
 
New Directions for Mahout
New Directions for MahoutNew Directions for Mahout
New Directions for MahoutTed Dunning
 

Similar to Profilling Zoo (20)

Graph Neural Network #2-1 (PinSage)
Graph Neural Network #2-1 (PinSage)Graph Neural Network #2-1 (PinSage)
Graph Neural Network #2-1 (PinSage)
 
Roassal presentation
Roassal presentationRoassal presentation
Roassal presentation
 
2021 04-01-dalle
2021 04-01-dalle2021 04-01-dalle
2021 04-01-dalle
 
Ad24210214
Ad24210214Ad24210214
Ad24210214
 
Bifrost: Setting Smalltalk Loose
Bifrost: Setting Smalltalk LooseBifrost: Setting Smalltalk Loose
Bifrost: Setting Smalltalk Loose
 
Class 6: Programming with Data
Class 6: Programming with DataClass 6: Programming with Data
Class 6: Programming with Data
 
So You Want To Write Your Own Benchmark
So You Want To Write Your Own BenchmarkSo You Want To Write Your Own Benchmark
So You Want To Write Your Own Benchmark
 
A Performance Study of BDD-Based Model Checking
A Performance Study of BDD-Based Model CheckingA Performance Study of BDD-Based Model Checking
A Performance Study of BDD-Based Model Checking
 
%w(map reduce).first - A Tale About Rabbits, Latency, and Slim Crontabs
%w(map reduce).first - A Tale About Rabbits, Latency, and Slim Crontabs%w(map reduce).first - A Tale About Rabbits, Latency, and Slim Crontabs
%w(map reduce).first - A Tale About Rabbits, Latency, and Slim Crontabs
 
PR-297: Training data-efficient image transformers & distillation through att...
PR-297: Training data-efficient image transformers & distillation through att...PR-297: Training data-efficient image transformers & distillation through att...
PR-297: Training data-efficient image transformers & distillation through att...
 
The Ultimate Question of Programming, Refactoring, and Everything
The Ultimate Question of Programming, Refactoring, and EverythingThe Ultimate Question of Programming, Refactoring, and Everything
The Ultimate Question of Programming, Refactoring, and Everything
 
The Ultimate Question of Programming, Refactoring, and Everything
The Ultimate Question of Programming, Refactoring, and EverythingThe Ultimate Question of Programming, Refactoring, and Everything
The Ultimate Question of Programming, Refactoring, and Everything
 
Introducing LCS to Digital Design Verification
Introducing LCS to Digital Design VerificationIntroducing LCS to Digital Design Verification
Introducing LCS to Digital Design Verification
 
Semi-supervised concept detection by learning the structure of similarity graphs
Semi-supervised concept detection by learning the structure of similarity graphsSemi-supervised concept detection by learning the structure of similarity graphs
Semi-supervised concept detection by learning the structure of similarity graphs
 
Object Centric Reflection
Object Centric ReflectionObject Centric Reflection
Object Centric Reflection
 
Shuronr
ShuronrShuronr
Shuronr
 
Rubinius - Improving the Rails ecosystem
Rubinius - Improving the Rails ecosystemRubinius - Improving the Rails ecosystem
Rubinius - Improving the Rails ecosystem
 
ModRef'09: Gecode support for MCP
ModRef'09: Gecode support for MCPModRef'09: Gecode support for MCP
ModRef'09: Gecode support for MCP
 
Lightspeed Preprint
Lightspeed PreprintLightspeed Preprint
Lightspeed Preprint
 
New Directions for Mahout
New Directions for MahoutNew Directions for Mahout
New Directions for Mahout
 

More from ESUG

Workshop: Identifying concept inventories in agile programming
Workshop: Identifying concept inventories in agile programmingWorkshop: Identifying concept inventories in agile programming
Workshop: Identifying concept inventories in agile programmingESUG
 
Technical documentation support in Pharo
Technical documentation support in PharoTechnical documentation support in Pharo
Technical documentation support in PharoESUG
 
The Pharo Debugger and Debugging tools: Advances and Roadmap
The Pharo Debugger and Debugging tools: Advances and RoadmapThe Pharo Debugger and Debugging tools: Advances and Roadmap
The Pharo Debugger and Debugging tools: Advances and RoadmapESUG
 
Sequence: Pipeline modelling in Pharo
Sequence: Pipeline modelling in PharoSequence: Pipeline modelling in Pharo
Sequence: Pipeline modelling in PharoESUG
 
Migration process from monolithic to micro frontend architecture in mobile ap...
Migration process from monolithic to micro frontend architecture in mobile ap...Migration process from monolithic to micro frontend architecture in mobile ap...
Migration process from monolithic to micro frontend architecture in mobile ap...ESUG
 
Analyzing Dart Language with Pharo: Report and early results
Analyzing Dart Language with Pharo: Report and early resultsAnalyzing Dart Language with Pharo: Report and early results
Analyzing Dart Language with Pharo: Report and early resultsESUG
 
Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6
Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6
Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6ESUG
 
A Unit Test Metamodel for Test Generation
A Unit Test Metamodel for Test GenerationA Unit Test Metamodel for Test Generation
A Unit Test Metamodel for Test GenerationESUG
 
Creating Unit Tests Using Genetic Programming
Creating Unit Tests Using Genetic ProgrammingCreating Unit Tests Using Genetic Programming
Creating Unit Tests Using Genetic ProgrammingESUG
 
Threaded-Execution and CPS Provide Smooth Switching Between Execution Modes
Threaded-Execution and CPS Provide Smooth Switching Between Execution ModesThreaded-Execution and CPS Provide Smooth Switching Between Execution Modes
Threaded-Execution and CPS Provide Smooth Switching Between Execution ModesESUG
 
Exploring GitHub Actions through EGAD: An Experience Report
Exploring GitHub Actions through EGAD: An Experience ReportExploring GitHub Actions through EGAD: An Experience Report
Exploring GitHub Actions through EGAD: An Experience ReportESUG
 
Pharo: a reflective language A first systematic analysis of reflective APIs
Pharo: a reflective language A first systematic analysis of reflective APIsPharo: a reflective language A first systematic analysis of reflective APIs
Pharo: a reflective language A first systematic analysis of reflective APIsESUG
 
Garbage Collector Tuning
Garbage Collector TuningGarbage Collector Tuning
Garbage Collector TuningESUG
 
Improving Performance Through Object Lifetime Profiling: the DataFrame Case
Improving Performance Through Object Lifetime Profiling: the DataFrame CaseImproving Performance Through Object Lifetime Profiling: the DataFrame Case
Improving Performance Through Object Lifetime Profiling: the DataFrame CaseESUG
 
Pharo DataFrame: Past, Present, and Future
Pharo DataFrame: Past, Present, and FuturePharo DataFrame: Past, Present, and Future
Pharo DataFrame: Past, Present, and FutureESUG
 
thisContext in the Debugger
thisContext in the DebuggerthisContext in the Debugger
thisContext in the DebuggerESUG
 
Websockets for Fencing Score
Websockets for Fencing ScoreWebsockets for Fencing Score
Websockets for Fencing ScoreESUG
 
ShowUs: PharoJS.org Develop in Pharo, Run on JavaScript
ShowUs: PharoJS.org Develop in Pharo, Run on JavaScriptShowUs: PharoJS.org Develop in Pharo, Run on JavaScript
ShowUs: PharoJS.org Develop in Pharo, Run on JavaScriptESUG
 
Advanced Object- Oriented Design Mooc
Advanced Object- Oriented Design MoocAdvanced Object- Oriented Design Mooc
Advanced Object- Oriented Design MoocESUG
 
A New Architecture Reconciling Refactorings and Transformations
A New Architecture Reconciling Refactorings and TransformationsA New Architecture Reconciling Refactorings and Transformations
A New Architecture Reconciling Refactorings and TransformationsESUG
 

More from ESUG (20)

Workshop: Identifying concept inventories in agile programming
Workshop: Identifying concept inventories in agile programmingWorkshop: Identifying concept inventories in agile programming
Workshop: Identifying concept inventories in agile programming
 
Technical documentation support in Pharo
Technical documentation support in PharoTechnical documentation support in Pharo
Technical documentation support in Pharo
 
The Pharo Debugger and Debugging tools: Advances and Roadmap
The Pharo Debugger and Debugging tools: Advances and RoadmapThe Pharo Debugger and Debugging tools: Advances and Roadmap
The Pharo Debugger and Debugging tools: Advances and Roadmap
 
Sequence: Pipeline modelling in Pharo
Sequence: Pipeline modelling in PharoSequence: Pipeline modelling in Pharo
Sequence: Pipeline modelling in Pharo
 
Migration process from monolithic to micro frontend architecture in mobile ap...
Migration process from monolithic to micro frontend architecture in mobile ap...Migration process from monolithic to micro frontend architecture in mobile ap...
Migration process from monolithic to micro frontend architecture in mobile ap...
 
Analyzing Dart Language with Pharo: Report and early results
Analyzing Dart Language with Pharo: Report and early resultsAnalyzing Dart Language with Pharo: Report and early results
Analyzing Dart Language with Pharo: Report and early results
 
Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6
Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6
Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6
 
A Unit Test Metamodel for Test Generation
A Unit Test Metamodel for Test GenerationA Unit Test Metamodel for Test Generation
A Unit Test Metamodel for Test Generation
 
Creating Unit Tests Using Genetic Programming
Creating Unit Tests Using Genetic ProgrammingCreating Unit Tests Using Genetic Programming
Creating Unit Tests Using Genetic Programming
 
Threaded-Execution and CPS Provide Smooth Switching Between Execution Modes
Threaded-Execution and CPS Provide Smooth Switching Between Execution ModesThreaded-Execution and CPS Provide Smooth Switching Between Execution Modes
Threaded-Execution and CPS Provide Smooth Switching Between Execution Modes
 
Exploring GitHub Actions through EGAD: An Experience Report
Exploring GitHub Actions through EGAD: An Experience ReportExploring GitHub Actions through EGAD: An Experience Report
Exploring GitHub Actions through EGAD: An Experience Report
 
Pharo: a reflective language A first systematic analysis of reflective APIs
Pharo: a reflective language A first systematic analysis of reflective APIsPharo: a reflective language A first systematic analysis of reflective APIs
Pharo: a reflective language A first systematic analysis of reflective APIs
 
Garbage Collector Tuning
Garbage Collector TuningGarbage Collector Tuning
Garbage Collector Tuning
 
Improving Performance Through Object Lifetime Profiling: the DataFrame Case
Improving Performance Through Object Lifetime Profiling: the DataFrame CaseImproving Performance Through Object Lifetime Profiling: the DataFrame Case
Improving Performance Through Object Lifetime Profiling: the DataFrame Case
 
Pharo DataFrame: Past, Present, and Future
Pharo DataFrame: Past, Present, and FuturePharo DataFrame: Past, Present, and Future
Pharo DataFrame: Past, Present, and Future
 
thisContext in the Debugger
thisContext in the DebuggerthisContext in the Debugger
thisContext in the Debugger
 
Websockets for Fencing Score
Websockets for Fencing ScoreWebsockets for Fencing Score
Websockets for Fencing Score
 
ShowUs: PharoJS.org Develop in Pharo, Run on JavaScript
ShowUs: PharoJS.org Develop in Pharo, Run on JavaScriptShowUs: PharoJS.org Develop in Pharo, Run on JavaScript
ShowUs: PharoJS.org Develop in Pharo, Run on JavaScript
 
Advanced Object- Oriented Design Mooc
Advanced Object- Oriented Design MoocAdvanced Object- Oriented Design Mooc
Advanced Object- Oriented Design Mooc
 
A New Architecture Reconciling Refactorings and Transformations
A New Architecture Reconciling Refactorings and TransformationsA New Architecture Reconciling Refactorings and Transformations
A New Architecture Reconciling Refactorings and Transformations
 

Recently uploaded

Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetHyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetEnjoy Anytime
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Hyundai Motor Group
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 

Recently uploaded (20)

Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetHyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2
 
The transition to renewables in India.pdf
The transition to renewables in India.pdfThe transition to renewables in India.pdf
The transition to renewables in India.pdf
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 

Profilling Zoo

  • 1. Profiler Zoo Alexandre Bergel abergel@dcc.uchile.cl Pleiad lab, UChile, Chile
  • 2. 2
  • 3. Test coverage Problem: Traditional code coverage tools have a binary view of the world Why the problem is important: Which method should you test first in order to increase the coverage? Is my code well covered or not? Solution: An intuitive visual representation of a qualitative assessment of the coverage 3
  • 4. Test blueprint C1 Legend for methods (inner boxes) # calling methods d complexity # executions c invocation on self C2 red = not executed blue = abstract 4
  • 5. Successive improvement Version 2.2 Version 2.3 Version 2.4 Version 2.5 27.27% 54.54% 87.71% 100% 5
  • 7. Moose-Test-Core.13 Moose-Test-Core.48 Moose-Core.313 Moose-Core.326 21.42% 100% 56.86% 100% 73.58% 100% 68.25% 96.66% 36.78% 64.55% 0% 100% 7
  • 8. Reducing code complexity Version 1.58.1 Version 1.58.9 Coverage: 40.57% Coverage: 60.60% 8
  • 9. Reducing code complexity Version 2.10 Version 2.17 9
  • 10. Execution profiling Problem: Traditional code profilers are driven by the method stack, discarding the notion of sending messages Why the problem is important: How to answer to “Is there a slow function that is called too often?” Solution: An intuitive visual representation of the execution that visually compare the time spent and the number of executions 10
  • 11. Structural profiling blueprint legend for methods # executions (color) execution #different time receiver 11
  • 12. Structural profiling blueprint bounds legend for methods # executions (color) execution #different time receiver 12
  • 13. Behavioral profiling blueprint legend for methods # executions gray = return m1 m3 self execution m1 time yellow = invokes constant m2 m2 and m3 on return value 13
  • 14. Behavioral profiling blueprint legend for methods # executions gray = return m1 m3 self execution m1 time yellow = invokes m2 m2 and m3 bounds constant on return value 14
  • 15. 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 15
  • 16. 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 16
  • 17. Upgrading MOGraphElement>>bounds A B C 17
  • 18. 43% speedup Upgrading MOGraphElement>>bounds A B C 18
  • 19. A Upgrading MOGraphElement>>bounds B 19
  • 20. B C A cached absoluteBounds instea A' C' B' C' 20
  • 21. Measuring execution time Problem: Traditional code profilers sample program execution at a regular interval. This is inaccurate, non portable and non deterministic Why the problem is important: all profiles are meaningless if I get a new laptop or change the virtual machine cannot profile short execution time Solution: counting messages as a proxy for execution time 21
  • 22. Counting messages Wallet >> increaseByOne money := money + 1 Wallet >> increaseBy3 self increaseByOne; increaseByOne; increaseByOne. aWallet increaseBy3 => 6 messages sent 22
  • 23. Execution time and number of message sends 6 400 x 10 message sends 400000000 6 300 x 10 300000000 6 200 x 10 200000000 6 100 x 10 100000000 0 0 10000 20000 30000 40000 times (ms) 23
  • 24. Counting Messages to Identify Execution Bottlenecks 6 number of method 10000000 10.0 x 10 invocations 6 7500000 7.5 x 10 6 5.0 x 10 5000000 6 2.5 x 10 2500000 0 0 75 150 225 300 time (ms) 24
  • 25. Contrasting Execution Sampling with Message Counting No need for sampling Independent from the execution environment Stable measurements 25
  • 26. Counting messages in unit testing CollectionTest>>testInsertion self assert: [ Set new add: 1 ] fasterThan: [Set new add: 1; add: 2 ] 26
  • 27. Counting messages in unit testing MondrianSpeedTest>> testLayout2 | view1 view2 | view1 := MOViewRenderer new. view1 nodes: (Collection allSubclasses). view1 edgesFrom: #superclass. view1 treeLayout. view2 := MOViewRenderer new. view2 nodes: (Collection withAllSubclasses). view2 edgesFrom: #superclass. view2 treeLayout. self assertIs: [ view1 root applyLayout ] fasterThan: [ view2 root applyLayout ] 27
  • 29. Identifying redundant computation Problem: Traditional code profiler cannot determine whether the same computation is realized twice or more Why the problem is important: Redundant computation cannot be identified and removed without heavily involving programmer imagination Solution: Finding side-effect-free methods that are executed more than once 29
  • 30. Example MOGraphElement>> absoluteBounds ^ self shape absoluteBoundsFor: self MOGraphElement>> absoluteBounds boundsCache ifNotNil: [ ^ boundsCache ]. ^ boundsCache := self shape absoluteBoundsFor: self MONode>> translateBy: realStep boundsCache := nil. ... 30
  • 31. Example AbstractNautilusUI>>packageIconFor: aPackage |t| (packageIconCache notNil and: [ packageIconCache includesKey: aPackage ]) ifTrue: [ ˆ packageIconCache at: aPackage ]. packageIconCache ifNil: [ packageIconCache := IdentityDictionary new ]. aPackage isDirty ifTrue: [ ˆ IconicButton new ]. t := self iconClass iconNamed: #packageIcon. packageIconCache at: aPackage put: t. ˆt 31
  • 32. Identifying memoization candidate A method is candidate for being memoized if it is executed more than once on a particular object it returns the same value per receiver and arguments it does not any “perceptible” side effect its execution is sufficiently long 32
  • 33. Experiment We took 11 applications and profiled their unit tests We identified candidates for each of them We memoized some of the candidates The tests are kept green 33
  • 34. 34
  • 35. Execution time In some case we reduce the execution time by 20% e.g., Nautilus In some other case, the execution time increased (!) This is the case for very short methods 35
  • 36. Research questions Is there a general way to identify redundant messages by monitoring program execution? Can redundant messages be removed while preserving the overall program behavior? 36
  • 37. The Spy profiling framework Core MethodSpy Profiler methodName packages ClassSpy class currentTest PackageSpy spyClassForMethod originalMethod profile: aBlock spyClassForClass package outgoingCalls runTests: tests packageName superclass incomingCalls spyClassForPackage classes metaclass timeExecution allMethods methods afterRun:with: in: registryName beforeRun:with:in: run:with:in: TestCoverage TCMethod numberOfExectutions TestCoverage receiverTable spyClassForPackage beforeRun:with:in: view TCPackage TCClass numberOfDifferentReceivers ratioExecutedMethods spyClassForClass spyClassForMethod nbOfExecutions ratioCoveredClasses isCovered viewBasicOn: initialize registryName viewBasicOn: 37
  • 38. Closing words Little innovation in the tools we commonly use Profilers & debuggers have not significantly evolves Fantastic opportunities for improvement 38
  • 39. Thanks to Laurent Laffont, RMoD inria group all the people who participated in our experiments 39
  • 40. Test coverage with Hapao Moose-Test-Core.13 Moose-Test-Core.48 Profiling blueprints Moose-Core.313 Moose-Core.326 21.42% 100% Proxy for execution time Identifying redundant computation 56.86% 100% 73.58% 100% 68.25% 96.66% 36.78% 64.55% 0% 100% Profiler Zoo http://bergel.eu http://hapao.dcc.uchile.cl http://moosetechnology.org/tools/spy 40