I looked at the profiler snapshot today to see for any further major improvements that can
be brought in. Here's the summary on where the majority of time is spent (in short,
AOP and annotation scanning)
The scenario being considered is 100 beans (simple ones) with 100 methods each and one
@Resource and one @EJB injection each.
1) During EJB3 deployment, for each of these beans a bean container is created. During
initialization of this bean container, the (expensive) AOP initialization is done, which
includes creating AOP interceptor chain, applying any bindings to each of the 100 methods
for each of the 100 beans. As the number of methods increases, so does the time.
2) Once the bean container is initialized (and AOP initialized for this bean container),
these containers are again reinitialized for AOP (can't be avoided as explained by
Carlo and ALR). So this leads to a second iteration of expensive AOP initialization
3) The next part where time is being spent is annotation scanning. *Each method on each
bean* is scanned for various methods at different points:
3a - InterceptorRegistry - Looks for annotations like @Interceptors,
@ExcludeDefaultInterceptors @ExcludeClassInterceptors and so on.
3b - Factories (like CMTTxInterceptorFactory) in AOP interceptor chain which is
applied to the methods, looks for annotations like @TransactionTimeout,
@TransactionAttribute and so on
3c - Then there is MC which scans all methods of all MC bean instances (bean
containers are deployed as MC beans) for any MC specific annotations and other custom
annotations, which can be processed by AnnotationPlugins.
The process of annotation scanning goes through the AOP advisor which invokes the
corresponding retrievals (EJB3 has some custom metadata bridges which resolve annotations
out of EJB3 metadata) for 3a, 3b and 3c. As the number of methods increases, so does the
time to do all this. I was looking for an API like - getAnnotations(Member m) and
getClassAnnotations() which when invoked would get all the available annotations on a
member or a class. Later on when anyone requires to check for an annotation, the
repository could then use this internal cache. However, from what i found in the code,
these APIs aren't implemented/available.
There are some improvements that can help improve the performance:
http://www.jboss.org/index.html?module=bb&op=viewtopic&t=154878
http://www.jboss.org/index.html?module=bb&op=viewtopic&t=154875
However, these couple of changes wont bring in a major improvement in performance.
Overall, its AOP stuff that we need to think about to bring in some considerable
improvements. Any ideas are welcome - i can give them a try. In the meantime, i'll
look for any changes that might bring in some difference.
View the original post :
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4229027#...
Reply to the post :
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&a...