Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does the start-up time compose of in Java virtual machine?

Sometimes I heard people discussing about the start-up time for Java. It seems this is an important performance aspect. But what it really is?

  • What does it compose of?
    1. Class loading time caused by dynamic class loading?
    2. Or first time compilation overhead in compile-only JVM?
    3. Or something else that causes the "slowness" during the beginning period of a Java program execution?

Then, the second question is

  • how to measure the start-up time for Java programs? From which point to which point is the duration called start-up time?

I don't know if my question is asked in the right way; if not, please let me know. Thanks!

like image 924
JackWM Avatar asked Jun 15 '12 00:06

JackWM


2 Answers

The startup time is not formally defined. Indeed, most terms used in practical IT are not formally defined. (Or the formal definitions are ignored.)

But roughly speaking, it is the time from when the application is launched to when it is ready to do something useful. What goes on during startup is application dependent, but it includes static class loading, static class initialization and (possibly) JIT compilation of some of the classes. Other things might include starting UIs, connecting to databases, preloading application-specific data structures, application "wiring", and so on.

The problem with trying to define "startup time" formally is that any definition is likely to not work for some significant subset of application types. And even when you can define it, there is the complication that some of the startup (or warmup) tasks may continue happening in the background after the application announces itself as "ready".

(This is not a Java specific problem. Consider the "startup" of a laptop; i.e. what happens between powering it on and your desktop being fully usable.)

How to measure the start-up time for Java programs? From which point to which point is the duration called start-up time?

Both of those are up to you to decide, depending on the kind of application you are talking about, and what you want to consider as the startup phase for your application.

like image 176
Stephen C Avatar answered Nov 15 '22 00:11

Stephen C


As Stephen C mentioned, there is no general formal definition for "start-up time".

To get an intuitive understanding of this concept, I found some description on Oracle's webs.

Basically, it gives an informal definition. "The startup time of an application is the time it takes for the application to get up and running and ready to start doing what it is supposed to do." Both the JVM and Application itself can impact the start-up time.

Also, it provides some idea (adjusting heap size -Xms/-Xmx) to reduce the start-up time. Either too large or too small heap size would extend the start-up time.

Further, "Diagnosing a Slow JVM Startup" shows some clues to find the reasons for a slow start-up.

Note the above are all in the context of JRockit JVM, but the ideas are more general.

like image 36
JackWM Avatar answered Nov 14 '22 23:11

JackWM