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

When a change to startup related code is made disable dev mode instrumentation #14775

Merged
merged 3 commits into from
Feb 5, 2021

Conversation

geoand
Copy link
Contributor

@geoand geoand commented Feb 2, 2021

This is done because such code is meant to be run at startup so when it changes,
users expect to see it be rerun

Furthermore, add the -DdisableInstrumentation which allows a user to explicitly turn of instrumentation

@ghost ghost added area/arc Issue related to ARC (dependency injection) area/core labels Feb 2, 2021
@geoand
Copy link
Contributor Author

geoand commented Feb 2, 2021

I am not completely sure about the Arc change - it might catch to much stuff

@gsmet
Copy link
Member

gsmet commented Feb 2, 2021

Hmmm, and what about entities are modified and the database schema needs an update? It this taken care of?

If not, it looks like a usability regression.

@geoand
Copy link
Contributor Author

geoand commented Feb 2, 2021

I have no idea if it's taken care of, but the new build item put in place by this PR, any build step can based on its own rules turn off instrumentation

@stuartwdouglas
Copy link
Member

Yes, if entities are modified and the schema needs to be updated then instrumentation will not be used, as modifying method/field signatures or annotations means that instrumentation can't be used.

This is a bit of a corner case where you are actually coding logic that is run on startup, and only the logic changes.

Copy link
Member

@stuartwdouglas stuartwdouglas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should only apply if the class that was actually modified has a startup event, not if there is any startup event in the whole application.

@geoand
Copy link
Contributor Author

geoand commented Feb 2, 2021

This should only apply if the class that was actually modified has a startup event, not if there is any startup event in the whole application.

But doesn't it make sense that when there is a startup action it should always be executed?

I mean from a user's perspective, it will be hard to figure out and when the startup action is executed unless it always is.
That's the reason I did it the way I did as I believe consistency and being surprised as little as possible is important for users

@stuartwdouglas
Copy link
Member

Instrumentation based reload only takes effect if you modify the bytecode only and no signatures. In general with our current restart unless you are modifying the actual start-up method itself re-executing the start-up method is a necessary but not desirable side effect of how we do restarts (i.e. it needs to run to get the app into a workable state). With instrumentation based reload the app is already in a working state, so re-running the start-up methods will only have an effect if the start-up methods themselves have been changed.

There are edge cases where you could have code on the call path from a startup method that you are calling, but if this is really a problem then IMHO we should just add an option to the mojo to disable instrumentation.

The reason why I added this option is that I have seen reports of apps taking multiple seconds to restart in dev mode (and startup methods can actually be a big culprit here). For a lot of the changes that developers make on a regular basis (i.e. logic errors in a method) this will really increase productivity.

@geoand
Copy link
Contributor Author

geoand commented Feb 2, 2021

I completely understand your reasoning and I do agree that ideally start-up should not be rerun.

However my main reasoning for doing it the way I did it is because:

  1. I think its important to be consistent no matter what way the new user code takes effect
  2. users are already familiar with the restart behavior - they actually do see it as a proper restart where everything is rerun

If you insist, I can certainly limit the scope of the change to what you mention

@stuartwdouglas
Copy link
Member

Well in that case we should just remove it entirely. Its not worth maintaining something that will never be used.

@geoand
Copy link
Contributor Author

geoand commented Feb 2, 2021

You mean remove the instrumentation?

Why remove it just because of the startup thing?
Most applications probably won't have the startup capability anyway.

@stuartwdouglas
Copy link
Member

I think most applications that are large enough to benefit from the instrumentation based approach will have startup code, especially because it is often startup code that slows the reload down. Even things like @PostConstruct on a JAX-RS resource could be considered startup code, as this will be re-run on a full startup but not on instrumentation based reload.

@geoand
Copy link
Contributor Author

geoand commented Feb 3, 2021

Hm... That's an interesting point indeed.

So I guess for now we should go with what you suggested and see what users think as they start using the instrumentation more

@mkouba
Copy link
Contributor

mkouba commented Feb 3, 2021

FYI many extensions use @Observes StartupEvent as well, e.g. to initialize some beans at runtime.

@geoand geoand force-pushed the dev-instr-allow-disable branch from 1d031db to 670a0d7 Compare February 3, 2021 07:36
@ghost ghost added area/devtools Issues/PR related to maven, gradle, platform and cli tooling/plugins area/maven labels Feb 3, 2021
@geoand geoand changed the title When @Observes StartupEvent is used, disable dev mode instrumentation When a change to startup related code is made disable dev mode instrumentation Feb 3, 2021
@geoand geoand requested a review from stuartwdouglas February 3, 2021 07:37
@geoand
Copy link
Contributor Author

geoand commented Feb 3, 2021

PR completely overhauled - It's title and description have been updated to reflect what it now does

@stuartwdouglas
Copy link
Member

We should probably make this easy to turn on/off via config, and also easy to quickly turn on/off in the dev console.

@stuartwdouglas stuartwdouglas force-pushed the dev-instr-allow-disable branch from 670a0d7 to 7e709bc Compare February 4, 2021 02:20
@stuartwdouglas
Copy link
Member

I have changed this to use config to enable/disable instrumentation, and also expanded the test to cover it.

@geoand
Copy link
Contributor Author

geoand commented Feb 4, 2021

@stuartwdouglas seems like various tests are failing with java.lang.NoClassDefFoundError: io/quarkus/deployment/dev/DevConfig

geoand and others added 3 commits February 4, 2021 18:26
…mentation

This is done because such code is meant to be run at startup so when it changes,
users expect to see it be rerun
@stuartwdouglas stuartwdouglas force-pushed the dev-instr-allow-disable branch from 7e709bc to 6643b08 Compare February 4, 2021 07:28
@gsmet
Copy link
Member

gsmet commented Feb 4, 2021

Wondering if this should backported? Instrumentation based reload is part of 1.11, right?

@geoand
Copy link
Contributor Author

geoand commented Feb 4, 2021

@stuartwdouglas stuartwdouglas merged commit 9480b5f into quarkusio:master Feb 5, 2021
@ghost ghost added this to the 1.12 - master milestone Feb 5, 2021
@gsmet gsmet modified the milestones: 1.12 - master, 1.11.2.Final Feb 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/arc Issue related to ARC (dependency injection) area/core area/devtools Issues/PR related to maven, gradle, platform and cli tooling/plugins area/maven
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants