Profiling class loading?

Discussion in 'Java' started by Thomas Kellerer, Apr 30, 2008.

  1. 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
    Thomas Kellerer, Apr 30, 2008
    #1
    1. Advertising

  2. In article <>,
    Thomas Kellerer <> wrote:

    > 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.

    --
    Block Google's spam and enjoy Usenet again.
    Reply with Google and I won't hear from you.
    Kevin McMurtrie, May 2, 2008
    #2
    1. Advertising

  3. Kevin McMurtrie wrote on 02.05.2008 08:32:
    >> 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

    >


    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

    >
    Thomas Kellerer, May 2, 2008
    #3
  4. 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

    --

    "I'm a doctor, not a mechanic." Dr Leonard McCoy <>
    "I'm a mechanic, not a doctor." Volker Borchert <>
    Volker Borchert, May 2, 2008
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. E11
    Replies:
    1
    Views:
    4,684
    Thomas Weidenfeller
    Oct 12, 2005
  2. David Segall
    Replies:
    2
    Views:
    422
    Thomas Kellerer
    Jan 2, 2007
  3. Replies:
    4
    Views:
    284
  4. edfialk
    Replies:
    0
    Views:
    171
    edfialk
    May 10, 2007
  5. ofir
    Replies:
    0
    Views:
    170
Loading...

Share This Page