SlideShare una empresa de Scribd logo
1 de 25
Descargar para leer sin conexión
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

Más contenido relacionado

Similar a Memoization Aspects

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

Más 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 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
 

Más 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

Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
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 WorkerThousandEyes
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesBoston Institute of Analytics
 
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 FresherRemote DBA Services
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfhans926745
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
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?Igalia
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
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...Martijn de Jong
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 

Último (20)

Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
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
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
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
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
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?
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
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...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 

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