-
Notifications
You must be signed in to change notification settings - Fork 38.5k
Comprehensively cache annotated methods for interfaces and superclasses [SPR-16675] #21216
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Christoph Dreis commented You don't happen to have any numbers on how significant the improvement is by any chance? |
Juergen Hoeller commented Not in the context of a Boot app yet. In local microbenchmarks involving annotation introspection across class hierarchies and interfaces with unrelated annotations, it was 2-5x as fast. However, this is very dependent on the concrete bean classes in a setup and how expensive the activated annotation introspection actually is (e.g. |
Juergen Hoeller commented As of 5.0.5, we're also clearing our |
David commented I think there will be more improvement: Set<Class<?>> classes = new LinkedHashSet<Class<?>>(ClassUtils.getAllInterfacesForClassAsSet(targetClass));
classes.add(targetClass);
for (Class<?> clazz : classes) {
Method[] methods = ReflectionUtils.getAllDeclaredMethods(clazz);
for (Method method : methods) {
if ((introductionAwareMethodMatcher != null &&
introductionAwareMethodMatcher.matches(method, targetClass, hasIntroductions)) ||
methodMatcher.matches(method, targetClass)) {
return true;
}
}
} If we found that targetClass is a Proxy Class(eg: Proxy by JDK Proxy), then there is not need to check the method only existing is the Proxy Class (eg: Methods in org.springframework.aop.framework.Advised) |
Juergen Hoeller commented Andy Wilkinson, there seems to be a direct reference to the |
Juergen Hoeller commented Andy Wilkinson, Stéphane Nicoll, it'd be great to get a full round of Boot/Platform integration testing today still... I don't expect any regressions in real-life scenarios but there may always be strange tests relying on very specific old behavior. Since this revision (as well as #21208) is primarily there for Spring Data in a Boot setup, we need to make sure that it won't cause any trouble there... just hopefully improves startup performance a bit. |
Phil Webb commented Juergen Hoeller I've update the Boot code and we managed to get at least one build to go green (we've got unrelated CI issues). Our 1.5.x build is broken currently due to DATAJPA-1309 but I don't think that's related to this change. |
Juergen Hoeller commented Phil Webb, Stéphane Nicoll, Andy Wilkinson, I've pushed one more pass to master, also addressing Let's take it slowly tomorrow and do a full round of integration testing before we go live here. I don't expect 5.0.5 and 4.3.15 before late European afternoon at this point. |
Juergen Hoeller opened SPR-16675 and commented
AnnotationUtils
has had an internal annotated interface cache (#12286) as well as a general lookup cache (#16501) for a while. However, recent performance benchmarks showed that further significant gain can be achieved by turning the interface cache into an annotated base type cache, caching metadata about superclasses as well... in particular about non-annotated base classes that are never worth searching. We're also narrowing potential base type lookups to a set of candidate methods that carry any annotations to begin with, avoiding an oftenNoSuchMethodException
-triggeringClass.getMethod
lookup for a base method in favor of matching against the candidateMethod
set from our cache.Affects: 5.0.4
Issue Links:
0 votes, 5 watchers
The text was updated successfully, but these errors were encountered: