You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Nikita Tovstoles <ni...@gmail.com> on 2010/02/09 20:34:58 UTC

@SpringBean injection expensive - a bug?

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  |
|    |     |           | | | | |

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: @SpringBean injection expensive - a bug?

Posted by Igor Vaynberg <ig...@gmail.com>.
you can follow the progress here

https://issues.apache.org/jira/browse/WICKET-2741

-igor

On Tue, Feb 16, 2010 at 8:24 AM,  <MZ...@osc.state.ny.us> wrote:
> Any updates on this issue?  Will there be a fix?
>
>
>
>
> Igor Vaynberg <ig...@gmail.com>
> 02/10/2010 06:15 PM
> Please respond to
> users@wicket.apache.org
>
>
> To
> users@wicket.apache.org
> cc
>
> Subject
> Re: @SpringBean injection expensive - a bug?
>
>
>
>
>
>
> create a jira issue and a quickstart. thanks.
>
> -igor
>
> On Tue, Feb 9, 2010 at 11:34 AM, Nikita Tovstoles
> <ni...@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  |
>> |    |     |           | | | | |
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
>
>
>
>
> Notice: This communication, including any attachments, is intended solely
> for the use of the individual or entity to which it is addressed. This
> communication may contain information that is protected from disclosure
> under State and/or Federal law. Please notify the sender immediately if
> you have received this communication in error and delete this email from
> your system. If you are not the intended recipient, you are requested not
> to disclose, copy, distribute or take any action in reliance on the
> contents of this information.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: @SpringBean injection expensive - a bug?

Posted by Nikita Tovstoles <ni...@gmail.com>.
Thanks for the fix, zbigniew. However, IMO it isn't complete:

https://issues.apache.org/jira/browse/WICKET-2737?focusedCommentId=12834859&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#action_12834859

what do you think?

On Wed, Feb 17, 2010 at 1:20 AM, zbigniew <zb...@consol.pl> wrote:

>
>
>
> Any updates on this issue?  Will there be a fix?
>
> Check this out:
> https://issues.apache.org/jira/browse/WICKET-2737
>
> 1.4.7 will have that fix, in the meantime you can patch your wicket-spring
> by yourself.
>
>
> --
> View this message in context:
> http://old.nabble.com/%40SpringBean-injection-expensive---a-bug--tp27520784p27620954.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>


-- 
---------------------------------------------------
Nikita Tovstoles
cell: +1-650-996-8173
---------------------------------------------------

Re: @SpringBean injection expensive - a bug?

Posted by zbigniew <zb...@consol.pl>.


Any updates on this issue?  Will there be a fix?

Check this out:
https://issues.apache.org/jira/browse/WICKET-2737

1.4.7 will have that fix, in the meantime you can patch your wicket-spring
by yourself.


-- 
View this message in context: http://old.nabble.com/%40SpringBean-injection-expensive---a-bug--tp27520784p27620954.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: @SpringBean injection expensive - a bug?

Posted by MZ...@osc.state.ny.us.
Any updates on this issue?  Will there be a fix?




Igor Vaynberg <ig...@gmail.com> 
02/10/2010 06:15 PM
Please respond to
users@wicket.apache.org


To
users@wicket.apache.org
cc

Subject
Re: @SpringBean injection expensive - a bug?






create a jira issue and a quickstart. thanks.

-igor

On Tue, Feb 9, 2010 at 11:34 AM, Nikita Tovstoles
<ni...@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  |
> |    |     |           | | | | |
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org






Notice: This communication, including any attachments, is intended solely 
for the use of the individual or entity to which it is addressed. This 
communication may contain information that is protected from disclosure 
under State and/or Federal law. Please notify the sender immediately if 
you have received this communication in error and delete this email from 
your system. If you are not the intended recipient, you are requested not 
to disclose, copy, distribute or take any action in reliance on the 
contents of this information.

Re: @SpringBean injection expensive - a bug?

Posted by Igor Vaynberg <ig...@gmail.com>.
create a jira issue and a quickstart. thanks.

-igor

On Tue, Feb 9, 2010 at 11:34 AM, Nikita Tovstoles
<ni...@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  |
> |    |     |           | | | | |
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: @SpringBean injection expensive - a bug?

Posted by Nikita Tovstoles <ni...@gmail.com>.
FWIW, explicitly specifying a name with @SpringBean worked around the
problem

On Tue, Feb 9, 2010 at 11:34 AM, Nikita Tovstoles <
nikita.tovstoles@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
---------------------------------------------------