[Lldb-commits] [lldb] [lldb] Move DemangledNameInfo cache out of Mangled class (PR #225332)
via lldb-commits
lldb-commits at lists.llvm.org
Tue Sep 29 01:05:36 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-lldb
Author: Raphael Isemann (Teemperor)
<details>
<summary>Changes</summary>
This patch moves the per-Mangled DemangledInfoCache into a global
cache with a size limit. The motivation for this is:
1. It makes `Mangled` a smaller which saves memory as its a frequently
heap-allocated object.
2. The current Mangled class is sometimes accessed via the SB API from
multiple threads, and the stateful cache in Symbol causes crashes due
to the inherent race conditions of this approach.
3. It avoids potentially large memory usage in case many symbols have
their DemangledNameInfo computed and cached.
The size of the global cache can be changed via the new
'symbols.demangled-name-info-cache-size' setting. Setting this to 0
disables the cache.
For the caching strategy, the current implementation drops a random
entry whenever the cache is full. Note that we can't use an LRU/LFU
cache as this won't allow us to use a read-write lock (as we would
need to update the use counter on a read).
Also, this patch doesn't make Symbol or Mangled fully thread-safe. It
just avoid the racy allocations.
---
Full diff: https://github.com/llvm/llvm-project/pull/225332.diff
12 Files Affected:
- (modified) lldb/include/lldb/Core/DemangledNameInfo.h (+52)
- (modified) lldb/include/lldb/Core/Mangled.h (+13-45)
- (modified) lldb/include/lldb/Core/ModuleList.h (+1)
- (modified) lldb/include/lldb/Symbol/Symbol.h (+1-1)
- (modified) lldb/source/Core/CoreProperties.td (+4)
- (modified) lldb/source/Core/DemangledNameInfo.cpp (+76)
- (modified) lldb/source/Core/Mangled.cpp (+20-28)
- (modified) lldb/source/Core/ModuleList.cpp (+6)
- (modified) lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp (+10-1)
- (modified) lldb/source/Symbol/Symbol.cpp (+1-1)
- (modified) lldb/source/Symbol/Symtab.cpp (+1-1)
- (modified) lldb/unittests/Core/MangledTest.cpp (+129-28)
``````````diff
The server is unavailable at this time. Please wait a few minutes before you try again.
``````````
</details>
https://github.com/llvm/llvm-project/pull/225332
More information about the lldb-commits
mailing list