Bug 520597

Summary: Weaving slow with Java 9
Product: [Tools] AspectJ Reporter: Mario Ivankovits <mario>
Component: LibraryAssignee: aspectj inbox <aspectj-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: aclement
Version: DEVELOPMENT   
Target Milestone: 1.9.0.RC1   
Hardware: PC   
OS: Mac OS X   
Whiteboard:
Attachments:
Description Flags
Patch to speedup weaving with Java 9 none

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.