Affects Version/s: 1.4.4
Fix Version/s: 1.4.5
AnnotationMapper.processAnnotations is really hot performance-wise in multi-threaded applications (see https://issues.jenkins-ci.org/browse/JENKINS-13154 for more details.)
This is because every time anything happens, the processAnnotations method is called and it needs to obtain a lock on annotatedTypes. Simply making the annotatedTypes field concurrency-safe doesn't work, because the processTypes methods adds a class to annotatedTypes before it processes its fields.
In this patch, we introduce another field that keeps track of classes that were already analyzed. This class is concurrency-safe, resulting in a substantial boost in multi-threaded applications.
To make it clear what this patch actually does, I created a separate patch file b.diff that ignores whitespace difference.
This issue made me thinking about the current approach. Actually there is no real reason why a different thread should wait to process a completely unrelated type. Therefore the big synchronization block has been moved now into the loop of processed types and is based on the currently processed type. The cache with the annotatedTypes is now only synchronized for the short time accessing the set. This should improve the situation even more.