How can I profile all threads in a multi-threaded application?
The IDE profiles methods that it has instrumented irrespective of the thread that executes these methods. That is, every thread that enters the root method starts to generate profiling data, and continues until it leaves the root method. However, it often appears unnecessary to profile each thread that ever entered the root method, if it is already known that all threads are going to behave in the same way. In order to reduce overhead in this situation, you can set a limit on the maximum number of concurrent threads to profile. By default this number is 32, which we consider enough for most multi-threaded applications. Setting this to value n will result in only the first n threads that entered the root method to be profiled, which, if n is small, may lead to a substantial reduction in the profiling overhead.
With multi-threaded applications it is often important to see all the threads that your application launches when you just begin to analyze it. When profiling a multi-threaded application you have the option to treat all void run() methods of all classes that extend java.lang.Thread or implement java.lang.Runnable, and are loaded by the VM after your designated root method has been started, as implicit roots. That is, the void run() method of such classes is instrumented once the class is loaded. This process, however, does not start until the root method is loaded, and works only for classes loaded after the root class is loaded. If your root method is the main method of the application, all application threads are instrumented; otherwise only the threads started after the root method invocation are instrumented.
To use this option when profiling your application, do the following:
- Create a custom configuration in the Select Profiling Task dialog box
- Click Advanced Settings
- Select Profile new Threads/Runnables
- Click Run to start the profiling session
Back to NetBeans IDE Profiling FAQs
Back to NetBeans User FAQs