Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-dev] Load-Time Weaving Optimization Update

Hi All,

I wanted to update you on the progress I've been making on tuning load-time
weaving performance for AspectJ 5, working with Matthew, Alex, Adrian, and
Andy. I've been focused on dramatically reducing memory requirements while
preserving decent performance and finding opportunities to improve the same.

To that end, I've created an experimental version of load-time weaving that
is running almost as quickly as the code in RC1 but that is using
dramatically less memory.  It works properly for a few different
configurations that I've tried.

I've attached memory snapshots of loading the Glassbox Inspector on a larger
configuration (4 web apps) on start up. The RC1 codebase uses -
Memory_RC1_4apps.html (62 million bytes of heap overhead: 300% total) and
the use in my optimized version - Memory_Tuned_4apps.html (6 million bytes
of overhead: 25% total), which loads within 5-10% of the same time. My
optimized code also handles small classloaders in a reasonable fashion (like
Tomcat's Jasper loader for JSP's) by allowing sharing BCEL loaded by loading
aspects.

To optimize the weaving time for my version I avoided making any extraneous
calls to ClassLoader.getResource. The performance cost for that (at least on
Windoze) is far too high to justify the sharing gains, IMHO. To a first
order, time spent weaving is time spent opening and reading files. I think
it's a lot better to manage a cache of files than to try to allow sharing
(at least unless you have a participating ClassLoader: see below). Thus far,
however, a fully aggressive eviction strategy is still performing quite well
in terms of elapsed and CPU time required.

The major improvements I've made that aren't yet in HEAD are:
1. Allowing using of reflection delegates only for bootstrap types (as
Matthew first suggested to me). Experimentally, a lot of types and a lot of
types that result in cascading loads come from rt.jar types.
 2. Using weak references for values in the expendible type maps. This
allows GC'ing them, which is a major benefit. If starting up in a
constrained memory environment, this might trade off performance for memory
use (although it would be better than crashing with an out of memory
condition). One case I've thought a bit about is whether the expendible maps
are inadvertently holding references to 
3. Evicting BCEL objects when finished with all weaving on the stack (for a
thread). This is a very aggressive memory conservation policy, but so far it
seems to work quite well.
4. Evicting unneeded BCEL information from retained types (i.e., caching
information needed from the JavaClass and Method data, to allow null'ing
them out for GC'ing). I now have this working.

While each of these gives a significant benefit, I think they each need to
be deferred until 1.5.1, since they are too destabilizing at this point at
the release cycle (and I'm sure I'm not the only one who feels this way).

Two additional minor enhancements I've made are worth considering for 1.5.0:
1. Disabling adaptors where no aspects are defined (this is useful if you
have excluded all aspects from a parent in a child classloader!)
2. Avoiding BCEL loading when doing fast matches with NO slow matches
defined (a useful optimization that can be facilitated by writing aop.xml
files thoughtfully)

Matthew and Alex, it would be great to talk again to review what I've done
since we last spoke, and to discuss and plan testing and integration.

Going forward, I think it would be useful to allow a range of caching
options from evicting immediately (what my version does) to never (what's in
HEAD). I think load-time weaving will need a range of memory management
options just as JVM's do.

I also have some thoughts about Matthew's suggestion of using a custom
interface for ClassLoaders (and an aspect to add these and ITD's to many
cases). This should allow better performance in the case where we are
reloading. However, I think this should be a lower priority than effective
cache management and eviction.

Cheers,
Ron

Ron Bodkin
Chief Technology Officer
New Aspects of Software
w: (415) 824-4690

Title: Class tree

Class tree

 <Default package>
1,881,819100 %73,100,944100 %73,100,944100 %
 java
511,64427 %14,756,88020 %72,824,768100 %
 org
1,001,83753 %31,813,99244 %70,371,11296 %
 aspectj
992,59453 %31,476,24043 %61,627,86484 %
 weaver
183,91010 %10,763,43215 %61,494,33684 %
 bcel
31,6512 %4,187,4166 %61,292,20084 %
 BcelWorld
40 %2880 %32,261,74444 %
 BcelObjectType
2,7170 %304,3040 %24,664,80834 %
 BcelMethod
25,7731 %3,711,3125 %8,714,56012 %
 BcelSourceContext
1,8440 %44,2560 %4,485,6086 %
 BcelAdvice
2880 %27,6480 %450,6481 %
 BcelField
7360 %94,2080 %121,4240 %
 BcelTypeMunger
2170 %3,4720 %53,8160 %
 UnwovenClassFile
190 %4560 %19,1760 %
 BcelWeaver
40 %3200 %9600 %
 BcelCflowStackFieldAdder
240 %5760 %5760 %
 BcelVar
140 %3360 %3360 %
 BcelCflowCounterFieldAdder
40 %960 %960 %
 BcelCflowAccessVar
20 %640 %640 %
 Range$Where
40 %640 %640 %
 BcelVar[]
10 %160 %160 %
 loadtime
340 %9840 %34,461,31247 %
 ReferenceType
7,7380 %866,6561 %33,313,60046 %
 World$TypeMap
40 %640 %32,250,60844 %
 ResolvedMember[]
4,5540 %251,8720 %14,993,23221 %
 ResolvedMemberImpl
21,8271 %2,270,0083 %5,972,2408 %
 UnresolvedType[]
54,1883 %936,1601 %3,317,5285 %
 UnresolvedType
39,6482 %1,585,9202 %3,266,3364 %
 patterns
4,5270 %201,0960 %686,3921 %
 WeaverStateInfo
9080 %29,0560 %474,1201 %
 ResolvedPointcutDefinition[]
2,7170 %44,2080 %351,8560 %
 ResolvedType[]
11,7911 %192,1040 %336,9360 %
 ResolvedPointcutDefinition
2190 %22,7760 %308,2080 %
 TypeVariableReferenceType
5430 %69,5040 %183,2320 %
 tools
70 %2240 %176,1200 %
 WeaverStateInfo$Entry
1360 %2,1760 %171,5520 %
 NewMethodTypeMunger
1360 %4,3520 %145,5040 %
 BoundedReferenceType
1410 %16,9200 %67,4560 %
 PrivilegedAccessMunger
2170 %6,9440 %50,3440 %
 TypeVariable
6550 %26,2000 %37,4640 %
 CrosscuttingMembers
450 %2,5200 %27,7840 %
 AjAttribute$AdviceAttribute
1000 %4,8000 %26,7520 %
 ResolvedType$Array
580 %4,1760 %14,8880 %
 BoundedReferenceType$ReferenceTypeReferenceTypeDelegate
6840 %10,9440 %10,9440 %
 ReferenceType[]
6840 %10,9440 %10,9440 %
 TypeVariable[]
1250 %2,2000 %8,4720 %
 Lint
40 %5120 %8,0320 %
 ast
490 %9920 %5,1120 %
 Lint$Kind
1120 %3,5840 %3,5840 %
 AjAttribute$MethodDeclarationLineNumberAttribute
1820 %2,9120 %2,9120 %
 CrosscuttingMembersSet
40 %2240 %2,5680 %
 AjAttribute$WeaverVersionInfo
810 %1,9440 %1,9440 %
 AnnotationX[]
720 %1,1520 %1,1520 %
 ResolvedType$Primitive
90 %6480 %1,0080 %
 MemberImpl
20 %1120 %6640 %
 World$AspectPrecedenceCalculator
40 %640 %5440 %
 AdviceKind
140 %3360 %3360 %
 Shadow$Kind
110 %1760 %1760 %
 ResolvedTypeMunger$Kind
90 %1440 %1440 %
 IntMap$1
10 %240 %1200 %
 Member$Kind
70 %1120 %1120 %
 UnresolvedType$TypeKind
70 %1120 %1120 %
 ResolvedType$Missing
10 %640 %1040 %
 Shadow$Kind[]
10 %560 %560 %
 Member[]
10 %160 %160 %
 ShadowMunger[]
10 %160 %160 %
 Iterators$1
10 %80 %80 %
 apache.bcel
808,25543 %20,697,08028 %36,711,35250 %
 bridge
3980 %15,0880 %102,0320 %
 runtime.reflect
90 %3120 %6480 %
 asm
130 %2560 %2560 %
 util
90 %720 %720 %
 apache
8,8690 %328,1520 %8,695,30412 %
 springframework
3710 %9,5760 %287,1760 %
 xml.sax.helpers
20 %160 %160 %
 hsqldb
10 %80 %80 %
 sun
7950 %27,4480 %62,867,33686 %
 char[]
322,00717 %19,701,35227 %19,701,35227 %
 byte[]
27,8711 %6,289,2889 %6,289,2889 %
 javax
6,7510 %154,3520 %596,7601 %
 int[]
10,1481 %323,0080 %323,0080 %
 com
1430 %2,5600 %175,0640 %
 int[][]
120 %9920 %58,0160 %
 net.sf.cglib
2060 %5,4240 %14,8800 %
 long[]
140 %11,1680 %11,1680 %
 short[][]
60 %1,2480 %9,0320 %
 short[]
2660 %8,8880 %8,8880 %
 boolean[]
1090 %3,7200 %3,7200 %
 $Proxy0
10 %160 %1,0080 %
 boolean[][]
30 %1760 %6080 %
 double[]
30 %3120 %3120 %
 byte[][]
20 %640 %640 %
 float[]
10 %560 %560 %

Title: Class tree

Class tree

 <Default package>
287,546100 %17,530,272100 %17,530,272100 %
 java
160,43556 %6,342,44036 %17,248,85698 %
 org
62,12022 %2,271,21613 %15,147,36886 %
 apache
9,0133 %333,4322 %9,350,50453 %
 aspectj
52,73318 %1,928,18411 %5,743,06433 %
 weaver
26,0489 %1,272,3767 %5,610,44832 %
 bcel
2,6631 %307,1282 %5,286,62430 %
 BcelObjectType
1170 %14,0400 %2,702,10415 %
 BcelAdvice
2880 %27,6480 %1,928,42411 %
 BcelVar
140 %3360 %1,153,0487 %
 BcelField
4390 %52,6800 %846,5525 %
 BcelMethod
1,4220 %204,7681 %498,3683 %
 BcelSourceContext
1080 %2,5920 %226,7761 %
 BcelTypeMunger
2170 %3,4720 %41,6640 %
 UnwovenClassFile
190 %4560 %19,1760 %
 BcelWeaver
40 %3200 %9600 %
 BcelCflowStackFieldAdder
240 %5760 %5760 %
 BcelCflowCounterFieldAdder
40 %960 %960 %
 BcelCflowAccessVar
20 %640 %640 %
 Range$Where
40 %640 %640 %
 BcelVar[]
10 %160 %160 %
 ResolvedMember[]
3430 %21,2640 %3,308,96819 %
 ReferenceType
3550 %39,7600 %3,283,76019 %
 patterns
4,5112 %200,4561 %2,162,99212 %
 reflect
4,3672 %267,5762 %1,810,52810 %
 ast
490 %9920 %1,157,7367 %
 ResolvedType[]
4,2591 %73,2880 %614,8644 %
 UnresolvedType
4,3131 %172,5201 %387,5762 %
 ResolvedPointcutDefinition[]
1170 %2,6080 %296,0722 %
 ResolvedPointcutDefinition
2190 %22,7760 %293,9282 %
 UnresolvedType[]
2,5711 %48,2080 %223,2081 %
 WeaverStateInfo
440 %1,4080 %209,2801 %
 ResolvedMemberImpl
7300 %70,0800 %208,7441 %
 tools
310 %6080 %176,5041 %
 WeaverStateInfo$Entry
1360 %2,1760 %170,4641 %
 NewMethodTypeMunger
1360 %4,3520 %144,4161 %
 loadtime
340 %9840 %112,4721 %
 ltw
80 %4880 %63,8400 %
 World$TypeMap
50 %1200 %50,5360 %
 PrivilegedAccessMunger
2170 %6,9440 %38,1920 %
 CrosscuttingMembers
450 %2,5200 %27,7840 %
 AjAttribute$AdviceAttribute
1000 %4,8000 %26,7520 %
 ResolvedType$Array
300 %2,1600 %11,1600 %
 Lint
50 %6400 %10,0400 %
 TypeVariableReferenceType
140 %1,7920 %4,7360 %
 AnnotationX[]
1540 %2,4720 %4,5520 %
 Lint$Kind
1400 %4,4800 %4,4800 %
 AjAttribute$MethodDeclarationLineNumberAttribute
2140 %3,4240 %3,4240 %
 TypeVariable
330 %1,3200 %3,0560 %
 CrosscuttingMembersSet
50 %2800 %2,8080 %
 TypeVariable[]
180 %2960 %2,5360 %
 AnnotationX
30 %960 %2,0800 %
 AjAttribute$WeaverVersionInfo
780 %1,8720 %1,8720 %
 ResolvedType$Primitive
90 %6480 %1,0080 %
 BoundedReferenceType
10 %1200 %6880 %
 World$AspectPrecedenceCalculator
50 %800 %6800 %
 MemberImpl
20 %960 %5520 %
 AdviceKind
140 %3360 %3360 %
 BoundedReferenceType$ReferenceTypeReferenceTypeDelegate
150 %2400 %2400 %
 ReferenceType[]
150 %2400 %2400 %
 Shadow$Kind
110 %1760 %1760 %
 ResolvedTypeMunger$Kind
90 %1440 %1440 %
 IntMap$1
10 %240 %1200 %
 Member$Kind
70 %1120 %1120 %
 UnresolvedType$TypeKind
70 %1120 %1120 %
 ResolvedType$Missing
10 %640 %1040 %
 Shadow$Kind[]
10 %560 %560 %
 Member[]
10 %160 %160 %
 ShadowMunger[]
10 %160 %160 %
 Iterators$1
10 %80 %80 %
 apache.bcel
26,0939 %630,9924 %1,370,6088 %
 bridge
3980 %15,0880 %102,0321 %
 internal.lang.reflect
1620 %9,0720 %9,0880 %
 runtime.reflect
90 %3120 %6480 %
 asm
130 %2560 %2560 %
 util
90 %720 %720 %
 lang.reflect
10 %160 %160 %
 springframework
3710 %9,5760 %286,8162 %
 xml.sax.helpers
20 %160 %160 %
 hsqldb
10 %80 %80 %
 sun
2,7871 %66,3280 %6,983,95240 %
 char[]
51,28418 %4,303,93625 %4,303,93625 %
 byte[]
1,7181 %4,174,19224 %4,174,19224 %
 javax
6,8832 %158,8561 %608,0483 %
 com
1530 %2,7200 %188,5201 %
 int[]
1,5071 %177,9361 %177,9361 %
 int[][]
120 %9920 %58,0160 %
 net.sf.cglib
2060 %5,4240 %14,8800 %
 long[]
150 %11,1920 %11,1920 %
 short[][]
60 %1,2480 %9,0320 %
 short[]
2660 %8,8880 %8,8880 %
 $Proxy3
350 %5600 %7,0000 %
 boolean[]
1090 %3,7200 %3,7200 %
 $Proxy4
10 %160 %1,0080 %
 boolean[][]
30 %1760 %6080 %
 double[]
30 %3120 %3120 %
 byte[][]
20 %640 %640 %
 float[]
10 %560 %560 %


Back to the top