[PATCH] D120860: [memprof] Filter out callstack frames which cannot be symbolized.

Teresa Johnson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 3 16:51:38 PST 2022


tejohnson added inline comments.


================
Comment at: llvm/lib/ProfileData/RawMemProfReader.cpp:336
+    auto &CallStack = Entry.getSecond();
+    CallStack.erase(std::remove_if(CallStack.begin(), CallStack.end(),
+                                   [&AllVAddrsToDiscard](const uint64_t A) {
----------------
snehasish wrote:
> tejohnson wrote:
> > Rather than scan CallStack again, can you keep a flag initialized to false above the prior loop, set to true if any entries are symbolized, and check that here?
> In practice all callstacks have at least one item to discard which originates from a shared library, i.e. the call to main from glibc at `__libc_start_main in libc-start.c` so adding a flag here doesn't help. 
> 
> An alternative way to filter would be to use the procmaps to identify all addresses within the main binary and only retain those while reading the raw profile, however we don't record build ids on linux during profiling today (sanitizer_procmaps_linux does not support it). We could use a heuristic to identify the main binary but matching it to the profiled binary (passed in during `llvm-profdata merge`) build id would be best. 
Nevermind, I mistakenly thought this was removing all of them, but it may only be removing some frames.


================
Comment at: llvm/test/tools/llvm-profdata/memprof-basic.test:45
 CHECK-NEXT:     NumSegments: 9
 CHECK-NEXT:     NumMibInfo: 3
 CHECK-NEXT:     NumStackOffsets: 3
----------------
snehasish wrote:
> tejohnson wrote:
> > Should this now be 2? Ditto for NumStackOffsets below.
> This is coming from the raw profile without symbolization and pruning. If you don't feel strongly, I'll update the summary code in a separate patch. I've added a TODO in RawMemProfReader.cpp for now.
That's fine, but I'm confused as to how the output of this file changed then, since it looks like printYAML prints the records immediately after the summary, but now there are only 2 MIB records printed? Is it the case that the records have been filtered by that point but the summary hasn't been updated accordingly?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D120860/new/

https://reviews.llvm.org/D120860



More information about the llvm-commits mailing list