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

Look for optimizations in AutoConfigurationImportSelector #15495

Closed
dsyer opened this issue Dec 19, 2018 · 4 comments
Closed

Look for optimizations in AutoConfigurationImportSelector #15495

dsyer opened this issue Dec 19, 2018 · 4 comments
Labels
status: invalid An issue that we don't feel is valid theme: performance Issues related to general performance

Comments

@dsyer
Copy link
Member

dsyer commented Dec 19, 2018

A regression in performance in spring-projects-experimental/spring-init was traced to a hostspot in AutoConfigurationImportSelector.getAutoConfigurationEntry() - once we prevented that method from being called when we already knew the imports, we were able to save nearly 5% of startup time in a micro app.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Dec 19, 2018
@dsyer dsyer added the theme: performance Issues related to general performance label Dec 19, 2018
@wilkinsona
Copy link
Member

I'm not sure that there's much to be gained here in a typical app that uses @SpringBootApplication. AutoConfigurationImportSelector.getAutoConfigurationEntry(AutoConfigurationMetadata, AnnotationMetadata) is called once and takes in the region of 10ms on my laptop. 7ms of that is spent in AutoConfigurationImportSelector.filter(List<String>, AutoConfigurationMetadata).

Can you give us some code to run where it's taking 5% of startup and will appear as a hotspot?

@wilkinsona wilkinsona added the status: waiting-for-feedback We need additional information before we can continue label Dec 19, 2018
@dsyer
Copy link
Member Author

dsyer commented Dec 19, 2018

10ms is less than 5% of the app I was running, so probably I overstated it - I made other changes, but this was the biggest one. The hotspot was in getAttributes(). The app was this one: https://github.com/spring-projects-experimental/spring-init/blob/master/tests/benchmarks/src/main/java/com/example (there are 3 apps there and the difference between the "manual" and "init" ones was driving the changes). You'd have to go back a few commits in spring-init to wind back through the optimizations and see the effect.

In a @SpringBootApplication aren't the imports known by reading spring.factories? Why do we even need to read the annotation metadata in that case? It seems over-engineered for the simplest use case, so even if it is only a small gain, it might be worth having.

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Dec 19, 2018
@wilkinsona
Copy link
Member

wilkinsona commented Dec 19, 2018

10ms is less than 5% of the app I was running, so probably I overstated it

That's really frustrating. Precision is vital here otherwise we're going to waste time chasing benefits that don't exist.

The hotspot was in getAttributes()

That method takes < 1ms for me. As I said above, the main cost that I see is in filter. It takes 7ms with 3-4ms of that being the call to load the filters via spring.factories. That 7ms is time well spent as it removes considerably more than 7ms of processing later on in startup. See #7573.

Why do we even need to read the annotation metadata in that case?

To honour the exclude attribute.

@wilkinsona wilkinsona added for: team-attention An issue we'd like other members of the team to review and removed status: feedback-provided Feedback has been provided labels Dec 19, 2018
@dsyer
Copy link
Member Author

dsyer commented Dec 19, 2018

OK. So probably there is nothing further to do here for now. There was a real gain in the prototype, but it can't be translated into a general benefit for Spring Boot.

@dsyer dsyer closed this as completed Dec 19, 2018
@wilkinsona wilkinsona added status: invalid An issue that we don't feel is valid and removed for: team-attention An issue we'd like other members of the team to review status: waiting-for-triage An issue we've not yet triaged labels Dec 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: invalid An issue that we don't feel is valid theme: performance Issues related to general performance
Projects
None yet
Development

No branches or pull requests

3 participants