Bug 532033 - Performance improvement for pointcuts with WildTypePattern
Summary: Performance improvement for pointcuts with WildTypePattern
Status: NEW
Alias: None
Product: AspectJ
Classification: Tools
Component: LTWeaving (show other bugs)
Version: 1.8.11   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: aspectj inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-03-05 14:04 EST by Andreas Huber CLA
Modified: 2019-04-04 14:57 EDT (History)
2 users (show)

See Also:


Attachments
Early out for WildTypePatterns in KindedPointcut.fastMatch (743 bytes, patch)
2018-03-05 14:04 EST, Andreas Huber CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Andreas Huber CLA 2018-03-05 14:04:39 EST
Created attachment 273007 [details]
Early out for WildTypePatterns in KindedPointcut.fastMatch

I have a Spring application that uses load time weaving. I have with several pointcuts that look like this:

@Around("execution(@com.example.demo.Permissions * com.example..*Controller.*(..))")

They match all annotated methods that are in classes with a specific naming pattern.

For some classes the evaluation for one pointcut can take almost a second. Even for classes that do not match the naming pattern. The time depends on the number of methods. Examples are com.fasterxml.jackson.databind.ObjectMapper (part of spring-boot-starter-web, 201 methods), org.apache.cxf.jaxrs.JAXRSServerFactoryBean (84 methods), com.mchange.v2.c3p0.ComboPooledDataSource (216 methods) or org.camunda.bpm.engine.spring.SpringProcessEngineConfiguration (485 methods).

I tested this with aspectjweaver 1.8.13.

The performance can be improved by adding an early out to KindedPointcut.fastMatch(). That way classes that don't match the naming pattern can be skipped and the expression does not have to be evaluated for every method.

In my case this improves the startup time by 40-50 seconds.

A patch is attached.
Comment 1 Andrew Clement CLA 2018-03-21 16:38:34 EDT
I just ran the test suite with the change in, good news is that it completely passes but I am scared to add it without more analysis and tests focused specifically on the change, particularly in the rc phase of 1.9.0.
Comment 2 Andrew Clement CLA 2019-04-04 14:57:05 EDT
I did build 1.9.3 RC1 with this in, but after further testing I am finding it breaks Spring Framework tests so I'm having to remove it again for now, pending investigation.