Spring Boot application takes too long to initialize with th

Questions about YourKit Java Profiler
Locked
maseev
Posts: 4
Joined: Sat Jul 21, 2018 4:43 pm

Spring Boot application takes too long to initialize with th

Post by maseev »

Hi.

I've got a Spring Boot application which I run inside a Docker container. The problem is, it takes too long for the application to fully initialize.

For example, when I run the application inside the Docker container without the YourKit Java agent attached to it, it takes approximately 1 minute to initialize and start accepting requests from users.
However, when I run the very same application with the YourKit Java agent attached to it, it takes 10 minutes to start. This particular problem manifests itself only in the container environment.

I used the YourKit guide in order to setup the Java agent inside a Docker container, but it seems to me there's something else going on. Unfortunately, I wasn't able to see any problems in the agent log. It looks pretty normal to me.

Is there anything I can do to find out what slows down the application with the agent attached to it?

Thanks.
maseev
Posts: 4
Joined: Sat Jul 21, 2018 4:43 pm

Re: Spring Boot application takes too long to initialize wit

Post by maseev »

Anton Katilin
Posts: 6172
Joined: Wed Aug 11, 2004 8:37 am

Re: Spring Boot application takes too long to initialize wit

Post by Anton Katilin »

Hi,

There is nothing odd in the log.

Please note you run with the debugger too (-agentlib:jdwp). Please check if the problem is reproducible without -agentlib:jdwp.

Please try the agent startup options recommended by the EE server integration wizard:

-agentpath:<path to agent>=port=<port>,listen=all,disablestacktelemetry,exceptions=disable

Does this help?

Best regards,
Anton
maseev
Posts: 4
Joined: Sat Jul 21, 2018 4:43 pm

Re: Spring Boot application takes too long to initialize wit

Post by maseev »

Anton Katilin wrote:Hi,
Please note you run with the debugger too (-agentlib:jdwp). Please check if the problem is reproducible without -agentlib:jdwp.
Yes, it's reproducible without the remote debugger agent attached to the JVM. The interesting thing is when I leave the jdwp agent connected to the JVM and add the "disablestacktelemetry,exceptions=disable" options to the YourKit Java agent, the startup time drops from 10 minutes to 2.
If I remove the jdwp agent and leave only the YourKit Java agent with these options "disablestacktelemetry,exceptions=disable" the application takes only 1 minute to start.
Anton Katilin wrote: Please try the agent startup options recommended by the EE server integration wizard:

-agentpath:<path to agent>=port=<port>,listen=all,disablestacktelemetry,exceptions=disable

Does this help?
Actually, yes, it does help. Now the application takes a little bit more than a minute to fully initialize (without jdwp agent though).

Although, I'm a little bit worried whether it's a good idea to disable stack telemetry altogether. The documentation says that this information can potentially be very useful in the debugging process. If I understand correctly, I won't be able to turn this feature back on using YourKit profiler.

And what about this option - "exceptions=disable"? Can I use "exceptions=off" instead of "disable" so I'd be able to turn this feature on at runtime via YourKit profiler connected to the app? I'm not really sure that's a good idea to disable this feature completely.
Anton Katilin
Posts: 6172
Joined: Wed Aug 11, 2004 8:37 am

Re: Spring Boot application takes too long to initialize wit

Post by Anton Katilin »

Hi,
I won't be able to turn this feature back on using YourKit profiler.
It's not true. You can turn stack telemetry on and off in runtime when you want, with the toolbar button in the profiler UI or programmatically:
https://www.yourkit.com/docs/java/help/threads.jsp
And what about this option - "exceptions=disable"? Can I use "exceptions=off" instead of "disable" so I'd be able to turn this feature on at runtime via YourKit profiler connected to the app? I'm not really sure that's a good idea to disable this feature completely.
Please try "exceptions=off". Normally, the overhead should not be significant.

Best regards,
Anton
maseev
Posts: 4
Joined: Sat Jul 21, 2018 4:43 pm

Re: Spring Boot application takes too long to initialize wit

Post by maseev »

Anton Katilin wrote: It's not true. You can turn stack telemetry on and off in runtime when you want, with the toolbar button in the profiler UI or programmatically:
https://www.yourkit.com/docs/java/help/threads.jsp
Oh, I see. I forgot about this button completely. Well, that's great. I guess it's not a big deal to have stack telemetry disabled from the start because I can always turn it back on from YourKit profiler. The only thing is that I won't have any "historical" data about stack telemetry unless I enable this feature from profiler by clicking on that button you mentioned before.
Anton Katilin wrote: Please try "exceptions=off". Normally, the overhead should not be significant.
Sure, I already did. It works perfectly.

Thank you for your help, Anton.

Have a great day.
sv123455
Posts: 1
Joined: Mon Aug 09, 2021 10:25 pm

Re: Spring Boot application takes too long to initialize wit

Post by sv123455 »

We have a similar setup, a spring boot app,. running within docker, and like most spring apps, quite a bit of runtime code generation goes on.

When we start the app without the yourkit - 30-35 seconds of startup time
When we start the app with yourkit and these parameters : disablestacktelemetry,exceptions=disable - the startup time is about 40-45 seconds
When we start the app with yourkit and these parameters : disablestacktelemetry,exceptions=off - the startup time is about 210 seconds

and needless to say - without any explicit parameters to disablestacktelemetry and exceptions it takes much longer than the 210 seconds,. closer to 300+ seconds

Any thoughts on why we are seeing that much of a difference between exceptions=off vs exceptions=disable?

Do let me know if you need any other info,

regards,
Anton Katilin
Posts: 6172
Joined: Wed Aug 11, 2004 8:37 am

Re: Spring Boot application takes too long to initialize wit

Post by Anton Katilin »

Exception profiling depends on exception events in the JVM.
https://www.yourkit.com/docs/java/help/ ... filing.jsp

"exceptions=off" enables exception events in the JVM but does not immediately start the exception profiling that can instead be started later in runtime.

"exceptions=disable" fully disables exception events in the JVM to totally eliminate corresponding overhead. The exception profiling will not be available.

Apparently the number of throws exceptions in your case is high which makes the event overhead significant.
Locked