performance analysis of synchronisation problem
TRANSCRIPT
![Page 1: Performance analysis of synchronisation problem](https://reader036.vdocuments.us/reader036/viewer/2022062503/58f14c9b1a28ab086c8b45f1/html5/thumbnails/1.jpg)
PERFORMANCE ANALYSIS OF SYNCHRONISATION PROBLEM USING ASPECT ORIENTED PROGRAMMING
Submitted by:-Harshit monish9911103466F-4
![Page 2: Performance analysis of synchronisation problem](https://reader036.vdocuments.us/reader036/viewer/2022062503/58f14c9b1a28ab086c8b45f1/html5/thumbnails/2.jpg)
OVERVIEW Cross Cutting Concerns
Logging Producer Consumer problem(synchronization)
The cost of tangled code Aspect Oriented Programming Development stage Terminology Aop benefits and oop shortcomings Producer Consumer problem
![Page 3: Performance analysis of synchronisation problem](https://reader036.vdocuments.us/reader036/viewer/2022062503/58f14c9b1a28ab086c8b45f1/html5/thumbnails/3.jpg)
CROSS CUTTING CONCERNS:- What is a crosscutting concern?
Behavior that cuts across the typical divisions of responsibility, such as logging or debugging
A problem which a program tries to solve. Aspects of a program that do not relate to the
core concerns directly, but which proper program execution nevertheless requires
![Page 4: Performance analysis of synchronisation problem](https://reader036.vdocuments.us/reader036/viewer/2022062503/58f14c9b1a28ab086c8b45f1/html5/thumbnails/4.jpg)
Function Requirements
Non-FunctionalRequirements
Production Code
=+
![Page 5: Performance analysis of synchronisation problem](https://reader036.vdocuments.us/reader036/viewer/2022062503/58f14c9b1a28ab086c8b45f1/html5/thumbnails/5.jpg)
CROSS CUTTING CONCERNS:- Examples Synchronisation Logging Authorisation Exception handling
![Page 6: Performance analysis of synchronisation problem](https://reader036.vdocuments.us/reader036/viewer/2022062503/58f14c9b1a28ab086c8b45f1/html5/thumbnails/6.jpg)
LOGGING WITHOUT AOP
![Page 7: Performance analysis of synchronisation problem](https://reader036.vdocuments.us/reader036/viewer/2022062503/58f14c9b1a28ab086c8b45f1/html5/thumbnails/7.jpg)
LOGGING WITH AOP
![Page 8: Performance analysis of synchronisation problem](https://reader036.vdocuments.us/reader036/viewer/2022062503/58f14c9b1a28ab086c8b45f1/html5/thumbnails/8.jpg)
PRODUCER CONSUMER PROBLEM
![Page 9: Performance analysis of synchronisation problem](https://reader036.vdocuments.us/reader036/viewer/2022062503/58f14c9b1a28ab086c8b45f1/html5/thumbnails/9.jpg)
TWO PROBLEMS AOP TRIES TO SOLVE
![Page 10: Performance analysis of synchronisation problem](https://reader036.vdocuments.us/reader036/viewer/2022062503/58f14c9b1a28ab086c8b45f1/html5/thumbnails/10.jpg)
TWO PROBLEMS AOP TRIES TO SOLVE
![Page 11: Performance analysis of synchronisation problem](https://reader036.vdocuments.us/reader036/viewer/2022062503/58f14c9b1a28ab086c8b45f1/html5/thumbnails/11.jpg)
THE COST OF TANGLED CODE redundant code
same fragment of code in many places difficult to reason about
non-explicit structure the big picture of the tangling isn’t clear
difficult to change have to find all the code involved and be sure to change it consistently Poor traceability Lower productivity Less code reuse Harder refactoring
![Page 12: Performance analysis of synchronisation problem](https://reader036.vdocuments.us/reader036/viewer/2022062503/58f14c9b1a28ab086c8b45f1/html5/thumbnails/12.jpg)
ASPECT ORIENTED PROGRAMMING AOP is a programming paradigm which aims
to increase modularity by allowing the separation of cross-cutting concerns
In AOP crosscutting concerns are implemented in aspects instead of fusing them into core modules.
Aspects can be reused. By reducing code tangling it makes it easier
to understand what the core functionality of a module is.
An “aspect weaver” takes the aspects and the core modules and composes the final system
![Page 13: Performance analysis of synchronisation problem](https://reader036.vdocuments.us/reader036/viewer/2022062503/58f14c9b1a28ab086c8b45f1/html5/thumbnails/13.jpg)
Coding is HARD
AOP makes it EASY
![Page 14: Performance analysis of synchronisation problem](https://reader036.vdocuments.us/reader036/viewer/2022062503/58f14c9b1a28ab086c8b45f1/html5/thumbnails/14.jpg)
AOP DEVELOPMENT STAGESIntegrating all concerns
Identify concerns
![Page 15: Performance analysis of synchronisation problem](https://reader036.vdocuments.us/reader036/viewer/2022062503/58f14c9b1a28ab086c8b45f1/html5/thumbnails/15.jpg)
What’s in it for YOU?
![Page 16: Performance analysis of synchronisation problem](https://reader036.vdocuments.us/reader036/viewer/2022062503/58f14c9b1a28ab086c8b45f1/html5/thumbnails/16.jpg)
BENEFITS Write less code Read less code More concise and easy to understand More maintainable Fewer code = Less boilerplate code More interesting work Increased attention More PRODUCTIVITY!
FEWER DEFECTS!
![Page 17: Performance analysis of synchronisation problem](https://reader036.vdocuments.us/reader036/viewer/2022062503/58f14c9b1a28ab086c8b45f1/html5/thumbnails/17.jpg)
TERMINOLOGYCross-cutting – Identify areas of code
where common functionality exists Advice – The code to be injected Joinpoint – Where one or more
aspects can be appliedPointcut – A collection of joinpointsAspect – General term for where
advice and point-cuts are combined
![Page 18: Performance analysis of synchronisation problem](https://reader036.vdocuments.us/reader036/viewer/2022062503/58f14c9b1a28ab086c8b45f1/html5/thumbnails/18.jpg)
TERMINOLOGYWeaving – Integrating applications
and aspects (e.g. AspectJ is an “aspect weaver”)
Compile-time – Can produce integrated source-code, but typically only produces woven byte-code.
Run-time – Aspects are applied “on the fly” (typically when classes are loaded)
![Page 19: Performance analysis of synchronisation problem](https://reader036.vdocuments.us/reader036/viewer/2022062503/58f14c9b1a28ab086c8b45f1/html5/thumbnails/19.jpg)
OOP SHORTCOMINGS OOP allows to decompose a system into units of
function or behavior Certain software properties cannot be isolated in
single functional unit, instead they crosscut multiple components
Such crosscutting concerns result in tangled code that is hard to develop and maintain
![Page 20: Performance analysis of synchronisation problem](https://reader036.vdocuments.us/reader036/viewer/2022062503/58f14c9b1a28ab086c8b45f1/html5/thumbnails/20.jpg)
AOP BENEFITS Separation of components and aspects
Better understanding of software because of high level of abstraction
Easier development and maintenance because tangling of code is prevented
Increased potential for reuse for both components as well as aspects
![Page 21: Performance analysis of synchronisation problem](https://reader036.vdocuments.us/reader036/viewer/2022062503/58f14c9b1a28ab086c8b45f1/html5/thumbnails/21.jpg)
AOP breaks encapsulation in a controlled manner.
Encapsulation is broken between classes and aspects.
Aspects marked as privileged have access to the private members of a class.
Encapsulation is preserved between classes.
An aspect encapsulates a crosscutting concern.
WHAT ABOUT ENCAPSULATION?
![Page 22: Performance analysis of synchronisation problem](https://reader036.vdocuments.us/reader036/viewer/2022062503/58f14c9b1a28ab086c8b45f1/html5/thumbnails/22.jpg)
PROBLEM DESCRIPTION Question: ''How to enforce synchronization
policies with AOP?''
Suppose multiple objects are concurrently working on some shared data and exclusive access is needed for modification
All objects that are working on the data must be synchronized, for example by locking the shared data temporarily
![Page 23: Performance analysis of synchronisation problem](https://reader036.vdocuments.us/reader036/viewer/2022062503/58f14c9b1a28ab086c8b45f1/html5/thumbnails/23.jpg)
PROBLEM DESCRIPTION Question: ''How to enforce synchronization
policies with AOP?''
Suppose multiple objects are concurrently working on some shared data and exclusive access is needed for modification
All objects that are working on the data must be synchronized, for example by locking the shared data temporarily
![Page 24: Performance analysis of synchronisation problem](https://reader036.vdocuments.us/reader036/viewer/2022062503/58f14c9b1a28ab086c8b45f1/html5/thumbnails/24.jpg)
OBSERVATION Without AOP
Every component that works on the shared data must take care of the locking itself, leading to tangled and complex code
With AOP The locking aspect is separated from the components
by means of an aspect module, resulting in usual benefits of modularization
![Page 25: Performance analysis of synchronisation problem](https://reader036.vdocuments.us/reader036/viewer/2022062503/58f14c9b1a28ab086c8b45f1/html5/thumbnails/25.jpg)
THE PRODUCER CONSUMER ASPECT
![Page 26: Performance analysis of synchronisation problem](https://reader036.vdocuments.us/reader036/viewer/2022062503/58f14c9b1a28ab086c8b45f1/html5/thumbnails/26.jpg)