summaryrefslogtreecommitdiff
path: root/libunwindstack/Symbols.h
diff options
context:
space:
mode:
authorDavid Srbecky <dsrbecky@google.com>2020-11-26 16:58:57 +0000
committerDavid Srbecky <dsrbecky@google.com>2021-03-23 13:43:21 +0000
commitfcdc5f2c4084890c2ca48d981f74c6ff7bac4889 (patch)
tree8db6b102dd15f3d88004d481e9b4d62bfd12b4f9 /libunwindstack/Symbols.h
parent9bb405dfe2187e892779798b16de0bc782615c68 (diff)
downloadunwinding-fcdc5f2c4084890c2ca48d981f74c6ff7bac4889.tar.gz
Add shared symbol name cache.
The symbol name related reads and memory operations take about half of the symbol name reading cost now. This CL adds ref-counted read-only shared string cache, which essentially eliminates all of the costs. BM_symbol_find_single_many_times is >10% faster on ARM. (which is 20% if we exclude the fixed ELF loading cost) Real-world profiles seem even more encouraging. The extra memory cost is negligible (by definition, a small fraction of the decompressed mini-debug-info: specifically, the subset of strtab for hit functions). Furthermore, this effectively dedups strings when consecutive unwinds hit similar set of functions. (perfetto might keep several unwind results live) Test: m libunwindstack_unit_test Change-Id: I5cf600bb972fdb9d0f3a57ed0997bead2efa38f4
Diffstat (limited to 'libunwindstack/Symbols.h')
-rw-r--r--libunwindstack/Symbols.h10
1 files changed, 6 insertions, 4 deletions
diff --git a/libunwindstack/Symbols.h b/libunwindstack/Symbols.h
index 97c03c2..1074ebf 100644
--- a/libunwindstack/Symbols.h
+++ b/libunwindstack/Symbols.h
@@ -23,6 +23,8 @@
#include <optional>
#include <string>
+#include <unwindstack/SharedString.h>
+
namespace unwindstack {
// Forward declaration.
@@ -30,9 +32,9 @@ class Memory;
class Symbols {
struct Info {
- uint64_t addr; // Symbol address.
+ uint32_t size; // Symbol size in bytes.
uint32_t index; // Index into *sorted* symbol table.
- uint32_t name; // Offset in .strtab, or 0 if the symbol is not a function.
+ SharedString name;
};
public:
@@ -41,7 +43,7 @@ class Symbols {
virtual ~Symbols() = default;
template <typename SymType>
- bool GetName(uint64_t addr, Memory* elf_memory, std::string* name, uint64_t* func_offset);
+ bool GetName(uint64_t addr, Memory* elf_memory, SharedString* name, uint64_t* func_offset);
template <typename SymType>
bool GetGlobal(Memory* elf_memory, const std::string& name, uint64_t* memory_address);
@@ -53,7 +55,7 @@ class Symbols {
private:
template <typename SymType, bool RemapIndices>
- const Info* BinarySearch(uint64_t addr, Memory* elf_memory);
+ Info* BinarySearch(uint64_t addr, Memory* elf_memory, uint64_t* func_offset);
template <typename SymType>
void BuildRemapTable(Memory* elf_memory);