Skip to content
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

Reduce BeanDefinition cloning in AbstractBeanFactory.getMergedBeanDefinition [SPR-12236] #16851

Closed
spring-issuemaster opened this issue Sep 22, 2014 · 3 comments
Assignees
Milestone

Comments

@spring-issuemaster
Copy link
Collaborator

@spring-issuemaster spring-issuemaster commented Sep 22, 2014

Phil Webb opened SPR-12236 and commented

Profiling the Spring Boot Petclinic sample shows that the getMergedBeanDefinition method in AbstractBeanFactory is called 80,000+ times (and before configuration is frozen). The main callers are getType and getTypeMatch.

We could improve performance by not always cloning the BeanDefinition in this method.


Affects: 4.1 GA

Issue Links:

  • #18841 markBeanAsCreated does not clear merged bean definition in a thread-safe fashion
  • #17735 Use already loaded metadata when possible for AbstractAutowireCapableBeanFactory.getTypeForFactoryMethod
  • #17684 Reduce memory consumption for caches

Referenced from: commits 09eb492

@spring-issuemaster
Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Jun 18, 2015

Phil Webb commented

#820 helps a little with this

@spring-issuemaster
Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Jul 10, 2015

Juergen Hoeller commented

I'm trying a slightly different approach now: allowing for early caching of merged bean definitions, enforcing a fresh re-cache step once a bean is about to be created (in order to catch the latest metadata modifications if any).

Juergen

@spring-issuemaster
Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Jul 14, 2015

Juergen Hoeller commented

The re-caching approach seems to work fine in combination with a few extra measures, such as re-caching not only when a bean is about to be created but also after the ApplicationContext post-process phase. Some pre-resolved metadata is critical to retain afterwards though, e.g. for qualifier matching on factory methods, so we keep the merged bean definition around afterwards.

Juergen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.