summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-xray/func-id-helper.cc
diff options
context:
space:
mode:
authorMartin Pelikan <martin.pelikan@gmail.com>2018-03-01 01:59:24 +0000
committerMartin Pelikan <martin.pelikan@gmail.com>2018-03-01 01:59:24 +0000
commit86ed8e58306dbb6f7a52508f2641f12877e2e01b (patch)
tree868153858783ca60d7a07ee68f65d6d1bca53e2d /llvm/tools/llvm-xray/func-id-helper.cc
parent811343cfd8bb8dfbd4756bed3f3ecda2cf407fad (diff)
downloadbcm5719-llvm-86ed8e58306dbb6f7a52508f2641f12877e2e01b.tar.gz
bcm5719-llvm-86ed8e58306dbb6f7a52508f2641f12877e2e01b.zip
[XRay] cache symbolized function names for a repeatedly queried function ID
Summary: Processing 2 GB XRay traces with "llvm-xray convert -symbolize" needs to go over each trace record and symbolize the function name refered to by its ID. Currently this happens by asking the LLVM symbolizer code every single time. A simple cache can save around 30 minutes of processing of that trace. llvm-xray's resident memory usage increased negligibly with this cache. Reviewers: dberris Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D43896 llvm-svn: 326407
Diffstat (limited to 'llvm/tools/llvm-xray/func-id-helper.cc')
-rw-r--r--llvm/tools/llvm-xray/func-id-helper.cc8
1 files changed, 7 insertions, 1 deletions
diff --git a/llvm/tools/llvm-xray/func-id-helper.cc b/llvm/tools/llvm-xray/func-id-helper.cc
index 3234010695b..9bf55b23bdd 100644
--- a/llvm/tools/llvm-xray/func-id-helper.cc
+++ b/llvm/tools/llvm-xray/func-id-helper.cc
@@ -19,6 +19,10 @@ using namespace llvm;
using namespace xray;
std::string FuncIdConversionHelper::SymbolOrNumber(int32_t FuncId) const {
+ auto CacheIt = CachedNames.find(FuncId);
+ if (CacheIt != CachedNames.end())
+ return CacheIt->second;
+
std::ostringstream F;
auto It = FunctionAddresses.find(FuncId);
if (It == FunctionAddresses.end()) {
@@ -37,7 +41,9 @@ std::string FuncIdConversionHelper::SymbolOrNumber(int32_t FuncId) const {
F << "@(" << std::hex << It->second << ")";
});
- return F.str();
+ auto S = F.str();
+ CachedNames[FuncId] = S;
+ return S;
}
std::string FuncIdConversionHelper::FileLineAndColumn(int32_t FuncId) const {
OpenPOWER on IntegriCloud