This forum is now a read-only archive. All commenting, posting, registration services have been turned off. Those needing community support and/or wanting to ask questions should refer to the Tag/Forum map, and to http://spring.io/questions for a curated list of stackoverflow tags that Pivotal engineers, and the community, monitor.

Tips

Mar 30th, 2011, 07:05 AM

Hey!

We are using Spring for a fat client. And now we reached the edge when the startup time is not acceptable for users. Basically startup is a process of joining/loading different spring contexts. For the moment I counted 543 beans in total. I profiled the loading using CPU sampling and took "slow" initialization out to separate threads. That kind of helped, but still performance isn't perfect. It still takes more than 30 secs just to init the context. 30 secs may sounds okay for a server startup, however it's a fat client and believe me users complain about the slow startup a lot. I found out that the time of the internal context initialization (see below lines: 2,3) comparable to the time of classes initialization of the application (see below lines: 6,5,7). In other words the startup time is doubled due to the framework. Lazy loading is enabled, but frankly lazy-loading doesn't help that much in my case. It passes the problem to a later stage.

Profiling scenario is pretty basic: new ClassPathXmlApplicationContext(locations);
Time in ms

Results for Spring 3.0.5

Total 34187

java.beans.Introspector.getBeanInfo(Class) called by (CachedIntrospectionResults) 11156

java.lang.reflect.Constructor.newInstance(Object[]) called by BeanUtils 4000

java.lang.reflect.Method.invoke(Object, Object[]) 2937

SUM of org.fatclient.beans.**.init> 8860

As you see java.beans.Introspector.getBeanInfo(Class) spends ages exploring bean info. Is there any way to boost the loading up? Is there any easy and safe way to serialize the context (bean info) right after the first loading to avoid parsing and exploring for a next run? Is there any common guides, tips & tricks, container performance tuning guides?

Thanks in advance for your help,
Anton

Last edited by ahtokca; Mar 30th, 2011, 09:13 AM.
Reason: Title isn't good

Comment

Hello, I'm sorry I cannot come with a solution, I'm having the same problem, my app starts in about 1 min 30 sec, from which 50-55 seconds is taken by
Introspector.getBeanInfo(beanClass) from org.springframework.beans.CachedIntrospectionResul ts. If you found a way to fix or improve your startup time please feel free to share.