Go to main content
Oracle® Developer Studio 12.5: Performance Analyzer Tutorials

Exit Print View

Updated: June 2016
 
 

Understanding the Java HotSpot Compiler Behavior

This procedure continues from the previous section, and shows you how to use the Timeline and Threads views to filter and find the threads responsible for HotSpot compiling.

  1. Select the Timeline view and remove the filter by clicking the X in the Active Filters panel, then reset the horizontal zoom to the default by pressing 0 on your keyboard.

    You can also click the |< button in front of the horizontal slider in the Timeline tool bar, or right-click in the Timeline and select Reset.

  2. Open the Function Colors dialog again, and pick different colors for each of the Routine.* functions.

    In the Timeline view, the color changes appear in call stacks of thread 2.

    image:Timeline view of Routine.* functions different colors
  3. Look at all the threads of the Timeline in the period of time where you see the color changes in thread 2.

    You should see that there are some threads with patterns of events occurring at just about the same time as the color changes in thread 2. In this example, they are threads 17, 18, and 19.

    image:Threads view with threads showing HotSpot behavior
  4. Go to the Threads view and select thread 2 and the threads in your experiment that show activity during the time period where thread 2 shows calls to Routine.* functions.

    You might find it easier to first sort by name by clicking the Name column header. Then select the multiple threads by pressing Ctrl as you click the threads.

    In this example, threads 2, 17, 18, 19 are selected.

    image:Threads view with Threads 2, 17, 18, and 19 selected
  5. Click the filter button image:Filter icon in the toolbar and select Add Filter: Include only events with selected items.

    This sets a filter to include only events on those threads. You could also right-click in the Threads view and select the filter.

  6. Return to the Timeline View and reset the horizontal zoom to make the pattern easier to see.

  7. Click on events in threads 17 and 18.

    Note that the Call Stack panel shows CompileBroker::compiler_thread_loop(). Those threads are the threads used for the HotSpot compiler.

    image:Timeline view with events in Threads 17 and 18 selected

    Thread 19 shows call stacks with ServiceThread::service_thread_entry() in them.

    image:Filtered Timeline view to show events on specific threads

    The reason the multiple events occur on those threads is that whenever the user code invokes a new method and spends a fair amount of time in it, the HotSpot compiler is triggered to generate machine code for that method. The HotSpot compiler is fast enough that the threads that run it do not consume very much User CPU Time.

    The details of exactly how the HotSpot compiler is triggered is beyond the scope of this tutorial.