OSDN Git Service

[CSSPGO][llvm-profgen] Aggregate samples on call frame trie to speed up profile gener...
authorwlei <wlei@fb.com>
Mon, 11 Jan 2021 20:47:22 +0000 (12:47 -0800)
committerTom Stellard <tstellar@redhat.com>
Sat, 20 Feb 2021 05:21:11 +0000 (21:21 -0800)
commite562ff08f634d814c1cd1e65e3428ca5308d3022
tree03bccc898dd83f2b56f00e0f742ebb964cdc780f
parent6209b0756d5df805f6279d3dadc8d2ba8648c3eb
[CSSPGO][llvm-profgen] Aggregate samples on call frame trie to speed up profile generation

For CS profile generation, the process of call stack unwinding is time-consuming since for each LBR entry we need linear time to generate the context( hash, compression, string concatenation). This change speeds up this by grouping all the call frame within one LBR sample into a trie and aggregating the result(sample counter) on it, deferring the context compression and string generation to the end of unwinding.

Specifically, it uses `StackLeaf` as the top frame on the stack and manipulates(pop or push a trie node) it dynamically during virtual unwinding so that the raw sample can just be recoded on the leaf node, the path(root to leaf) will represent its calling context. In the end, it traverses the trie and generates the context on the fly.

Results:
Our internal branch shows about 5X speed-up on some large workloads in SPEC06 benchmark.

Differential Revision: https://reviews.llvm.org/D94110
llvm/tools/llvm-profgen/PerfReader.cpp
llvm/tools/llvm-profgen/PerfReader.h
llvm/tools/llvm-profgen/ProfiledBinary.cpp
llvm/tools/llvm-profgen/ProfiledBinary.h