-
Notifications
You must be signed in to change notification settings - Fork 40.8k
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
Use @Configuration(proxyBeanMethods=false) wherever possible #9068
Comments
See https://github.com/philwebb/spring-boot/tree/gh-9068 for an example. Tests still appear to pass on this branch. Startup time for |
Some Master:
Branch:
|
Isn't that going a tad too far? I understand the performance argument but reading an auto-configuration flagged as a component is very odd. And the lite mode is something I am not sure we should advertize. What are you going to write in the user guide to justify such move? |
@philwebb are you sure that the performance changes that you presented are not just statistically insignificant fluctuations? Change of 3% or 100ms seems like a noise :) |
@iNikem How do you draw that conclusion without knowing by how much the timings usually fluctuate? Do you have some additional data to share? |
@wilkinsona I don't have more data. I just saw the comment above where @philwebb showed time measurements from 7 runs. IMO 7 data points is never enough to draw any conclusions about performance |
While we're still not keen on using Fat jar:
Main method:
|
The following classes in Spring Boot require proxying as they have one or more
All of these are out of our control. In each case we sub-class a class from another project and it's the code in the super-class that means that a proxy is required. We also have one class where the need for a proxy is, largely, self-inflicted:
There are a few other classes in Boot that currently rely on proxying, but it's straightforward to change them so that they do not do so. |
when use @configuration(proxyBeanMethods = false) whill erro in my bean getOtherBean |
@hefreecola this means you're probably relying on proxying (inter-bean methods calls). In this case, you shouldn't use this option. See javadoc. For further questions, please use StackOverflow. |
As part of performance start-up time improvement, Spring 5.2 brings the option to disable the cglib proxy, allowing henceforth configuration classes to be final. Mind that inner-class bean method call are no longer possible since no proxy will ensure the unique instance (if bean scope defaulted to singleton). Reference: spring-projects/spring-boot#9068
As part of performance start-up time improvement, Spring 5.2 brings the option to disable the cglib proxy, allowing henceforth configuration classes to be final. Mind that inner-class bean method call are no longer possible since no proxy will ensure the unique instance (if bean scope defaulted to singleton). Reference: spring-projects/spring-boot#9068
Almost all of our auto-configuration classes are currently annotated with
@Configuration
. The means that theConfigurationClassPostProcessor
will treat them as full configuration classes and create cglib proxies.This is potentially quite an expensive operation and is unnecessary for most of them. As long as we use parameter injection (and don't call other methods directly) we can use the
@Component
annotation instead to createConfigurationClassUtils.CONFIGURATION_CLASS_LITE
configuration.The text was updated successfully, but these errors were encountered: