Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [aspectj-users] AspectJ overhead

How does the overhead compare with manually inserting log entries (e.g.,
can you write a benchmark that only requires you to manually add entries
for a few methods)? This should give you a sense of whether AspectJ is
adding extra overhead and if so, how much.

In general, using thisJoinPoint will add a fair bit of overhead. But
adding a lot of logging to an application will add overhead no matter
what implementation technique you use. 

You could try configuring the application to do selective logging
(either through your logging package or if tests, such as the if
pointcut) to reduce the <<logging>> overhead.

Ron

-----Original Message-----
From: aspectj-users-admin@xxxxxxxxxxx
[mailto:aspectj-users-admin@xxxxxxxxxxx] On Behalf Of Mohamed S. Mansour
Sent: Monday, March 10, 2003 12:17 PM
To: aspectj-users@xxxxxxxxxxx
Subject: Re: [aspectj-users] AspectJ overhead

If I refrain from using thisJoinPoint, the overhead is about 10% only.
Please note that I profile with a skeletal aspect, it has not code for
logging 
or string concatentation.

--
Mohamed

Wes Isberg wrote:
>>I measured the overhead of my aspect and it adds 120% overhead!!!
> 
> 
> Yes, thisJoinPoint is reflective and uses memory.
> You might speed up the join point matching by using
> staticly-determinable pointcuts -- e.g.,
> 
> from
>      pointcut methodCall(Object o):  call(* *(..))
>          && target(o) && !javaCode()  && !myTrace();
> to
>      pointcut methodCall():  call(!static * *(..))
>          && !javaCode()  && !myTrace();
> 
> Then use thisJoinPoint.getTarget().
> 
> But how much time is the logging and how much is the 
> aspect protocol to log?  Put another way, if you disable 
> logging and String concatenation, does just the aspect
> tracing protocol double the time your program takes 
> to run?  That seems like the right measure of the overhead.
> 
> Wes
> 
> "Mohamed S. Mansour" wrote:
> 
>>Hi,
>>
>>I am writing an aspect to trace program execution. Basically, for each
method
>>call we want to log the caller, callee and values of formal arguments.
>>
>>I measured the overhead of my aspect and it adds 120% overhead!!!
>>
>>By stripping down my aspect, I found out that using thisJoinPoint is
the culprit.
>>
>>Is there an alternative aspect that causes less overhead?
>>--
>>Mohamed
>>
>>aspect TraceAspect {
>>    pointcut myTrace(): within(TraceAspect) || within(Trace);
>>    pointcut javaCode(): within(java..*) || call(* java..*(..));
>>
>>    // a point cut that matches any non-static method call.
>>    pointcut methodCall(Object o):
>>           call(* *(..))
>>           && target(o)
>>           && !javaCode()
>>           && !myTrace();
>>
>>    // a point cut that matches any static method call.
>>    pointcut staticMethodCall():
>>           call(static * *(..))
>>           && !javaCode()
>>           && !myTrace();
>>
>>    before (): staticMethodCall() {
>>       logCaller(thisJoinPoint);
>>       logCallee(thisJoinPointStaticPart);
>>    }
>>    before (Object o): methodCall(o) {
>>       logCaller(thisJoinPoint);
>>       logCallee(thisJoinPointStaticPart, o);
>>    }
>>    //***********************************************//
>>    private void logCaller(JoinPoint thisJoinPoint) {
>>       SourceLocation loc = thisJoinPoint.getSourceLocation();
>>       // add a log entry
>>
>>       Object[] args = thisJoinPoint.getArgs();
>>       for (int i=0; i<args.length; i++) {
>>          // add a log entry
>>       }
>>    }
>>    private void logCallee(JoinPoint.StaticPart
thisJoinPointiStaticPart) {
>>
>>       Signature sig = thisJoinPointiStaticPart.getSignature();
>>       // add a log entry
>>    }
>>    private void logCallee(JoinPoint.StaticPart
thisJoinPointStaticPart,
>>                           Object target) {
>>       Signature sig = thisJoinPointStaticPart.getSignature();
>>       // add a log entry
>>    }
>>    //***********************************************//
>>}
>>
>>_______________________________________________
>>aspectj-users mailing list
>>aspectj-users@xxxxxxxxxxx
>>http://dev.eclipse.org/mailman/listinfo/aspectj-users
> 
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> http://dev.eclipse.org/mailman/listinfo/aspectj-users
> 
> 



_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/aspectj-users



Back to the top