-
Notifications
You must be signed in to change notification settings - Fork 38.5k
getBean(Class) lookup performance degredation on upgrade #22425
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Any chance you could provide a repro project? |
Hi Sdeleuze, we do the generation of java source files dynamically (depending on the configuration), then compile and register the bean to spring context and try to fetch the bean instance from Below is the code for registering and look up. // bean register logic
AbstractApplicationContext abstractApplicationContext = ( AbstractApplicationContext )applicationContext;
DefaultListableBeanFactory beanFactory = ( DefaultListableBeanFactory )abstractApplicationContext.getBeanFactory();
beanFactory.setAllowBeanDefinitionOverriding( true );
AbstractBeanDefinition beanDefinition = BeanDefinitionBuilder.rootBeanDefinition( implementingClass ).getBeanDefinition();
beanDefinition.setScope( "singleton");
beanFactory.registerBeanDefinition( beanName, beanDefinition );
//Look up
xyz = ( T )**applicationContext.getBean**( StringHelperUtl.firstCharToLower( className ) );
//Next will update the "xyz" instance to cache and from 2nd time onwards we fetch it from our own cache if our hash key matches. Note : Let me know if more details are need. Really appreciate your help and inputs. Also I could see SPR-17282 with same details but with latest versions. Right now we are on Java 1.7 version. |
Implementation class "XmlWebApplicationContext" for applicationContext. |
Hi, We tested the same code with other versions as mentioned below, looks like it got introduced in 4.3.0.RELEASE version. We can see time lag difference from 4.2.9 to 4.3.0 4.2.8Time Difference -> Start : End : Tue Feb 19 23:32:16 PST 2019 --> Tue Feb 19 23:32:17 PST 2019 -> 1Sec 4.2.91st Time 2nd Time 4.3.0Time Difference -> Start : End : Tue Feb 19 22:00:05 PST 2019 --> Tue Feb 19 22:03:27 PST 2019 -> 3mins 22Sec 4.3.2Time Difference -> Start : End : Tue Feb 19 20:58:58 PST 2019 --> Tue Feb 19 21:02:18 PST 2019 -> 2mins 20Sec 4.3.15Time Difference -> Start : End : Tue Feb 19 22:28:27 PST 2019 --> Tue Feb 19 22:31:48 PST 2019 -> 3mins 21Sec 4.3.16Time Difference -> Start : End : Tue Feb 19 22:28:27 PST 2019 --> Tue Feb 19 22:31:48 PST 2019 -> 3mins 24Sec 4.3.17Time Difference -> Start : End : Tue Feb 19 23:18:11 PST 2019 --> Tue Feb 19 23:21:30 PST 2019 -> 3mins 19Sec |
Thanks for these additional details, could you check with latest |
We are on Java7 and tried the latest on 4.3.22. Still performance issue exists as mentioned. |
Thanks @Srikanth249, that helps a lot for a start. Some additional mechanism introduced in the 4.3 timeframe must severely degrade in case of a large number of beans here. We'll try to sort this out for 4.3.23 and the corresponding 5.0.13 and 5.1.6 releases which are probably also affected. |
Thank You @jhoeller, for the update. Thanks in Advance. |
Our next round of releases, including 4.3.23, is scheduled for March 27th. The latest dates can always be found at the https://github.com/spring-projects/spring-framework/milestones page. For this case, I hope we can fully track down the cause of the regression and sort it out by then. |
Hi Juergen, Can we get any intermediate patch or any workaround to resolve this issue, as our new customer go-live and several existing customer upgrades are being impacted and this needs immediate resolution. |
I'm afraid we still don't know the root cause of the performance degradation here. Are you seeing a degradation on first access to a bean (i.e. the type-based resolution algorithm got more expensive) or just on repeated access to the same bean (in which case it's likely that the underlying cache is not being used properly)? Any insight appreciated since we intend to fix this for our March 27th releases still... As for a workaround, there's only really the use of |
Issue is coming only on the first access to the bean, from second time onward its coming as expected. Only by jar upgrade we came across the performance issue, and the same code is present from long time and its the base code for our system, changing the code now as said may cause any other issues to the system and need to perform complete regression. |
Hi Juergen, |
@Srikanth249 You should provide a minimum runnable project like AutowirePerformance.zip in #23905 |
Can someone assign it to me? |
At this point, this issue is not about an independent regression anymore but rather to be seen as part of the wider bean type matching performance topic: #22060. |
Uh oh!
There was an error while loading. Please reload this page.
When upgrading spring versions from 4.2.3 to 4.3.18 I experienced severe performance degradation in some parts of an application that happens to call
ApplicationContext.getBean(Class)
.Same code with 4.2.3 is returning results in 2sec, and with 4.3.18 we see around 2-3 minutes.
Any help is appreciated.
The text was updated successfully, but these errors were encountered: