JDK-6618943 : -Xprof overhead is too high
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 6u5
  • Priority: P3
  • Status: Closed
  • Resolution: Won't Fix
  • OS: generic
  • CPU: generic
  • Submitted: 2007-10-19
  • Updated: 2010-10-15
  • Resolved: 2010-10-15
In the 5.0 JDK release the built-in flat profiler in HotSpot was changed to use safepoints to acquire samples of threads' program counters rather than deeper operating system primitives involving suspending threads. There are good reasons for moving away from using these APIs, but using safepoints in the flat profiler has eliminated its usefulness. It used to be the case that the flat profiler would reduce the performance of the profiled application by roughly 10% at most, but it now typically incurs a factor of 5 slowdown. The flat profiler used to be the best tool for the job for really lightweight profiling of performance sensitive applications, and it would be helpful if the previous mechanisms for sampling threads' PCs were reintroduced. They should be orthogonal to the safepoint and Java-level suspension / resumption functionality at this point so should be minimally intrusive. Discussion on internal mailing lists indicates that we could potentially use SIGPROF on Solaris to avoid the use of the deprecated thr_suspend() on that platform. (On Windows, we could use the same thread suspension and PC querying APIs we used to.)

Some of the JOGL demos can be used as test cases. To reproduce, please follow the instructions for downloading JOGL from the Users' Guide on the JOGL home page, in particular setting up of CLASSPATH and PATH. (I recommend testing on the Windows platform for repeatability of results.) Download the jogl-demos.zip from the most recent promoted or nightly build as well. Make sure you are running the most recent OpenGL drivers from your vendor.

The JOGL TestTextRenderer demo, which runs on a wide variety of graphics cards, doesn't run with 1.4.2 due to an apparent bug in that platform. However, it shows the same slowdown (a factor of 5 to 7) when run with both Java 5 and Java 6 with -Xprof. Run it with

java [-Xprof] -Dsun.java2d.noddraw=true demos.j2d.TestTextRenderer

Note the large decrease in frame rate when run with -Xprof.

The JOGL VertexArrayRange demo can be compared between 1.4.2 and 6 directly, though it requires an NVidia graphics card to run. If you have such a card available, you can run it with 

java [-Xprof] -Dsun.java2d.noddraw=true demos.vertexArrayRange.VertexArrayRange

Press 'r' when the demo comes up to cause it to print frame rate statistics to stdout. Note the large slowdowns when run with -Xprof.

Even running with -Xrunhprof does not have the same magnitude of overhead.

The following forum thread may have more pure Java test cases posted: