[PATCH] D107800: [CSSPGO][llvm-profgen] Cut off probe stack from the bottom to reduce memory usage
Lei Wang via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 9 21:18:36 PDT 2021
wlei created this revision.
Herald added subscribers: hoy, wenlei, lxfind.
wlei requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D107800
Files:
llvm/tools/llvm-profgen/PerfReader.cpp
Index: llvm/tools/llvm-profgen/PerfReader.cpp
===================================================================
--- llvm/tools/llvm-profgen/PerfReader.cpp
+++ llvm/tools/llvm-profgen/PerfReader.cpp
@@ -18,6 +18,11 @@
cl::ZeroOrMore,
cl::desc("Print unwinder output"));
+static cl::opt<int> CSProfProbeStackDepth(
+ "csprof-probe-stack-depth", cl::init(-1), cl::ZeroOrMore,
+ cl::desc("Cut off probe stack from the bottom and keep it up to a given "
+ "depth. No cut is made if the input is -1."));
+
extern cl::opt<bool> ShowDisassemblyOnly;
extern cl::opt<bool> ShowSourceLocations;
@@ -104,11 +109,18 @@
std::shared_ptr<ProbeBasedCtxKey> ProbeStack::getContextKey() {
std::shared_ptr<ProbeBasedCtxKey> ProbeBasedKey =
std::make_shared<ProbeBasedCtxKey>();
+ auto &P = ProbeBasedKey->Probes;
for (auto CallProbe : Stack) {
- ProbeBasedKey->Probes.emplace_back(CallProbe);
+ P.emplace_back(CallProbe);
+ }
+ CSProfileGenerator::compressRecursionContext<const MCDecodedPseudoProbe *>(P);
+ if (CSProfProbeStackDepth >= 0 &&
+ static_cast<size_t>(CSProfProbeStackDepth) < P.size()) {
+ std::copy(P.begin() + P.size() - static_cast<size_t>(CSProfProbeStackDepth),
+ P.end(), P.begin());
+ P.resize(CSProfProbeStackDepth);
}
- CSProfileGenerator::compressRecursionContext<const MCDecodedPseudoProbe *>(
- ProbeBasedKey->Probes);
+
ProbeBasedKey->genHashCode();
return ProbeBasedKey;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D107800.365348.patch
Type: text/x-patch
Size: 1553 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210810/85f33a88/attachment.bin>
More information about the llvm-commits
mailing list