There you are, submitting your poor application to the worst load imaginable. However, after looking at the profiling data in Mission Control, the evil grin on your face is quickly replaced by a look of surprise. The [CPU] load on the machine is only a fraction of what should be available to your application. You’ve got a throughput problem.
Picture of heavily loaded multi-threaded app running on a multi-core machine
Mission Control contains a lot of information about why your application isn’t spending time executing Java code. Events are produced for almost everything that can make your threads halt. For example, in the Contention tab there is aggregated information, per class, about what classes of locks are blocking your threads (on monitor enter) the most.
Sometimes, however, you really want to look at the information on a per lock instance basis. Take the following example:
You may, for example, want to know if all the sun.misc.Launcher$AppClassLoader locks are one and the same [instance], or if there are several in play. The easiest way to check this is to set the operative set to the events for that lock class, and then view those events in a histogram grouped by the monitor address (don’t let the name confuse you – it’s actually the lock address).
First add to the operative set:
Then build the histogram (don’t forget to check Show Only Operative Set):
Indeed, in this case they are blocking on the same instance. Admittedly a silly example, but you get the idea. Note that one drawback is that the monitor address information is only guaranteed to be coherent in between garbage collections, as the lock object may have been moved due to propagation and/or compaction during a garbage collection. If it is very important to not have a certain lock instance being reported more than once, make sure you study a range between two garbage collections.
Now, if you find yourself looking at this kind of information a lot, you may want to redesign the GUI to contain this information in a separate tab. This is easier to accomplish than you may think; I’ll post another blog with step-by-step instructions on how to accomplish that in a bit.