[Lldb-commits] [PATCH] D150418: [lldb][NFCI] Replace use of DWARFAttribute in DWARFAbbreviationDecl

Alex Langford via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Thu May 11 19:19:34 PDT 2023


bulbazord created this revision.
bulbazord added reviewers: JDevlieghere, aprantl, mib, jingham, labath, kastiglione, rastogishubham, fdeazeve, clayborg.
Herald added a project: All.
bulbazord requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

DWARFAttribute is used in 2 classes: DWARFAbbreviationDecl and
DWARFAttributes. The former stores a std::vector of them and the latter
has a small structure called AttributeValue that contains a
DWARFAttribute. DWARFAttributes maintains a llvm::SmallVector of
AttributeValues.

My end goal is to have `DWARFAttributes` have a llvm::SmallVector
specialized on DWARFAttribute. In order to do that, we'll have to move
the other elements of AttributeValue into DWARFAttribute itself. But we
don't want to do this while DWARFAbbreviationDecl is using
DWARFAttribute because it will needlessly increase the size of
DWARFAbbreviationDecl. So instead I will create a small type containing
only what DWARFAbbreviationDecl needs and call it `AttributeSpec`. This
is the exact same thing that LLVM does today.

I've elected to swap std::vector for llvm::SmallVector here with a pre-allocated
size of 8. I've collected time and memory measurements before this change and
after it as well. Using a c++ project with 10,000 object files and no dSYM, I
place a breakpoint by file + lineno and see how long it takes to resolve.

Before this patch:

  Time (mean ± σ):     13.577 s ±  0.024 s    [User: 12.418 s, System: 1.247 s]

Total number of bytes allocated: 1.38 GiB
Total number of allocations: 6.47 million allocations

After this patch:

  Time (mean ± σ):     13.287 s ±  0.020 s    [User: 12.128 s, System: 1.250 s]

Total number of bytes allocated: 1.59 GiB
Total number of allocations: 4.61 million allocations

So we consume more memory than before, but we actually make less allocations on
average.

I also measured with an llvm::SmallVector with a pre-allocated size of 4 instead
of 8 to measure how well it performs:

  Time (mean ± σ):     13.246 s ±  0.048 s    [User: 12.074 s, System: 1.268 s]

Total memory consumption: 1.50 GiB
Total number of allocations: 5.74 million

Of course this data may look very different depending on the actual program
being debugged, but each of the object files had 100+ AbbreviationDeclarations
each with between 0 and 10 Attributes, so I feel this was a fair example to
consider.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D150418

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFAttribute.h

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D150418.521535.patch
Type: text/x-patch
Size: 4341 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20230512/1e45301d/attachment.bin>


More information about the lldb-commits mailing list