SlideShare ist ein Scribd-Unternehmen logo
1 von 25
Downloaden Sie, um offline zu lesen
Motivation                         First Approach                Aspect-based Refactoring             Results




                        Memoization Aspects: a Case Study

         Santiago A. Vidal
                                          1,2       Claudia A. Marcos
                                                                           1   Alexandre Bergel
                                                                                                  3
                                                Gabriela Arévalo
                                                                     2,4

                               1
                                   ISISTAN Research Institute, Faculty of Sciences,
                                          UNICEN University, Argentina
                   2
                       CONICET (National Scientic and Technical Research Council)
                         3
                             PLEIAD Lab, Department of Computer Science (DCC),
                                         University of Chile, Chile
                                   4
                                       Universidad Nacional de Quilmes, Argentina,

         International Workshop on Smalltalk Technologies (ESUG 2011)




1 / 17       S. Vidal, C. Marcos, A. Bergel, G. Arévalo       Memoization Aspects: a Case Study
Motivation                   First Approach                  Aspect-based Refactoring         Results



 Mondrian

             Mondrian is an agile visualization engine implemented in
             Pharo, and has been used in more than a dozen projects




2 / 17       S. Vidal, C. Marcos, A. Bergel, G. Arévalo   Memoization Aspects: a Case Study
Motivation                   First Approach                  Aspect-based Refactoring         Results



 Dealing with Mondrian Evolution
             Mondrian has several caches
             Each unpredictable usage led to a performance problem that
             has been solved using a new memoization.




3 / 17       S. Vidal, C. Marcos, A. Bergel, G. Arévalo   Memoization Aspects: a Case Study
Motivation                   First Approach                  Aspect-based Refactoring         Results



 Mondrian Computations



         Memoization

         An optimization technique used to speed up an application by
         making calls that avoid repeating the similar previous computation


         Mondrian caches are instances of the memoization technique

         MOGraphElementabsoluteBounds
            absoluteBoundsCache
               ifNotNil: [ ^ absoluteBoundsCache ].
            ^ absoluteBoundsCache:= self shape absoluteBoundsFor: self




4 / 17       S. Vidal, C. Marcos, A. Bergel, G. Arévalo   Memoization Aspects: a Case Study
Motivation                   First Approach                  Aspect-based Refactoring         Results



 Proposal


         Problems

             The caches that are used intensively when visualizing software
             are not useful and may even be a source of slowdown and
             complexity in other contexts.

             The legibility of the methods with memoization has been
             aected.




5 / 17       S. Vidal, C. Marcos, A. Bergel, G. Arévalo   Memoization Aspects: a Case Study
Motivation                   First Approach                  Aspect-based Refactoring         Results



 Proposal


         Problems

             The caches that are used intensively when visualizing software
             are not useful and may even be a source of slowdown and
             complexity in other contexts.

             The legibility of the methods with memoization has been
             aected.


         Goals

             Identication of memoizing crosscutting concerns

             Refactorization of these crosscutting concerns into modular
             and pluggable aspects




5 / 17       S. Vidal, C. Marcos, A. Bergel, G. Arévalo   Memoization Aspects: a Case Study
Motivation                   First Approach                  Aspect-based Refactoring         Results



 A Naive Solution

             General operations for accessing and resetting a cache




6 / 17       S. Vidal, C. Marcos, A. Bergel, G. Arévalo   Memoization Aspects: a Case Study
Motivation                   First Approach                  Aspect-based Refactoring         Results



 A Naive Solution

             General operations for accessing and resetting a cache




         Problem

             Signicant overhead (3 to 10 times slower)




6 / 17       S. Vidal, C. Marcos, A. Bergel, G. Arévalo   Memoization Aspects: a Case Study
Motivation                   First Approach                  Aspect-based Refactoring         Results



 Requirements for Refactoring


             All cache accesses have to be identied. This is essential to
             have all the caches considered equally.

             No cost of performance must be paid, or it defeats the whole
             purpose of the work.

             Readability must not be reduced.




7 / 17       S. Vidal, C. Marcos, A. Bergel, G. Arévalo   Memoization Aspects: a Case Study
Motivation                   First Approach                  Aspect-based Refactoring         Results



 Identifying caches


             The caches are mostly identied by browsing the methods in
             which the cache variables are referenced and accessed.




8 / 17       S. Vidal, C. Marcos, A. Bergel, G. Arévalo   Memoization Aspects: a Case Study
Motivation                   First Approach                  Aspect-based Refactoring         Results



 Identifying caches


             The caches are mostly identied by browsing the methods in
             which the cache variables are referenced and accessed.


             9 caches were found.




8 / 17       S. Vidal, C. Marcos, A. Bergel, G. Arévalo   Memoization Aspects: a Case Study
Motivation                   First Approach                  Aspect-based Refactoring         Results



 Identifying caches


             The caches are mostly identied by browsing the methods in
             which the cache variables are referenced and accessed.


             9 caches were found.


             The caches were grouped together based on the purpose of its
             use:

                    Initialize and reset the cache
                    Retrieve the cache value
                    Store data in the cache



8 / 17       S. Vidal, C. Marcos, A. Bergel, G. Arévalo   Memoization Aspects: a Case Study
Motivation                   First Approach                  Aspect-based Refactoring         Results



 Identifying caches


             The caches are mostly identied by browsing the methods in
             which the cache variables are referenced and accessed.


             9 caches were found.


             The caches were grouped together based on the purpose of its
             use:

                    Initialize and reset the cache
                    Retrieve the cache value
                    Store data in the cache
         These groups allow the identication of code patterns.




8 / 17       S. Vidal, C. Marcos, A. Bergel, G. Arévalo   Memoization Aspects: a Case Study
Motivation                    First Approach                             Aspect-based Refactoring               Results



 Patterns identied
                                                      MOGraphElement
                                            -cacheShapeBounds                        LI: lazy initialization
                                            -cacheForm
                                            -boundsCache                             CI: cache initialization
                                            -absoluteBoundsCache
                                            -elementsToDisplayCache
                                                                                     ResC: reset cache
                                            -lookupNodeCache                         RetC: return cache
                                            absoluteBounds
                                     LI     bounds                                   CL: cache loaded
                                            elementsToDisplay
                                     CI     cacheCanvas
                                            isCacheLoaded
                                            resetAbsoluteBoundsCacheRecursively
                                            resetCache
                                 ResC       resetElementsToDisplayCache
                                            resetFormCache
                                            resetFormCacheRecursively
                                            resetFormCacheToTheRoot
                                            shapeBoundsAt:put:
                                  RetC      shapeBounds




                                MOEdge                                         MONode
                          -cacheFromPoint
                          -cacheToPoint                        RetC      cacheForm
                     LI   bounds                                         scaleBy:
                                                               ResC      translateBy:bounded:
                    CL    isCacheLoaded
                  ResC    resetCache
                          cacheFromPoint:
                    CI    cacheToPoint:
                          cacheFromPoint                                       MORoot
                  RetC    cacheToPoint                                   -cacheBounds
                                                                    LI   bounds




9 / 17       S. Vidal, C. Marcos, A. Bergel, G. Arévalo             Memoization Aspects: a Case Study
Motivation                   First Approach                  Aspect-based Refactoring         Results



 Pattern description

      Lazy Initialization:            In some situations it is not relevant to
      initialize the cache before it is actually needed.

      MOEdgebounds
         ^ boundsCache ifNil:[boundsCache:= self shape
          computeBoundsFor: self ].

      Reset Cache:           A cache has to be invalidated when its content has
      to be updated.

      MOGraphElementresetCache
         self resetElementsToLookup.
         boundsCache := nil.
         absoluteBoundsCache := nil.
         cacheShapeBounds :=SmallDictionary new.
         elementsToDisplayCache := nil.
         self resetMetricCaches



10 / 17      S. Vidal, C. Marcos, A. Bergel, G. Arévalo   Memoization Aspects: a Case Study
Motivation                   First Approach                  Aspect-based Refactoring         Results



 Cache Concerns as Aspects

             The goal of the refactorization is the separation of these
             patterns from the main code without changing the overall
             behavior.




11 / 17      S. Vidal, C. Marcos, A. Bergel, G. Arévalo   Memoization Aspects: a Case Study
Motivation                   First Approach                  Aspect-based Refactoring         Results



 Cache Concerns as Aspects

             The goal of the refactorization is the separation of these
             patterns from the main code without changing the overall
             behavior.


             Aspect weaving is achieved via a customized AOP mechanism
             based on code annotation and source code manipulation.




11 / 17      S. Vidal, C. Marcos, A. Bergel, G. Arévalo   Memoization Aspects: a Case Study
Motivation                   First Approach                  Aspect-based Refactoring         Results



 Cache Concerns as Aspects

             The goal of the refactorization is the separation of these
             patterns from the main code without changing the overall
             behavior.


             Aspect weaving is achieved via a customized AOP mechanism
             based on code annotation and source code manipulation.


             Refactoring strategy: for each method that involves a cache,
             the part of the method that deals directly with the cache is
             removed and the method is annotated.




11 / 17      S. Vidal, C. Marcos, A. Bergel, G. Arévalo   Memoization Aspects: a Case Study
Motivation                   First Approach                  Aspect-based Refactoring         Results



 Cache Concerns as Aspects

             The goal of the refactorization is the separation of these
             patterns from the main code without changing the overall
             behavior.


             Aspect weaving is achieved via a customized AOP mechanism
             based on code annotation and source code manipulation.


             Refactoring strategy: for each method that involves a cache,
             the part of the method that deals directly with the cache is
             removed and the method is annotated.


             The annotation structure is patternCodeName: cacheName

                      LazyInitializationPattern: #absoluteBoundsCache

11 / 17      S. Vidal, C. Marcos, A. Bergel, G. Arévalo   Memoization Aspects: a Case Study
Motivation                    First Approach                  Aspect-based Refactoring         Results



 Injection Mechanism I

      For every annotation a method may have, the code injector
      performs the needed source code transformation to use the cache.

          1   A new method is created with the same name as the method
              that contains the annotation but with the prex  compute
              plus the name of the class in which is dened.

              MOEdgebounds
              LazyInitializationPattern: #boundsCache
                 ^ self shape computeBoundsFor: self.

              MOEdgecomputeMOEdgeBounds

          2   The code of the original method is copied into the new one.

              MOEdgecomputeMOEdgeBounds
                 ^ self shape computeBoundsFor: self.



12 / 17       S. Vidal, C. Marcos, A. Bergel, G. Arévalo   Memoization Aspects: a Case Study
Motivation                    First Approach                  Aspect-based Refactoring         Results



 Injection Mechanism II



          3   The code inside the original method is replaced by the code
              automatically generated according to the pattern dened in
              the annotation

              MOEdgebounds
                 boundsCache ifNotNil: [ ^ boundsCache].
                 ^ boundsCache:= computeMOEdgeBounds




13 / 17       S. Vidal, C. Marcos, A. Bergel, G. Arévalo   Memoization Aspects: a Case Study
Motivation                   First Approach                  Aspect-based Refactoring         Results



 Injection Mechanism III




14 / 17      S. Vidal, C. Marcos, A. Bergel, G. Arévalo   Memoization Aspects: a Case Study
Motivation                    First Approach                  Aspect-based Refactoring         Results



 Maintainability




      The contribution of this approach is twofold:

          1   The mechanism of encapsulation and injection can be used to
              refactor the current Mondrian caches improving the code reuse.

          2   The code legibility is increased because the Cache Concern is
              extracted from the main concern leaving a cleaner code.




15 / 17       S. Vidal, C. Marcos, A. Bergel, G. Arévalo   Memoization Aspects: a Case Study
Motivation                    First Approach                      Aspect-based Refactoring         Results



 Performance




          d




                                  E                        
                                                                                      




16 / 17       S. Vidal, C. Marcos, A. Bergel, G. Arévalo       Memoization Aspects: a Case Study
Motivation                   First Approach                  Aspect-based Refactoring         Results




17 / 17      S. Vidal, C. Marcos, A. Bergel, G. Arévalo   Memoization Aspects: a Case Study

Weitere ähnliche Inhalte

Ähnlich wie Memoization Aspects: a Case Study Optimization of Mondrian Visualization Engine

Memory Heap Analysis with AppDynamics - AppSphere16
Memory Heap Analysis with AppDynamics - AppSphere16Memory Heap Analysis with AppDynamics - AppSphere16
Memory Heap Analysis with AppDynamics - AppSphere16AppDynamics
 
Rattani - Ph.D. Defense Slides
Rattani - Ph.D. Defense SlidesRattani - Ph.D. Defense Slides
Rattani - Ph.D. Defense SlidesPluribus One
 
GECCO'2006: Bounding XCS’s Parameters for Unbalanced Datasets
GECCO'2006: Bounding XCS’s Parameters for Unbalanced DatasetsGECCO'2006: Bounding XCS’s Parameters for Unbalanced Datasets
GECCO'2006: Bounding XCS’s Parameters for Unbalanced DatasetsAlbert Orriols-Puig
 
ShawnQuinnCSS581FinalProjectReport
ShawnQuinnCSS581FinalProjectReportShawnQuinnCSS581FinalProjectReport
ShawnQuinnCSS581FinalProjectReportShawn Quinn
 
Modeling selection pressure in XCS for proportionate and tournament selection
Modeling selection pressure in XCS for proportionate and tournament selectionModeling selection pressure in XCS for proportionate and tournament selection
Modeling selection pressure in XCS for proportionate and tournament selectionkknsastry
 
Substructrual surrogates for learning decomposable classification problems: i...
Substructrual surrogates for learning decomposable classification problems: i...Substructrual surrogates for learning decomposable classification problems: i...
Substructrual surrogates for learning decomposable classification problems: i...kknsastry
 
Granatum_LiSIs_BIBE_2012_presentation_v4.0
Granatum_LiSIs_BIBE_2012_presentation_v4.0Granatum_LiSIs_BIBE_2012_presentation_v4.0
Granatum_LiSIs_BIBE_2012_presentation_v4.0Christos Kannas
 
Memory Leak Profiling with NetBeans and HotSpot
Memory Leak Profiling with NetBeans and HotSpotMemory Leak Profiling with NetBeans and HotSpot
Memory Leak Profiling with NetBeans and HotSpotjavapsyche
 

Ähnlich wie Memoization Aspects: a Case Study Optimization of Mondrian Visualization Engine (11)

Lecture8 - From CBR to IBk
Lecture8 - From CBR to IBkLecture8 - From CBR to IBk
Lecture8 - From CBR to IBk
 
Memory Heap Analysis with AppDynamics - AppSphere16
Memory Heap Analysis with AppDynamics - AppSphere16Memory Heap Analysis with AppDynamics - AppSphere16
Memory Heap Analysis with AppDynamics - AppSphere16
 
Rattani - Ph.D. Defense Slides
Rattani - Ph.D. Defense SlidesRattani - Ph.D. Defense Slides
Rattani - Ph.D. Defense Slides
 
GECCO'2006: Bounding XCS’s Parameters for Unbalanced Datasets
GECCO'2006: Bounding XCS’s Parameters for Unbalanced DatasetsGECCO'2006: Bounding XCS’s Parameters for Unbalanced Datasets
GECCO'2006: Bounding XCS’s Parameters for Unbalanced Datasets
 
ShawnQuinnCSS581FinalProjectReport
ShawnQuinnCSS581FinalProjectReportShawnQuinnCSS581FinalProjectReport
ShawnQuinnCSS581FinalProjectReport
 
Modeling selection pressure in XCS for proportionate and tournament selection
Modeling selection pressure in XCS for proportionate and tournament selectionModeling selection pressure in XCS for proportionate and tournament selection
Modeling selection pressure in XCS for proportionate and tournament selection
 
Substructrual surrogates for learning decomposable classification problems: i...
Substructrual surrogates for learning decomposable classification problems: i...Substructrual surrogates for learning decomposable classification problems: i...
Substructrual surrogates for learning decomposable classification problems: i...
 
Executable Biology Tutorial
Executable Biology TutorialExecutable Biology Tutorial
Executable Biology Tutorial
 
Granatum_LiSIs_BIBE_2012_presentation_v4.0
Granatum_LiSIs_BIBE_2012_presentation_v4.0Granatum_LiSIs_BIBE_2012_presentation_v4.0
Granatum_LiSIs_BIBE_2012_presentation_v4.0
 
LaSo
LaSoLaSo
LaSo
 
Memory Leak Profiling with NetBeans and HotSpot
Memory Leak Profiling with NetBeans and HotSpotMemory Leak Profiling with NetBeans and HotSpot
Memory Leak Profiling with NetBeans and HotSpot
 

Mehr von 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
 

Mehr von 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
 

Kürzlich hochgeladen

Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Strongerpanagenda
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesThousandEyes
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...panagenda
 
Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditSkynet Technologies
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesThousandEyes
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Scott Andery
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...AliaaTarek5
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 

Kürzlich hochgeladen (20)

Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
 
Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance Audit
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 

Memoization Aspects: a Case Study Optimization of Mondrian Visualization Engine

  • 1. Motivation First Approach Aspect-based Refactoring Results Memoization Aspects: a Case Study Santiago A. Vidal 1,2 Claudia A. Marcos 1 Alexandre Bergel 3 Gabriela Arévalo 2,4 1 ISISTAN Research Institute, Faculty of Sciences, UNICEN University, Argentina 2 CONICET (National Scientic and Technical Research Council) 3 PLEIAD Lab, Department of Computer Science (DCC), University of Chile, Chile 4 Universidad Nacional de Quilmes, Argentina, International Workshop on Smalltalk Technologies (ESUG 2011) 1 / 17 S. Vidal, C. Marcos, A. Bergel, G. Arévalo Memoization Aspects: a Case Study
  • 2. Motivation First Approach Aspect-based Refactoring Results Mondrian Mondrian is an agile visualization engine implemented in Pharo, and has been used in more than a dozen projects 2 / 17 S. Vidal, C. Marcos, A. Bergel, G. Arévalo Memoization Aspects: a Case Study
  • 3. Motivation First Approach Aspect-based Refactoring Results Dealing with Mondrian Evolution Mondrian has several caches Each unpredictable usage led to a performance problem that has been solved using a new memoization. 3 / 17 S. Vidal, C. Marcos, A. Bergel, G. Arévalo Memoization Aspects: a Case Study
  • 4. Motivation First Approach Aspect-based Refactoring Results Mondrian Computations Memoization An optimization technique used to speed up an application by making calls that avoid repeating the similar previous computation Mondrian caches are instances of the memoization technique MOGraphElementabsoluteBounds absoluteBoundsCache ifNotNil: [ ^ absoluteBoundsCache ]. ^ absoluteBoundsCache:= self shape absoluteBoundsFor: self 4 / 17 S. Vidal, C. Marcos, A. Bergel, G. Arévalo Memoization Aspects: a Case Study
  • 5. Motivation First Approach Aspect-based Refactoring Results Proposal Problems The caches that are used intensively when visualizing software are not useful and may even be a source of slowdown and complexity in other contexts. The legibility of the methods with memoization has been aected. 5 / 17 S. Vidal, C. Marcos, A. Bergel, G. Arévalo Memoization Aspects: a Case Study
  • 6. Motivation First Approach Aspect-based Refactoring Results Proposal Problems The caches that are used intensively when visualizing software are not useful and may even be a source of slowdown and complexity in other contexts. The legibility of the methods with memoization has been aected. Goals Identication of memoizing crosscutting concerns Refactorization of these crosscutting concerns into modular and pluggable aspects 5 / 17 S. Vidal, C. Marcos, A. Bergel, G. Arévalo Memoization Aspects: a Case Study
  • 7. Motivation First Approach Aspect-based Refactoring Results A Naive Solution General operations for accessing and resetting a cache 6 / 17 S. Vidal, C. Marcos, A. Bergel, G. Arévalo Memoization Aspects: a Case Study
  • 8. Motivation First Approach Aspect-based Refactoring Results A Naive Solution General operations for accessing and resetting a cache Problem Signicant overhead (3 to 10 times slower) 6 / 17 S. Vidal, C. Marcos, A. Bergel, G. Arévalo Memoization Aspects: a Case Study
  • 9. Motivation First Approach Aspect-based Refactoring Results Requirements for Refactoring All cache accesses have to be identied. This is essential to have all the caches considered equally. No cost of performance must be paid, or it defeats the whole purpose of the work. Readability must not be reduced. 7 / 17 S. Vidal, C. Marcos, A. Bergel, G. Arévalo Memoization Aspects: a Case Study
  • 10. Motivation First Approach Aspect-based Refactoring Results Identifying caches The caches are mostly identied by browsing the methods in which the cache variables are referenced and accessed. 8 / 17 S. Vidal, C. Marcos, A. Bergel, G. Arévalo Memoization Aspects: a Case Study
  • 11. Motivation First Approach Aspect-based Refactoring Results Identifying caches The caches are mostly identied by browsing the methods in which the cache variables are referenced and accessed. 9 caches were found. 8 / 17 S. Vidal, C. Marcos, A. Bergel, G. Arévalo Memoization Aspects: a Case Study
  • 12. Motivation First Approach Aspect-based Refactoring Results Identifying caches The caches are mostly identied by browsing the methods in which the cache variables are referenced and accessed. 9 caches were found. The caches were grouped together based on the purpose of its use: Initialize and reset the cache Retrieve the cache value Store data in the cache 8 / 17 S. Vidal, C. Marcos, A. Bergel, G. Arévalo Memoization Aspects: a Case Study
  • 13. Motivation First Approach Aspect-based Refactoring Results Identifying caches The caches are mostly identied by browsing the methods in which the cache variables are referenced and accessed. 9 caches were found. The caches were grouped together based on the purpose of its use: Initialize and reset the cache Retrieve the cache value Store data in the cache These groups allow the identication of code patterns. 8 / 17 S. Vidal, C. Marcos, A. Bergel, G. Arévalo Memoization Aspects: a Case Study
  • 14. Motivation First Approach Aspect-based Refactoring Results Patterns identied MOGraphElement -cacheShapeBounds LI: lazy initialization -cacheForm -boundsCache CI: cache initialization -absoluteBoundsCache -elementsToDisplayCache ResC: reset cache -lookupNodeCache RetC: return cache absoluteBounds LI bounds CL: cache loaded elementsToDisplay CI cacheCanvas isCacheLoaded resetAbsoluteBoundsCacheRecursively resetCache ResC resetElementsToDisplayCache resetFormCache resetFormCacheRecursively resetFormCacheToTheRoot shapeBoundsAt:put: RetC shapeBounds MOEdge MONode -cacheFromPoint -cacheToPoint RetC cacheForm LI bounds scaleBy: ResC translateBy:bounded: CL isCacheLoaded ResC resetCache cacheFromPoint: CI cacheToPoint: cacheFromPoint MORoot RetC cacheToPoint -cacheBounds LI bounds 9 / 17 S. Vidal, C. Marcos, A. Bergel, G. Arévalo Memoization Aspects: a Case Study
  • 15. Motivation First Approach Aspect-based Refactoring Results Pattern description Lazy Initialization: In some situations it is not relevant to initialize the cache before it is actually needed. MOEdgebounds ^ boundsCache ifNil:[boundsCache:= self shape computeBoundsFor: self ]. Reset Cache: A cache has to be invalidated when its content has to be updated. MOGraphElementresetCache self resetElementsToLookup. boundsCache := nil. absoluteBoundsCache := nil. cacheShapeBounds :=SmallDictionary new. elementsToDisplayCache := nil. self resetMetricCaches 10 / 17 S. Vidal, C. Marcos, A. Bergel, G. Arévalo Memoization Aspects: a Case Study
  • 16. Motivation First Approach Aspect-based Refactoring Results Cache Concerns as Aspects The goal of the refactorization is the separation of these patterns from the main code without changing the overall behavior. 11 / 17 S. Vidal, C. Marcos, A. Bergel, G. Arévalo Memoization Aspects: a Case Study
  • 17. Motivation First Approach Aspect-based Refactoring Results Cache Concerns as Aspects The goal of the refactorization is the separation of these patterns from the main code without changing the overall behavior. Aspect weaving is achieved via a customized AOP mechanism based on code annotation and source code manipulation. 11 / 17 S. Vidal, C. Marcos, A. Bergel, G. Arévalo Memoization Aspects: a Case Study
  • 18. Motivation First Approach Aspect-based Refactoring Results Cache Concerns as Aspects The goal of the refactorization is the separation of these patterns from the main code without changing the overall behavior. Aspect weaving is achieved via a customized AOP mechanism based on code annotation and source code manipulation. Refactoring strategy: for each method that involves a cache, the part of the method that deals directly with the cache is removed and the method is annotated. 11 / 17 S. Vidal, C. Marcos, A. Bergel, G. Arévalo Memoization Aspects: a Case Study
  • 19. Motivation First Approach Aspect-based Refactoring Results Cache Concerns as Aspects The goal of the refactorization is the separation of these patterns from the main code without changing the overall behavior. Aspect weaving is achieved via a customized AOP mechanism based on code annotation and source code manipulation. Refactoring strategy: for each method that involves a cache, the part of the method that deals directly with the cache is removed and the method is annotated. The annotation structure is patternCodeName: cacheName LazyInitializationPattern: #absoluteBoundsCache 11 / 17 S. Vidal, C. Marcos, A. Bergel, G. Arévalo Memoization Aspects: a Case Study
  • 20. Motivation First Approach Aspect-based Refactoring Results Injection Mechanism I For every annotation a method may have, the code injector performs the needed source code transformation to use the cache. 1 A new method is created with the same name as the method that contains the annotation but with the prex compute plus the name of the class in which is dened. MOEdgebounds LazyInitializationPattern: #boundsCache ^ self shape computeBoundsFor: self. MOEdgecomputeMOEdgeBounds 2 The code of the original method is copied into the new one. MOEdgecomputeMOEdgeBounds ^ self shape computeBoundsFor: self. 12 / 17 S. Vidal, C. Marcos, A. Bergel, G. Arévalo Memoization Aspects: a Case Study
  • 21. Motivation First Approach Aspect-based Refactoring Results Injection Mechanism II 3 The code inside the original method is replaced by the code automatically generated according to the pattern dened in the annotation MOEdgebounds boundsCache ifNotNil: [ ^ boundsCache]. ^ boundsCache:= computeMOEdgeBounds 13 / 17 S. Vidal, C. Marcos, A. Bergel, G. Arévalo Memoization Aspects: a Case Study
  • 22. Motivation First Approach Aspect-based Refactoring Results Injection Mechanism III 14 / 17 S. Vidal, C. Marcos, A. Bergel, G. Arévalo Memoization Aspects: a Case Study
  • 23. Motivation First Approach Aspect-based Refactoring Results Maintainability The contribution of this approach is twofold: 1 The mechanism of encapsulation and injection can be used to refactor the current Mondrian caches improving the code reuse. 2 The code legibility is increased because the Cache Concern is extracted from the main concern leaving a cleaner code. 15 / 17 S. Vidal, C. Marcos, A. Bergel, G. Arévalo Memoization Aspects: a Case Study
  • 24. Motivation First Approach Aspect-based Refactoring Results Performance d E 16 / 17 S. Vidal, C. Marcos, A. Bergel, G. Arévalo Memoization Aspects: a Case Study
  • 25. Motivation First Approach Aspect-based Refactoring Results 17 / 17 S. Vidal, C. Marcos, A. Bergel, G. Arévalo Memoization Aspects: a Case Study