Profiling class loading?

T

Thomas Kellerer

Hi,

I'm trying to tune the startup time of my (Swing) application. First step was to
analyze the number of classes that are loading during startup. I'm still trying
to reduce that number, but now I'm at a point were any change would require a
larger re-write of the startup logic.

Because of that I would like to find out which classes actually slow down the
startup.

I can easily profile performance of the classes once the application is running,
but I can't find a way to find out which class took how long to load.

Any ideas?

Btw: something that I have been asking myself: is it quicker to load two small
classes or a single bigger class?

Thanks in advance
Thomas
 
K

Kevin McMurtrie

Thomas Kellerer said:
Hi,

I'm trying to tune the startup time of my (Swing) application. First step was
to
analyze the number of classes that are loading during startup. I'm still
trying
to reduce that number, but now I'm at a point were any change would require a
larger re-write of the startup logic.

Because of that I would like to find out which classes actually slow down the
startup.

I can easily profile performance of the classes once the application is
running,
but I can't find a way to find out which class took how long to load.

Any ideas?

Btw: something that I have been asking myself: is it quicker to load two
small
classes or a single bigger class?

Thanks in advance
Thomas

If it's strictly for Sun's JVM, try the option:

-XX:CompileThreshold=40000

This large threshold delays expensive native compilation. It can help
certain kinds of apps launch faster. Also:

-XX:+PrintCompilation
-XX:+TraceClassLoading

This will tell you what's loading and compiling. You want the main
foundation classes compiling as soon as possible (String, HashMap, etc.)
but you don't want single-use initialization code compiling
(MyClass.<init>).

There's probably a profiler for the classloader somewhere. My guess is
that the slowness is loading all of the AWT, Java 2D, and Swing classes.
 
T

Thomas Kellerer

Kevin McMurtrie wrote on 02.05.2008 08:32:
Thanks for the answer
If it's strictly for Sun's JVM, try the option:

-XX:CompileThreshold=40000

Yes, I have already tried that one.
But it smells more like a workaround to me :)
This large threshold delays expensive native compilation. It can help
certain kinds of apps launch faster. Also:

-XX:+PrintCompilation
-XX:+TraceClassLoading
I was using -verbose::class so far. The output of those two options seems a bit
more detailed. Is there a documentation somwehere regarding the additional
details? I'm talking about things like this:

[Loaded sun.misc.URLClassPath$JarLoader from shared objects file]
1 java.lang.String::hashCode (60 bytes)

What does the "1" mean? It seems to be a counter or something, as it increases
with each log entry.

Then there are entries with an exclamation mark, like this one:

[Loaded sun.misc.Launcher$1 from shared objects file]
9 java.io.Win32FileSystem::normalize (143 bytes)
10 sun.nio.cs.SingleByteDecoder::decode (33 bytes)
11 ! java.io.BufferedReader::readLine (304 bytes)
12 ! sun.nio.cs.SingleByteDecoder::decodeArrayLoop (308 bytes)

What does the ! mean here?

and a real strange one:

[Loaded javax.swing.JTree$TreeSelectionRedirector from shared objects file]
180 javax.swing.JComponent::getInputMap (142 bytes)
181 javax.swing.UIManager::getColor (8 bytes)
--- n java.lang.Class::isInstance

(note the --- n in the last line)

There's probably a profiler for the classloader somewhere.
I have looked for one, but wasn't successful so far.
My guess is that the slowness is loading all of the AWT, Java 2D, and Swing classes.
Yes probably. And the number of my own classes compared to the ones loaded from
the JDK is relatively small, so I doubt I could actually win something by
reducing that number.

Regards
Thomas
 
V

Volker Borchert

Thomas Kellerer wrote:

|> [Loaded javax.swing.JTree$TreeSelectionRedirector from shared objects file]
|> 180 javax.swing.JComponent::getInputMap (142 bytes)
|> 181 javax.swing.UIManager::getColor (8 bytes)
|> --- n java.lang.Class::isInstance
|>
|> (note the --- n in the last line)

native method
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top