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

Update Gradle bootRun to launch JVM with flags to enable development-time optimisations #16222

Closed
wilkinsona opened this issue Mar 13, 2019 · 14 comments
Assignees
Labels
theme: performance Issues related to general performance type: enhancement A general enhancement
Milestone

Comments

@wilkinsona
Copy link
Member

Both IDEA and Spring Tools launch Boot apps during development with customised tiered compilation and the verifier disabled to reduce startup time. We should do the same with spring-boot:run in Maven and bootRun in Gradle.

@wilkinsona wilkinsona added this to the 2.2.x milestone Mar 13, 2019
@wilkinsona wilkinsona added type: enhancement A general enhancement theme: performance Issues related to general performance labels Mar 13, 2019
@ghost
Copy link

ghost commented Mar 13, 2019

@wilkinsona Can we get a reference to study for IDEA and Spring Tools about customising tiered compilation and the disabled verifier?

@wilkinsona
Copy link
Member Author

@dosdebug You can just launch an app using their Spring Boot support and take a look at the JVM options. I'm not sure if it's documented anywhere in either case. The relevant code in Spring IDE is here.

@ghost
Copy link

ghost commented Mar 14, 2019

@wilkinsona There will definitely be a better solution but can you please see and suggest if it's the right direction or where should I focus on.

https://github.com/dosdebug/spring-boot/commit/d712978571c79195ab5f0d0d396d4633848cb390

I never have tried contributing before but trying to see if I can really do it.

@wilkinsona
Copy link
Member Author

Thanks for taking a look at this, @dosdebug. I'm not sure we're quite ready to implement this yet as we have some design decisions to make. For example, we need to decide when the arguments should be applied (always, when the user doesn't specify anything, always unless they've been disabled, etc).

@wilkinsona wilkinsona added the status: pending-design-work Needs design work before any code can be developed label Mar 14, 2019
@ghost
Copy link

ghost commented Mar 14, 2019

@wilkinsona Okay sure. No worries. But thank you for your time.

@wilkinsona
Copy link
Member Author

wilkinsona commented Apr 18, 2019

This branch contains a proposal for the Gradle side of things.

By default -Xverify:none and -XX:TieredStopAtLevel=1 are added to the JVM args used by the BootRun task. This happens both when the user has configured some JVM args and when they have not. The addition of these JVM arguments can be disabled by setting a new fastLaunch property to false.

I originally explored an approach that would not need the fastLaunch property, but it got quite complex and difficult to understand, particularly when the application plugin's applicationDefaultJvmArgs property was taken into consideration. While what I've ended up with adds an extra property, I think that added complexity is outweighed by the behaviour being simpler and easier to document. It should also be possible to implement the same behaviour in the Maven plugin.

Flagging for team attention to see if we have agreement on the approach. I'm also not convinced by the name of the fastLaunch property so suggestions for a better name would be much appreciated.

@wilkinsona wilkinsona added the for: team-attention An issue we'd like other members of the team to review label Apr 18, 2019
@ghost
Copy link

ghost commented Apr 18, 2019

@wilkinsona How about just quick?

@wilkinsona
Copy link
Member Author

Thanks for the suggestion. Disabling the verifier has no benefit once all of the classes have been loaded and tuning the JIT to stop at an earlier compilation level actually slows things down for a long-running process. In other words, the settings really only reduce the initial startup time rather than making everything quick. As such, I think launch, start or something similar should appear in the name.

@wilkinsona
Copy link
Member Author

wilkinsona commented Apr 26, 2019

Inspired by the terminology used in IntelliJ IDEA, we're going to go with optimizedLaunch.

@philwebb philwebb removed the for: team-attention An issue we'd like other members of the team to review label Apr 26, 2019
@wilkinsona wilkinsona self-assigned this May 17, 2019
@wilkinsona wilkinsona removed the status: pending-design-work Needs design work before any code can be developed label May 17, 2019
@wilkinsona
Copy link
Member Author

@dosdebug Would you like to update your proposal for Maven based on what I have done for Gradle but with the property being called optimizedLaunch?

@ghost
Copy link

ghost commented May 22, 2019

@wilkinsona Sure, I am going to give it a try and submit PR

@ghost
Copy link

ghost commented May 22, 2019

@wilkinsona Please review #16941 when you have time.

@wilkinsona wilkinsona changed the title Update spring-boot:run and bootRun to launch JVM with flags to enable development-time optimisations Update Gradle bootRun to launch JVM with flags to enable development-time optimisations May 25, 2019
@wilkinsona
Copy link
Member Author

I've retitled this issue to focus on Gradle. #16941 will take care of the Maven side of things.

@wilkinsona wilkinsona modified the milestones: 2.2.x, 2.2.0.M4 May 25, 2019
@yihtserns
Copy link

Note to fellow users

When you have a transitive import/dependency missing from classpath e.g. because it's not actually used at runtime, and you're wondering why:

  1. NoClassDefFoundError is thrown for that when you use the Spring Boot app via the built distribution/Docker, but
  2. That same issue is not reproducible when running via bootRun

...that's because this change added -Xverify:none for #​2. If you want #​2 to behave as close as possible to #​1, do (for Gradle):

tasks.withType(org.springframework.boot.gradle.tasks.run.BootRun) {
    optimizedLaunch = false
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
theme: performance Issues related to general performance type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

3 participants