Enabling PerfJITEventListener in the XLA runtime

52 views
Skip to first unread message

Muneeb Anwar

unread,
Sep 6, 2024, 12:03:35 PMSep 6
to openxla...@openxla.org
Hi,
I am trying to use perf tools (record/report) to profile JITed functions, when using OrcJIT in the XLA runtime. Even though there's this option to register `PerfJITEventListener` by setting `enable_perf_listener`, the call to `llvm::JITEventListener::createPerfJITEventListener()` returns NULL showing that it failed.

Moreover, the online documentation for OrcJIT in the llvm-project says that `JITEventListeners` feature isn't supported. This confuses me as to why there is an option for this if it's not supported in llvm.

How is OrcJIT supposed to make use of `PerfJITEventListener`? And how can it be enabled in the XLA runtime (if possible at all)? 

If not, is there another way to profile JITed code?

best,
Muneeb

Eugene Zhulenev

unread,
Sep 6, 2024, 12:29:32 PMSep 6
to Muneeb Anwar, Peter Hawkins, openxla...@openxla.org
Hi Muneeb,

It should work:

1. perf record -k 1 -g -o /tmp/perf.data -- $run_openxla_command (i.e. it can be jax)
2. perf inject -j -i /tmp/perf.data -o /tmp/perf.data.jit
3. perf report -g -i /tmp/perf.data

It requires defining LLVM_USE_PERF (we define it in lvm/include/llvm/Config/llvm-config.h), I'm not super familiar with OSS build set up, but I guess you can always pass if via bazel --copt flag.

Also I suspect we might be building jaxlib without this flag (+Peter to confirm or deny).

Eugene


--
You received this message because you are subscribed to the Google Groups "OpenXLA Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openxla-discu...@openxla.org.
To view this discussion on the web visit https://groups.google.com/a/openxla.org/d/msgid/openxla-discuss/CAHjT0%2B6XW7_fYYpEY6zh1juxT9kYLkHLQAx1m2m-tzE%2BdmAg-A%40mail.gmail.com.
For more options, visit https://groups.google.com/a/openxla.org/d/optout.

Peter Hawkins

unread,
Sep 6, 2024, 3:55:00 PMSep 6
to Eugene Zhulenev, Muneeb Anwar, openxla...@openxla.org
Hmm.. indeed we're not building jaxlib with that flag.

Is there a cost to doing so, or should we enable it unconditionally?

Peter

Eugene Zhulenev

unread,
Sep 6, 2024, 5:27:45 PMSep 6
to Peter Hawkins, Muneeb Anwar, openxla...@openxla.org
On Fri, Sep 6, 2024 at 12:54 PM Peter Hawkins <phaw...@google.com> wrote:
Hmm.. indeed we're not building jaxlib with that flag.

Is there a cost to doing so, or should we enable it unconditionally?

~free, it dumps extra metadata for perf to /tmp, and sometimes logs warnings if /tmp is not writable. It's super useful for debugging, I vote for enabling it by default for jaxlib.

Eugene 
Reply all
Reply to author
Forward
0 new messages