[all-commits] [llvm/llvm-project] e9a194: [lldb] Don't construct the demangled strings while...

Jonas Devlieghere via All-commits all-commits at lists.llvm.org
Thu Feb 3 10:50:54 PST 2022


  Branch: refs/heads/D118814
  Home:   https://github.com/llvm/llvm-project
  Commit: e9a1946a1be197ada1bda4260e50aabeb07d4b26
      https://github.com/llvm/llvm-project/commit/e9a1946a1be197ada1bda4260e50aabeb07d4b26
  Author: Jonas Devlieghere <jonas at devlieghere.com>
  Date:   2022-02-03 (Thu, 03 Feb 2022)

  Changed paths:
    M lldb/source/Core/Mangled.cpp
    M lldb/source/Symbol/Symtab.cpp
    M lldb/test/API/macosx/dyld-trie-symbols/TestDyldTrieSymbols.py

  Log Message:
  -----------
  [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




More information about the All-commits mailing list