[PATCH] D43896: [XRay] cache symbolized function names for a repeatedly queried function ID
Martin Pelikán via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 28 13:02:00 PST 2018
pelikan created this revision.
pelikan added a reviewer: dberris.
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.
Repository:
rL LLVM
https://reviews.llvm.org/D43896
Files:
tools/llvm-xray/func-id-helper.cc
tools/llvm-xray/func-id-helper.h
Index: tools/llvm-xray/func-id-helper.h
===================================================================
--- tools/llvm-xray/func-id-helper.h
+++ tools/llvm-xray/func-id-helper.h
@@ -28,6 +28,7 @@
std::string BinaryInstrMap;
symbolize::LLVMSymbolizer &Symbolizer;
const FunctionAddressMap &FunctionAddresses;
+ mutable std::unordered_map<int32_t, std::string> CachedNames;
public:
FuncIdConversionHelper(std::string BinaryInstrMap,
Index: tools/llvm-xray/func-id-helper.cc
===================================================================
--- tools/llvm-xray/func-id-helper.cc
+++ tools/llvm-xray/func-id-helper.cc
@@ -19,6 +19,10 @@
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 @@
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 {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D43896.136370.patch
Type: text/x-patch
Size: 1223 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180228/743263f2/attachment.bin>
More information about the llvm-commits
mailing list