Bug 520597 - Weaving slow with Java 9
Summary: Weaving slow with Java 9
Status: RESOLVED FIXED
Alias: None
Product: AspectJ
Classification: Tools
Component: Library (show other bugs)
Version: DEVELOPMENT   Edit
Hardware: PC Mac OS X
: P3 normal (vote)
Target Milestone: 1.9.0.RC1   Edit
Assignee: aspectj inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-08-06 04:20 EDT by Mario Ivankovits CLA
Modified: 2017-09-28 16:35 EDT (History)
1 user (show)

See Also:


Attachments
Patch to speedup weaving with Java 9 (10.31 KB, application/octet-stream)
2017-08-06 04:20 EDT, Mario Ivankovits CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Mario Ivankovits CLA 2017-08-06 04:20:23 EDT
Created attachment 269706 [details]
Patch to speedup weaving with Java 9

Actually a matching class file is searched by iterating through all modules. This makes weaving very slow as the module tree is scanned over and over again.

The attached patch builds a TOC of all class files once to speedup the search which greatly improves the speed of the weaving process.
Comment 1 Andrew Clement CLA 2017-09-28 16:35:24 EDT
Thanks Mario - I took your patch and further changed things somewhat. I hadn't done anything about this sooner as I was waiting for the actual JDK to settle down and see where we ended up. 

In my changes I didn't want a cache of all classes, too expensive, so I created a package cache with a soft hashmap for individual files. The package cache has about 1600 entries in (for a standard Java9) whilst a full file map had 40000 entries (many of which we'd never use).

I think further improvements are possible (for example a timer that clears the cache if unused for a few mins, that would benefit LTW) but this is a good first start and performance is back to where it needs to be.