For what it’s worth, we also mix
build-time and load-time weaving with Glassbox. To gain performance with
load-time weaving we:
1. Guard pointcuts using within(TypePattern+)
&& … - this lets AspectJ do fast matching. This is a big gain if
many classes do not need to be woven.
2. Use <weaver><include within=”TypePattern+”/></weaver>
in the aop.xml file to consistently hoist the fast matching (it’s
surprising that this gains performance over #1 but it definitely does … at
some point I hope to investigate why this happens).
3. Exclude weaving into statically woven
Glassbox code using <weaver><exclude within=”…”/>…,
primarily to avoid exposing a large number of internal aspects that need to be
potentially woven against external code. We started doing this before –outxml
was available for maintainability reasons and also before using the first two
approaches, so hopefully we could stop doing this and still achieve good
performance.
4. Exclude weaving into known sets of code
where our aspects don’t apply (server internals) also using exclude
Naturally, I would like if none of the
above were needed: if fast matching would handle #1, we didn’t need any additional
hints in the aop.xml file from #2 and probably #3 is already a minor
performance gain. But if you want to see a real world example of minimizing start-up
overhead with AspectJ LTW, it’s worth looking at how we do this.
HTH,
Ron
From:
aspectj-users-bounces@xxxxxxxxxxx [mailto:aspectj-users-bounces@xxxxxxxxxxx] On Behalf Of Matthew Webster
Sent: Wednesday, October 11, 2006
9:45 AM
To: Mick.Jordan@xxxxxxx;
aspectj-users@xxxxxxxxxxx
Subject: Re: [aspectj-users]
Mixing post-compile and load-time weaving
Mick,
The
reason you have not found any detailed documentation is because what you are
trying to do is unusual. You say you are using a custom class loader to define
dynamically generated classes. If you only want to weave these classes then
only add the aop.xml declaring the aspect you want to use to the CLASSPATH of
the custom class loader. When you use the agent all other class loaders will
also attempt to weave or reweave the classes they define but no aop.xml
configuration will be found. The weaving adaptor for the loader will be
disabled and the previously woven classes used straight off disk.
Matthew
Webster
AOSD Project
Java Technology Centre, MP146
IBM Hursley
Park, Winchester, SO21 2JN,
England
Telephone: +44 196 2816139 (external) 246139 (internal)
Email: Matthew Webster/UK/IBM @ IBMGB, matthew_webster@xxxxxxxxxx
http://w3.hursley.ibm.com/~websterm/[1]
Mick Jordan
<Mick.Jordan@xxxxxxx>
Sent
by: aspectj-users-bounces@xxxxxxxxxxx
11/10/2006 16:39
Please
respond to
Mick.Jordan@xxxxxxx; Please respond to
aspectj-users@xxxxxxxxxxx
|
|
To
|
aspectj-users@xxxxxxxxxxx
|
cc
|
|
Subject
|
Re: [aspectj-users] Mixing post-compile and
load-time weaving
|
|
Matthew Webster wrote On 10/11/06 01:51,:
Mick,
WRT combining compile- or post compile-time weaving and LTW there is some
information in the Development Environment Guide: http://www.eclipse.org/aspectj/doc/released/devguide/ltw.html.
I presume you only want to use LTW for the classes you are generating and
defining with your custom class loader. Are you planning to use the Java 5 LTW
agent via "-javaagent" or invoke the Aj interface directly from you
class loader?
I've read all that I can find and the documentation wasn't clear or detailed
enough IMHO. What I want is to avoid the run-time overhead of aspectifying the
classes that I can aspectify at compile time (there are several thousand) and
just aspectify the dynamically generated ones. The end result is that
everything is aspectified, however.
Yesterday I determined that if I set the classpath to the unaspectified classes
and set -javaagent to the JavaVM, everything does get aspectified by the load
time weaver, including the dymically generated ones. So that workd but perhaps
has a slower startup than necessary. This morning I will try putting the
aspectified classes on the class path and see if there is a significant
difference.
Mick
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users