performance analysis of synchronisation problem

26
PERFORMANCE ANALYSIS OF SYNCHRONISATION PROBLEM USING ASPECT ORIENTED PROGRAMMING Submitted by:- Harshit monish 9911103466 F-4

Upload: harshit200793

Post on 15-Apr-2017

153 views

Category:

Engineering


2 download

TRANSCRIPT

Page 1: Performance analysis of synchronisation problem

PERFORMANCE ANALYSIS OF SYNCHRONISATION PROBLEM USING ASPECT ORIENTED PROGRAMMING

Submitted by:-Harshit monish9911103466F-4

Page 2: Performance analysis of synchronisation problem

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

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

Function Requirements

Non-FunctionalRequirements

Production Code

=+

Page 5: Performance analysis of synchronisation problem

CROSS CUTTING CONCERNS:- Examples Synchronisation Logging Authorisation Exception handling

Page 6: Performance analysis of synchronisation problem

LOGGING WITHOUT AOP

Page 7: Performance analysis of synchronisation problem

LOGGING WITH AOP

Page 8: Performance analysis of synchronisation problem

PRODUCER CONSUMER PROBLEM

Page 9: Performance analysis of synchronisation problem

TWO PROBLEMS AOP TRIES TO SOLVE

Page 10: Performance analysis of synchronisation problem

TWO PROBLEMS AOP TRIES TO SOLVE

Page 11: Performance analysis of synchronisation problem

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

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

Coding is HARD

AOP makes it EASY

Page 14: Performance analysis of synchronisation problem

AOP DEVELOPMENT STAGESIntegrating all concerns

Identify concerns

Page 15: Performance analysis of synchronisation problem

What’s in it for YOU?

Page 16: Performance analysis of synchronisation problem

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

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

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

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

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

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

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

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

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

THE PRODUCER CONSUMER ASPECT

Page 26: Performance analysis of synchronisation problem