Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Performance impact of using aop

We have started to use spring aop for cross cutting aspects of our application (security & caching at the moment).

My manager worries about the performance impact of this technology although he fully understands the benefits.

My question, did you encounter performance problems introduced by the use of aop (specifically spring aop)?

like image 767
LiorH Avatar asked Jan 11 '09 19:01

LiorH


People also ask

Does AOP affect performance?

As far as performance is concerned, compile-time weaving is much faster than runtime weaving. Spring AOP is a proxy-based framework, so there is the creation of proxies at the time of application startup. Also, there are a few more method invocations per aspect, which affects the performance negatively.

What are the benefits of AOP?

You can use AOP to reduce code clutter by improving the readability and maintainability of your code. It should be noted that AOP is just a new programming paradigm -- it doesn't replace OOP in any way. Rather, it complements OOP by providing you another way to achieve modularity and also reduce code clutter.

What problems does AOP solve?

What is a cross cutting concern? Aspect Oriented Programming is the concept of weaving extra behavior during the application execution. The purpose is to solve cross-cutting concerns with a modular approach. A cross-cutting concern is a concern that impacts every layer and class of your application.


2 Answers

As long as you have control of your AOP I think it's efficient. We did have performance problems anyway, so by own reasoning we were not fully in control ;) This was mostly because it's important that anyone that writes aspects has full understanding of all the other aspects in the system and how they interrelate. If you start doing "smart" things you can outsmart yourself in a jiffy. Doing smart things in a large project with lots of people who only see small parts of the system can be very dangerous performance-wise. This advice probably applies without AOP too, but AOP lets you shoot yourself in the foot in some real elegant ways.

Spring also uses proxying for scope-manipluations and thats an area where it's easy to get undesired performance losses.

But given that you have control, the only real pain point with AOP is the effect on debugging.

like image 82
krosenvold Avatar answered Oct 08 '22 14:10

krosenvold


If performance is going to be a concern, we have used AspectJ to great effect.

Because it uses bytecode weaving (compile time vs. runtime makes quite the difference) it's one of the fastest AOP frameworks out there. See: AOP Benchmarks

like image 45
Nathan Avatar answered Oct 08 '22 15:10

Nathan