230 likes | 342 Views
Analyzing Run-time Component Memory Consumption with Aspect-Oriented Techniques. Gati Michael. Project Members: Michel Chaudron, Merijn de Jonge, Johan Muskens. Content. Project Context and Scope Project Goals Problem Analysis Aspect-Oriented Programming Why AspectC++
E N D
Analyzing Run-time Component Memory Consumption with Aspect-Oriented Techniques Gati Michael Project Members: Michel Chaudron, Merijn de Jonge, Johan Muskens
Content • Project Context and Scope • Project Goals • Problem Analysis • Aspect-Oriented Programming • Why AspectC++ • Instrumentation using AspectC++ • Problems with AspectC++ • Results • Lessons Learned
Project Context and Scope It is part of the ROBOCOP project Enable Robust, Reliable Operations Upgrading,Extending, Trading Components Resource management (CPU, Dynamic Memory) Prediction of resource consumption Software tool
Software Tool Aspect-oriented Technique Robocop component M E A S U R E M E N T Functional model Resource model Source code model Document model Validation : Project Goals To investigate Aspect-Oriented Techniques to design and implement an automated software tool to analyze dynamic memory consumption of component-based systems.
Problem Analysis Program instrumentation • Manual • Automatic – Profiling tools Disadvantages of existing profiling tools • Application level analysis • Performance analysis Introducing Aspect-Oriented Programming(AOP) No need to build a parser Exist an Aspect Weaver-> just use it
Aspect-Oriented Programming What is AOP ? Is intended to help OOP in the implementation of crosscutting concerns. Crosscutting concern is a design decision that can not be encapsulated in a single function, class or module. Logging,Transaction,Security and Performance Provides modular implementation of crosscutting concerns The implementation is confined to modular units called aspects. OOP-> Implementation of crosscutting concerns is difficult to maintain
Why AspectC++? AspectC++ is a general-purpose aspect-oriented extension to the C++ ROBOCOP – has a C++ language characteristics
Aspect 1 Aspect 2 C++’ C++ Weaver A A B C B C Illustration of Aspect Weaver • Weaving process • Compile Transformed code • Run Transformed Extendibility Reusability The Aspect weaver inserts code fragments that are derived from aspect code whenever they are needed.
Instrumentation Concepts of AspectC++ Join points Pointcuts Named Pointcuts and Composition Match Expression Advise Example
Concepts of AspectC++ Join points Are points in the source code where aspect code should be applied: Class, Struct,Union, and Method Example of a method that affect memory use void* malloc (size_t) void* malloc (…)
Concepts of AspectC++ Pointcuts Identify a collection of join points. A collection of calls to method malloc call(“malloc(…)”); A collection of class names derived from specific class(es) derived(“myClass”); A collection to express a scope of the joint point within(“myClass”);
Concepts of AspectC++ Named pointcuts and composition A set of logical operators are used to combine pointcuts call (“void* malloc (size_t)”)|| call(“void realloc(size_t,void*)”); Pointcuts can be given names- Ease complexity Reusability
Concepts of AspectC++ Pointcut memory_allocation()=call (“void* malloc (size_t)”)|| call(“void realloc(size_t,void*)”); Now memory_allocation() is reusable
Concepts of AspectC++ Matched Expressions Are used to filter out specific join points void* myClass::malloc(size_t) Refers to malloc found only in myClass “%” increase flexibility to filter join points void* %::malloc(size_t) Refers to malloc found in any class
Concepts AspectC++ Advice Advice specifies how aspect code should be weaved into the source code. Weaving can happen: before, after or around (before & after) a join point int x=0; Advice call(“void* malloc(..)”): void after() { x++; cout<< x<<endl; } Advice Pointcut: function { Action }
Example Struct myCalc { float a,b; char a; }; int main () { myCalc* ab; (myCalc*)malloc(sizeof(myCalc)); ab.doSomething(); free(ab); };//end aspect malloc_counter { int x =0; public: Advice call(”void* malloc(…)”): void after() { x++; cout <<x<<endl; } }; //end
Problems Using AspectC++ AspectC++-0.7.2 • Compiler problems • Unrecognized C++ templates • Segmentation faults
Results Experiments were performed on two applications Chat application Linked List application • Measurements collected: • Absolute memory consumption over time • Accumulative memory consumption over time • Accumulative memory consumption over time related to method calls • Total Memory Summary
Example Output Linked list application Expected output • Allocates 3 objects each 12 byte • De-allocates 3 objects each 12 bytes • Allocates 2 objects each 12 bytes • De-allocates 2 Objects each 2 bytes
Conclusions • Investigated the feasibility of aspect-oriented technology in the context of the ROBOCOP project • The technology is viable expect for the current shortcomings • 90% of the initial goals have been achieved • 10% depends on the development of the technology. If the shortcomings will be removed in the near future-> all goals will be met
Lessons Learned • Initiative -Don’t wait till you get a big picture • Communication - Management - Domain • Gained experiences - AOP -MySQL