Description
Phil Webb opened SPR-16933 and commented
I've been looking at the performance involved with using the SimpleMetadataReader
and I suspect that it might be possible to improve AnnotationUtils
.
I started with the following application that simulates the class parsing involved in a typical Spring Boot application
https://gist.github.com/philwebb/a22ea7bf5b575abd058a748fe12838d0
This app takes about 130ms to read the metadata from those 106 classes.
If I change the code to use an empty ASM visitor, parsing takes ~30ms
Reading just class bytes into an array takes ~22ms (so ASM parsing itself is quite fast)
If I remove the code that visits annotations so no AnnotationAttributes
are read, it takes ~60ms.
Looking at the profiler a lot of time is spent in AnnotationUtils
so I created a second sample:
https://gist.github.com/philwebb/f7cdc99401af8e063853b2ed574e9277
The NAMES
being used here are the same as were ultimately used with the first sample. This one is reading annotation data for 413 classes (starting from their String name) and it takes ~93ms.
Affects: 5.0.7
Attachments:
- Screen Shot 2018-06-11 at 5.13.56 PM.png (174.80 kB)
Issue Links:
- Annotations on generic interface methods not found by AnnotationUtils [SPR-16060] #20609 Annotations on generic interface methods not found by AnnotationUtils
- Reduce ClassUtils.forName overhead (in particular for annotation introspection purposes) [SPR-16667] #21208 Reduce ClassUtils.forName overhead (in particular for annotation introspection purposes)
- Comprehensively cache annotated methods for interfaces and superclasses [SPR-16675] #21216 Comprehensively cache annotated methods for interfaces and superclasses
- Avoid repeated superclass introspection in AnnotationUtils.findAnnotation [SPR-16730] #21271 Avoid repeated superclass introspection in AnnotationUtils.findAnnotation
- Spring internal configuration classes can no longer use @EventListener [SPR-17160] #19660 Spring internal configuration classes can no longer use
@EventListener
- @Scheduled task runs twice on bean with target-class scoped proxy (when injected) [SPR-17166] #21702
@Scheduled
task runs twice on bean with target-class scoped proxy (when injected)
0 votes, 6 watchers