llvm.org GIT mirror llvm / 26e6f68
[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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@326407 91177308-0d34-0410-b5e6-96231b3b80d8 Martin Pelikan 2 years ago
2 changed file(s) with 9 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
1818 using namespace xray;
1919
2020 std::string FuncIdConversionHelper::SymbolOrNumber(int32_t FuncId) const {
21 auto CacheIt = CachedNames.find(FuncId);
22 if (CacheIt != CachedNames.end())
23 return CacheIt->second;
24
2125 std::ostringstream F;
2226 auto It = FunctionAddresses.find(FuncId);
2327 if (It == FunctionAddresses.end()) {
3640 F << "@(" << std::hex << It->second << ")";
3741 });
3842
39 return F.str();
43 auto S = F.str();
44 CachedNames[FuncId] = S;
45 return S;
4046 }
4147
4248 std::string FuncIdConversionHelper::FileLineAndColumn(int32_t FuncId) const {
1212 #ifndef LLVM_TOOLS_LLVM_XRAY_FUNC_ID_HELPER_H
1313 #define LLVM_TOOLS_LLVM_XRAY_FUNC_ID_HELPER_H
1414
15 #include "llvm/ADT/DenseMap.h"
1516 #include "llvm/DebugInfo/Symbolize/Symbolize.h"
1617 #include
1718
2728 std::string BinaryInstrMap;
2829 symbolize::LLVMSymbolizer &Symbolizer;
2930 const FunctionAddressMap &FunctionAddresses;
31 mutable llvm::DenseMap CachedNames;
3032
3133 public:
3234 FuncIdConversionHelper(std::string BinaryInstrMap,