This is an archive of the discontinued LLVM Phabricator instance.

[llvm-porfgen] Allow perf data as input
ClosedPublic

Authored by wenlei on Sep 29 2021, 5:12 PM.

Details

Summary

This change enables llvm-profgen to take raw perf data as alternative input format. Sometimes we need to retrieve evenets for processes with matching binary. Using perf data as input allows us to retrieve process Ids from mmap events for matching binary, then filter by process id during perf script generation.

Diff Detail

Event Timeline

wenlei created this revision.Sep 29 2021, 5:12 PM
wenlei requested review of this revision.Sep 29 2021, 5:12 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 29 2021, 5:12 PM
wlei added inline comments.Sep 29 2021, 5:45 PM
llvm/tools/llvm-profgen/PerfReader.cpp
287

Nit : command

868

Before we use "TraceIt.getCurrentLine().startswith("PERF_RECORD_MMAP2"))" for the check, why here changed to find? it seems like our regex match only supports for leading "PERF_RECORD_MMAP2"

wenlei added inline comments.Sep 29 2021, 5:49 PM
llvm/tools/llvm-profgen/PerfReader.cpp
287

fixed, thanks.

868

This is because if we want to get mmap events only, we need to use perf script --show-mmap-events -F comm,pid -i .... However with that, the mmap shows up in the following format. I have a comment above.

systemd 0 [000] 0.000000: PERF_RECORD_MMAP2 1/1: [0x7ff989ee1000(0x7d000) @ 0 00:1c 4615 6072345749617000736]: r-xp /usr/lib64/libgcrypt.so.11.8.2

The regex handles this today as it's not pinned to the beginning of the line (no ^).

wlei accepted this revision.Sep 29 2021, 5:53 PM

LGTM, thanks!

llvm/tools/llvm-profgen/PerfReader.cpp
868

I see, thanks for the clarification.

This revision is now accepted and ready to land.Sep 29 2021, 5:53 PM
This revision was landed with ongoing or failed builds.Sep 29 2021, 11:00 PM
This revision was automatically updated to reflect the committed changes.