Re: [PATCH v2 0/4] perf: add support for profiling jitted code

Ingo Molnar
2015-02-18T17:32:01Z

* Stephane Eranian <eranian@google.com> wrote:

> The current support only works when the runtime is
> monitored from start to finish: perf record java
> --agenpath:libpfmjvmti.so my_class.

Could we add '--agenpath:libpfmjvmti.so' automatically if a
binary called 'java' is recorded?

( With a --nojavajit flag to not do that, should someone
feel like having a 'java' executable that doesn't accept
the --agenpath flag, or so? Assuming the major JVMs
accept the --agenpath flag. )

> Once the run is completed, the jitdump file needs to be
> injected into the perf.data file. This is accomplished by
> using the perf inject command. This will also generate an
> ELF image for each jitted function. The inject MMAP
> records will point to those ELF images. The reasoning
> behind using ELF images is that it makes processing for
> perf report and annotate automatic and transparent. It
> also makes it easier to package and analyze on a remote
> machine.

So it would be nice if this part was automatic, i.e. if I
could just profile a java run with the regular perf
profiling flow.

> The reporting is unchanged, simply invoke perf report or
> perf annotate on the modified perf.data file. The jitted
> code will appear symbolized and the assembly view will
> display the instruction level profile!
>
> As an added bonus, the series includes support for
> demangling function signature from OpenJDK.

Cool!

> Furthermore, we believe there is a way to skip the perf
> inject phase and have perf report/annotate directly
> inject the MMAP records on the fly during processing of
> the perf.data file. Perf report would also generate the
> ELF files if necessary. Such optimization, would make
> using this extension seamless in system-wide mode and
> larger environments. This will be added in a later update
> as well.

I think angling for seemless operation is really important.

> To use the new feature:
> - compile and install the perf_posix_clock.ko module:
> - make modules (say M to PERF_CLOCK config option)
> - make modules_install;
> - modprobe perf_posix_clock
> - dmesg should say: perf_clock clock registered
> - compile perf
> - cd tools/perf/jvmti; make; install wherever is appropriate

Will 'make -C tools/perf install' DTRT, or is the last step
needed separately?

Thanks,

Ingo