FWIW, explicitly specifying a name with @SpringBean worked around the problem
On Tue, Feb 9, 2010 at 11:34 AM, Nikita Tovstoles < nikita.tovsto...@gmail.com> wrote: > Wicket's SpringWebApplication is deprecated and the javadoc advocates > using @SpringBean to inject dependencies at component level. However, > that appears to be an expensive proposition: > > I have a listView component that renders a (new) ExternalLink subclass > per item. That subclass uses a service (a singleton spring bean) > injected via @SpringBean like so: > > @SpringBean > private MyService service; > > YourKit tells me that when the page is being rendered, 47%(!) of cpu > time is being spent constructing the subclass, specifically, > repeatedly calling: > > org.springframework.beans.factory.BeanFactoryUtils.beanNamesForTypeIncludingAncestors(ListableBeanFactory, > Class) > > The above is getting called with vigor from > SpringBeanLocator.hashCode() --> getBeanName() --> > getBeanNameOfClass(). HashCode() is likely getting called most often > by AnnotProxyFieldValueFactory.cache during look-ups - which I am > guessing isn't intentional. Looks like a bug, no? > > If the above is a bug indeed, is the workaround to always specify a > 'name' with @SpringBean? > > Thoughts? > -nikita > > +-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------+-----------------+ > | > Name > | Time (ms) | Own Time (ms) | > > +-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------+-----------------+ > | > > +---com.castanealabs.gui.component.search.CategoryDataViewPanel$1.populateItem(Item) > > | 5,430 100 % | 50 | > | | > > | | | > | > +---com.castanealabs.gui.component.search.ProductImageCell.<init>(String, > SiteId, IModel) > | 2,680 49 % | 20 | > | | | > > | | | > | | > +---com.castanealabs.gui.embedded.ExternalSiteProductInfoLink.<init>(String, > SiteId, IModel) > | 2,660 49 % | 0 | > | | | > > | | | > | | > +---com.castanealabs.gui.embedded.ExternalSiteProductInfoLink.<init>(String, > SiteId, IModel, IModel) > | 2,660 49 % | 0 | > | | | > > | | | > | | > +---com.castanealabs.gui.embedded.TargetedExternalLink.<init>(String, > IModel, IModel, String) > | 2,570 47 % | 0 | > | | | | > > | | | > | | | > +---org.apache.wicket.markup.html.link.ExternalLink.<init>(String, > IModel, IModel) > | 2,570 47 % | 0 | > | | | | > > | | | > | | | > +---org.springframework.beans.factory.BeanFactoryUtils.beanNamesForTypeIncludingAncestors(ListableBeanFactory, > Class) | 2,570 47 % | > 0 | > | | | | > > | | | > | | | > > +---org.springframework.context.support.AbstractApplicationContext.getBeanNamesForType(Class) > | 2,570 > 47 % | 0 | > | | | | > > | | | > | | | > > +---org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(Class) > | 2,570 47 % | > 10 | > | | | | > > | | | > | | | > > +---org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(Class, > boolean, boolean) | 2,560 47 % | > 0 | > | | | | > > | | | > | | | > > +---org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(String, > RootBeanDefinition) | 2,460 > 45 % | 10 | > | | | | | > > | | | > | | | | > > +---org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(String, > RootBeanDefinition, Class[]) | 2,420 45 % | > 100 | > | | | | | | > > | | | > | | | | | > > +---org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.getTypeForFactoryMethod(String, > RootBeanDefinition, Class[]) | 1,750 32 % | 0 | > | | | | | | | > > | | | > | | | | | | > +---org.springframework.util.ReflectionUtils.getAllDeclaredMethods(Class) > | > 1,490 27 % | 20 | > | | | | | | | | > -- --------------------------------------------------- Nikita Tovstoles cell: +1-650-996-8173 ---------------------------------------------------