Bug 59076 - Reduce footprint of JoinPoint.StaticPart objects
Summary: Reduce footprint of JoinPoint.StaticPart objects
Status: RESOLVED FIXED
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: 1.2.1   Edit
Hardware: PC Windows XP
: P3 enhancement (vote)
Target Milestone: 1.5.0 M4   Edit
Assignee: Adrian Colyer CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-04-19 10:52 EDT by Matthew Webster CLA
Modified: 2005-09-01 10:25 EDT (History)
1 user (show)

See Also:


Attachments
Patch to implement option (1) (2.76 KB, application/octet-stream)
2004-05-07 09:17 EDT, Andrew Clement CLA
no flags Details
New version of patch to implement (1) (3.14 KB, application/octet-stream)
2004-05-10 08:52 EDT, Noel Markham CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Matthew Webster CLA 2004-04-19 10:52:41 EDT
Tests show that each object consumes 180+ bytes. For a large project (1000+ 
classes) where an aspect is used to implement a pervasive cross-cutting 
concern e.g. exception logging this can lead to >1MB of additional heap space. 
Two possible approaches could be:
1. Break literal String used by Factory.makeXXXSig() methods into component 
parts e.g. package, class, method. ... names. These could then be shared 
automatically by the JVM as interned Strings.
2. Lazy instantiation of handler static JPs in the catch block.

Any enhancements could be enabled by a compiler option similar to -XlazyTjp.
Comment 1 Noel Markham CLA 2004-04-22 11:16:42 EDT
Adding Noel CC
Comment 2 Andrew Clement CLA 2004-05-07 09:17:55 EDT
Created attachment 10392 [details]
Patch to implement option (1) 

I am appending the attachment from Noel Markham that implements option (1) of
the two strategies proposed for addressing this problem.

Noel says:
---
Please find attached two patches: LazyClassGen.java and Factory.java, for
reducing the footprint of JoinPoint.StaticPart objects. Currently, only the
methods makeMethodSig() and makeCatchClauseSig() in Factory.java take a
broken-up set of parameters.
Since the generated code is enclosed in a static block, it is only run once and
shoudn't affect the performance too much. Using my FFDC Simulation tests, the
free heap size (on a 4Meg heap) has been increased from ~600k to ~1.6M.
On the test, 1000 classes are produced, each with four catch blocks. The class
names(fully qualified with package name) are approx 60 chars, and the method
names are approx 40 chars.
----

My only concern with the approach is using makeClass() which calls
Class.forName() - I wonder if that is necessary - but I haven't become an
expert on this area of code like Noel has so I can't say yet !
Comment 3 Noel Markham CLA 2004-05-10 08:52:52 EDT
Created attachment 10445 [details]
New version of patch to implement (1)

This patch creates overriding methods for makeMethodSig(),
makeConstructorSig(), makeFieldSig(), makeAdviceSig(), makeInitializerSig() and
makeCatchClauseSig() in Factory.java The code to use these methods instead of
the one-String parameter methods is in the second file, a patch for
LazyClassGen.java

This patch supersedes the previous submission.
Comment 4 Adrian Colyer CLA 2005-03-22 08:51:57 EST
This could reduce memory usage in AJ programs and it is worth looking at
integrating this patch in AJ5 M4. Note that tjpsp currently provides a stable
and unique hashCode for use in Maps etc.. Any change to the implementation must
preserve this property.
Comment 5 Adrian Colyer CLA 2005-09-01 10:25:14 EDT
patch updated and applied.