Nov 1st, 2012, 07:40 AM
loadtime weaving causes bottleneck on java.lang.Class.getAnnotations()
Hello spring developers.
We are using LoadTimeWeaving with spring 3.1.2 an JAVA 6u27 on CentOS-Linux for a high performance WebSite
(14 boxes with up to 24 cores each)
After we used the @Configurable-Annotation on an often instantiated class, we stumbled over a synchronized bottleneck in
java.lang.Class.initAnnotationsIfNecessary ( Class.java:3067 )
java.lang.Class.getAnnotations ( Class.java:3050 )
org.springframework.core.annotation.AnnotationUtil s.findAnnotation ( AnnotationUtils.java:211 )
We had to step back and build some own infrastructure without synchronization.
Now we have to decide if we get rid of LTW completely again because our heavily multicored servers need to rely on the parallelization, and we can not risk to step into that trap again, just because some objects are constructed more frequently after an application update.
There seem to be two possibilities two avoid this bottleneck
a) The code in java.lang.Class looks like it could avoid a huge amount of the locking by using double-checked locking, since redefinition of classes (needing to clear the cache) should be a rare event?
b) it might be possible to do some caching in the spring-Code of the LTW, although I am not sure how this caching can account for class-redefinitions?
How probable is a fast performance fix at that point by spring?
Thanks for answers
Tags for this Thread