Hi Rich,
Very fortunate I happened to check this ajdt mailing list, I don't do it very often. I tend to hang around on the aspectj users/dev list (or stack overflow) - that might be a better place for the discussion (at least more people will see the discussion).
Anyway, there is a lot to talk about there but let me start at the beginning:
> At this time we have defined a single aspect file which contains ~9 pointcuts and ~ 8 join-points..
You don't define join points. You define pointcuts:
pointcut p(): execution(* somemethod(..));
and advice attached to pointcuts:
before(): p() {...}
Join points are matched by pointcuts. Every program has lots of join points but using the pointcut patterns AspectJ selects a subset to which the advice gets attached.
> I think my terminology is correct in saying we have mostly statically determined pointcuts.
That is great that they are statically determinable but the cost for matching each one can vary wildly depending on the which elements of the pointcut are specified and which are wildcarded. Using annotations or type names can speed up matching (as large numbers of join points can be dismissed very quickly) but I know you have said you don't want to specify type or package names.
> Right now the pointcuts do have lots of operators (mainly OR’s). Are these know to be less performant?
Doesn't really matter about the operators. All pointcuts are translated into a DNF form and the individual components are sorted to ensure those cheaper to analyze are first.
> In terms of “Execution Time” the weave process takes ~2.5 mins.
When you say 'weave time' should I assume you mean compile and weave time? i.e. the time from when you press 'clean project' to the time when the whole process finishes? If your project is an AspectJ project then AspectJ is responsible for compilation and weaving - for compilation it is using a modified variant of the JDT compiler.
> Our eclipse project is large. It consists of 11334 types (files). Of these types we’re expecting that only types annotated with @Entity (~700 classes) would be weaved. But AJDT seems to report that 10404 makers are created and if I search the generated bytecode 19228 class files (of 21058) have references to “org.aspectj” in the bytecode. However only the @Entity classes have the inner $AjcClosure classes so I’m guessing it is advising correctly. Inspecting the non @Entity bytecode which does have references to “org.aspectj” it typically seems to be something like
>
> org.aspectj.weaver.MethodDeclarationLineNumber: length = 0x8
>
> Reading online this seems to be some form of debug information? So what we are seeing it is taking 2.5mins+ and potentially weaving more than it should.
grepping through the byte code isn't a great way to tell what was woven. The MethodDeclarationLineNumbers are used if something is advised since Java does not include the line numbers for method declarations. It is produced during compilation, *not* during weaving. I would expect all classes compiled in an AspectJ project to have these MethodDeclarationLineNumber elements in them (if they contain method declarations) so I presume that is why 19228 of your 21058 files have them. If you want to identify which files have actually been woven, grep the byte code for the attribute 'org.aspectj.weaver.WeaverState'. My gut reaction is that 10404 markers feels like a lot but I suppose if you have 700 classes that should be advised, it is only 14 per file. In the markers view in eclipse have you seen any markers that look wrong?
> Perhaps we need to tweak our pointcuts to skip over classes quicker?
Yes, I'm more suspicious of the matching time for pointcuts than the actual weaving time. You don't mention what version of AJDT you are on, I hope it is something recent?
I wrote an article a while back on profiling how long your pointcuts are taking to match:
And here is one on how to see that information in AJDT:
It would be interesting to know if you have any pointcuts that are spending a lot of time in the matching. And whether you are using the more adventurous pointcut designators like cflow.
> Is it possible to turn off markers (or perhaps only install the weaver) and not take advantage of advise markers.
I've often thought we need that but I don't think we have it right now. Are you able to do a command line build of this project - how does that compare when AJDT is not in the loop?
I'm certainly happy to work with you to dig into this. Taking a look at the pointcuts may be the next step.
cheers,
Andy