SlideShare a Scribd company logo
1 of 25
Download to read offline
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

More Related Content

Similar to 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
 

Similar to 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
 

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

Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Farhan Tariq
 
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
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Alkin Tezuysal
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...Wes McKinney
 
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
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
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
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterMydbops
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Hiroshi SHIBATA
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
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
 
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
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityIES VE
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
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
 

Recently uploaded (20)

Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...
 
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
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
 
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
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
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...
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL Router
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
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
 
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
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a reality
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
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
 

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