Skip to content

Commit

Permalink
[llvm-profgen] Ignore stack samples before aggregation
Browse files Browse the repository at this point in the history
With `ignore-stack-samples`, We can ignore the call stack before the samples aggregation which could reduce some redundant computations.

Reviewed By: hoy, wenlei

Differential Revision: https://reviews.llvm.org/D111577
  • Loading branch information
wlei-llvm committed Oct 13, 2021
1 parent 4fcc0ac commit ab5d65e
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions llvm/tools/llvm-profgen/PerfReader.cpp
Expand Up @@ -647,9 +647,13 @@ void HybridPerfReader::parseSample(TraceStream &TraceIt, uint64_t Count) {
if (!TraceIt.isAtEoF() && TraceIt.getCurrentLine().startswith(" 0x")) {
// Parsing LBR stack and populate into PerfSample.LBRStack
if (extractLBRStack(TraceIt, Sample->LBRStack)) {
// Canonicalize stack leaf to avoid 'random' IP from leaf frame skew LBR
// ranges
Sample->CallStack.front() = Sample->LBRStack[0].Target;
if (IgnoreStackSamples) {
Sample->CallStack.clear();
} else {
// Canonicalize stack leaf to avoid 'random' IP from leaf frame skew LBR
// ranges
Sample->CallStack.front() = Sample->LBRStack[0].Target;
}
// Record samples by aggregation
AggregatedSamples[Hashable<PerfSample>(Sample)] += Count;
}
Expand Down

0 comments on commit ab5d65e

Please sign in to comment.