SlideShare uma empresa Scribd logo
1 de 25
Baixar para ler 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

Mais conteúdo relacionado

Semelhante a Memoization Aspects

Rattani - Ph.D. Defense Slides
Rattani - Ph.D. Defense SlidesRattani - Ph.D. Defense Slides
Rattani - Ph.D. Defense Slides
Pluribus 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 Datasets
Albert Orriols-Puig
 
ShawnQuinnCSS581FinalProjectReport
ShawnQuinnCSS581FinalProjectReportShawnQuinnCSS581FinalProjectReport
ShawnQuinnCSS581FinalProjectReport
Shawn Quinn
 
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
Christos 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 HotSpot
javapsyche
 

Semelhante a Memoization Aspects (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
 

Mais de 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 programming
ESUG
 
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
ESUG
 
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 results
ESUG
 
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
ESUG
 
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
ESUG
 
Creating Unit Tests Using Genetic Programming
Creating Unit Tests Using Genetic ProgrammingCreating Unit Tests Using Genetic Programming
Creating Unit Tests Using Genetic Programming
ESUG
 
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
ESUG
 
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
ESUG
 
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
ESUG
 
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
ESUG
 
Pharo DataFrame: Past, Present, and Future
Pharo DataFrame: Past, Present, and FuturePharo DataFrame: Past, Present, and Future
Pharo DataFrame: Past, Present, and Future
ESUG
 
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
ESUG
 

Mais de 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
 

Último

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Último (20)

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 

Memoization Aspects

  • 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