[all-commits] [llvm/llvm-project] 050c09: [lldb][NFCI] Replace use of DWARFAttribute in DWAR...
Alex via All-commits
all-commits at lists.llvm.org
Fri May 12 13:13:32 PDT 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 050c09f0bed67f3135cb2ad99d4d35e241e5d61b
https://github.com/llvm/llvm-project/commit/050c09f0bed67f3135cb2ad99d4d35e241e5d61b
Author: Alex Langford <alangford at apple.com>
Date: 2023-05-12 (Fri, 12 May 2023)
Changed paths:
M lldb/source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.cpp
M lldb/source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.h
M lldb/source/Plugins/SymbolFile/DWARF/DWARFAttribute.h
Log Message:
-----------
[lldb][NFCI] Replace use of DWARFAttribute in DWARFAbbreviationDecl
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.
Differential Revision: https://reviews.llvm.org/D150418
More information about the All-commits
mailing list