Measuring Class Load Time Using OptimizeIt

J

John Raggio

Is it possible to easily measure class load time ( and any dependent
classes that are subsequently loaded) using OptimizeIt? I am trying
to figure out how big a hit we are taking on app load for class
loading. I'm not even sure if this makes sense, but I want to get a
feel for the CPU time overhead caused by loading classes.

Is there a good resource for learning how to best use OptimizeIt? I
read and understand the user manual, but it doesn't really give me a
good handle on how to use the tool effectively.

Thanks,
John
 
N

nos

You could run a test.
But I suppose you think it is easier to ask someone else to do it for ya.
 
J

John Raggio

You could try to post a reasonable answer instead of trying to be a
smart ass.

I did run tests. I was trying to figure out what exactly I should be
looking for in the results to see how I could filter out those items
that had to do with class loading and not actual "work". I am new to
OptimizeIt and am not really sure how to use the tool properly.

Thanks for your help nos.
 
V

Vladimir Kondratyev

I'm afraid that OptimizeIt cannot solve your problem. But there is
YourKit Java Profiler (http://www.yourkit.com) that can do. YourKit
profiler has "CPU Statistics" view. This view shows cumulative time of
all methods grouped by classes. So you just need to check how long
ClassLoader's methods work.

Kind regards,
Vladimir Kondratyev
 
R

rpadev

(e-mail address removed) (Vladimir Kondratyev) wrote in
I'm afraid that OptimizeIt cannot solve your problem. But there is
YourKit Java Profiler (http://www.yourkit.com) that can do. YourKit
profiler has "CPU Statistics" view. This view shows cumulative time of
all methods grouped by classes. So you just need to check how long
ClassLoader's methods work.

Kind regards,
Vladimir Kondratyev


(e-mail address removed) (John Raggio) wrote in message

Vlad:

Thanks for the reply. I will givce it a look. Now that we are on the
subject, what is the best way to speed up app start time? Is lazy
intialization worth the effort?
 
V

Vladimir Kondratyev

Everything depends on the real problem. First of all you have to find
startrup bottleneck. IMO class loading is rarely a problem of slow
startup. Often it's excessive object allocations and heap resizes.
Lazy initialization of subsystems that are required on startup is very
good but lazy initialization should not be paranoia :)

Sincerely,
Vladimir Kondratyev
 
J

Jon A. Cruz

Vladimir said:
I'm afraid that OptimizeIt cannot solve your problem.

Strange.

In the past OptimizeIt has help teams I was solve exactly that problem.
 
R

rpadev

Strange.

In the past OptimizeIt has help teams I was solve exactly that problem.

Jon,

Could you be a little more specific? Our app has a lrage number of
classes in it and I suspect that many of them are loaded becasue they
reference each other. As I understand it, classes are loaded if they are
referenced and not yet instantiated. Do I have this right? What shoul
dbe my next move?

Thanks,
John
 
J

Jon A. Cruz

Vladimir said:
I'm afraid that OptimizeIt cannot solve your problem. But there is
YourKit Java Profiler (http://www.yourkit.com) that can do. YourKit
profiler has "CPU Statistics" view. This view shows cumulative time of
all methods grouped by classes. So you just need to check how long
ClassLoader's methods work.

To explain a little more why I was suspicious of this claim, I just did
a google search and third item listed had some info

http://info.borland.com/techpubs/optimizeit/optimizeit6/thread_debugger/setting_up.html

Under "Choosing operation options"

# Auto-start Analyzer starts the monitor usage analyzer before executing
the tested program main() method. Use this option to include the program
startup phase, like the class loading, in the analysis.




Sorry I couldn't be more specific at first. It's been a while since my
team did the optimization on the product.
 
J

Jon A. Cruz

rpadev said:
Jon,

Could you be a little more specific? Our app has a lrage number of
classes in it and I suspect that many of them are loaded becasue they
reference each other. As I understand it, classes are loaded if they are
referenced and not yet instantiated. Do I have this right? What shoul
dbe my next move?

Uh oh. You're using a naughty word.

"suspect"

:)

That's a big no-no when it comes to performance. Studies have shown that
developer intuition is wrong the majority of the time when it comes to
optimization.

Probably the first thing of all is to measure what's going on. Instead
of guessing, check. As Vladimir pointed out, there are probably actually
two things going on in your situation.

Problem: "My program is slow to start"

Off hand, I'd say that most the time could be from two causes
1) Class loading is slow.
2) Application state and initialization/construction is slow.

So, keeping in mind that there are probably two different things going
on, you'll probably want to start getting measurements of both.


One thing to do is to check/dump the time as the first thing inside of
your main(). Then maybe dump it at the end also.

Another thing to do is to decouple your app's class loading from Java
startup itself. The simple way is to have a bare class that does not
reference any other classes at all. Inside the main of your launcher
stub dump the time, then use reflection to load your real main class.
dump the time again. Then instantiate your main class. Dump the time again.

Start measuring things. Broken apart like that, and with the two
different issues in mind, it should help with profiling.

IIRC, the main thing that might be slowing class loading is static
initializers. See if you have static blocks, or if you have static
variables initialized to a new instance of any classes.


Again, first start by splitting java starting from your classes and look
at where the big numbers fall. Then after that start to hunt down.


*THEN*, after all that is done and you have loads of wall-clock and
profiled measurments, then it will be safe to start thinking about
optimizing and whether or not things will improve your performance.
Since by that point you'll have all sorts of metrics, it will be easy to
A) see what needs improving, and B) see which things have either
negative, positive or negligible.
 
R

rpadev

To explain a little more why I was suspicious of this claim, I just
did a google search and third item listed had some info

http://info.borland.com/techpubs/optimizeit/optimizeit6/thread_debugger
/setting_up.html

Under "Choosing operation options"

# Auto-start Analyzer starts the monitor usage analyzer before
executing the tested program main() method. Use this option to include
the program startup phase, like the class loading, in the analysis.




Sorry I couldn't be more specific at first. It's been a while since my
team did the optimization on the product.

Thanks for the response and for your time. I will dig in on this Monday.
our other post was also helpful.

John
 

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

Forum statistics

Threads
473,733
Messages
2,569,439
Members
44,829
Latest member
PIXThurman

Latest Threads

Top