[lldb] Don't construct the demangled strings while indexing the symbol table
The symbol table needs to demangle all symbol names when building its index. However, this doesn't require the full mangled name: we only need the base name and the function declaration context. Currently, we always construct the demangled string during indexing and cache it in the string pool as a way to speed up future lookups. Constructing the demangled string is by far the most expensive step of the demangling process, because the output string can be exponentially larger than the input and unless you're dumping the symbol table, many of those demangled names will not be needed again. This patch avoids constructing the full demangled string when we can partially demangle. This speeds up indexing and reduces memory usage. I gathered some numbers by attaching to Slack: Before ------ Memory usage: 280MB Benchmark 1: ./bin/lldb -n Slack -o quit Time (mean ± σ): 4.829 s ± 0.518 s [User: 4.012 s, System: 0.208 s] Range (min … max): 4.624 s … 6.294 s 10 runs After ----- Memory usage: 189MB Benchmark 1: ./bin/lldb -n Slack -o quit Time (mean ± σ): 4.182 s ± 0.025 s [User: 3.536 s, System: 0.192 s] Range (min … max): 4.152 s … 4.233 s 10 runs Differential revision: https://reviews.llvm.org/D118814
Loading
Please sign in to comment