Help save net neutrality! Learn more.

#237 operf problems with --pid and --system-wide options


There are two distinct issues when trying to collect a profile of a Java application if operf is used with either the '--pid' option or the '--system-wide' option:

1) To stop operf in either case, the user must do a ctrl-C (or 'kill -SIGINT <operf_pid>'. If not using '--lazy-conversion', the operf.cpp:convert_sample_data function is run in a child process that does not have a SIGINT handler set up for it while reading sample data from the pipe (which is being written to by the operf-record process). The end result is that the operf-read process is interrupted and stopped by the unhandled ctrl-C before it gets a chance to run opjitconv.

2) When passing the 'java' command directly to operf, samples are nicely collected for all of the threads created by the JVM. However, if the Java app is already running when the user starts operf with either '--pid' or '--system-wide' option, zero samples are collected on the child threads of the JVM. Note: The user program that is JITed by the JVM is executed by a child thread.

Note: Another (minor) side effect of issue #1 above is that there may be sample data left un-read in the pipe, and the type of app being profiled (Java or not) is irrelevant.

I have a fix for issue #1 above, and I'll attach the patch.


  • Maynard Johnson

    Maynard Johnson - 2013-02-08

    I posted a patch for issue #2 to the oprofile-list on Feb 7, subject line "[PATCH] operf does not properly sample already-running Java apps".

  • Maynard Johnson

    Maynard Johnson - 2013-03-14

    I split the attached patch into two parts -- 1) to make sure opjitconv is always run; and 2) to fix profiling of already-running multi-threaded apps. I committed #1 on Feb 11, 2013 and #2 on Feb 21, 2013.

  • Maynard Johnson

    Maynard Johnson - 2013-03-14
    • status: open --> open-fixed
  • Maynard Johnson

    Maynard Johnson - 2013-07-17
    • assigned_to: Maynard Johnson
    • Group: -->
  • Maynard Johnson

    Maynard Johnson - 2013-07-29
    • status: open-fixed --> closed-fixed

Log in to post a comment.