[Lldb-commits] [PATCH] D107407: [rfc] target stats

walter erquinigo via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Tue Aug 3 16:06:31 PDT 2021


wallace created this revision.
wallace added reviewers: clayborg, jingham.
Herald added subscribers: dang, arphaman, mgorny.
wallace requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

D45547 <https://reviews.llvm.org/D45547> added a while ago the skeleton for some target stats, along with
a command to enable, disable, and dump them. However, it seems it wasn't
further developed.

My team is in need of a bunch of other target stats so that we can fix some bottlenecks. Some of these stats are related to expressions (e.g. # of expr eval that trigger global lookups, time per expr eval), and some others are are related to modules (e.g. amount of debug info parsed, time spent indexing dwarf, etc.).

In order to collect this metrics, I'm proposing improving the existing
code and create a TargetStats class, that can keep track of them.

Some things to consider:

- I think it's useful to have colletion enabled by default. You might

encounter some perf issues and you might want to dump the stats right
away, instead of rerunning the debug session but this time with
collection enabled.

- The information that is very cheap to collect, should be collected on

the fly, e.g. # of failed frame vars.

- The information that is expensive to collect, should be collected at

retrieval time (e.g. when invoking ToJSON or Dump). That way the
collection can be enabled by default without paying any noticeable
penalty.

As an interesting case, I added a metric for the amount of time spent indexing dwarf per module, which is not as trivial as the other existing metrics because the Target is not available there. However, it was easy to implement and can be extended to all symbol files. This metric is collected at retrieval time. This doesn't account for cases in which a dynamic library is unloaded at runtime, but I'm just making the current changes just for demostration purposes.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D107407

Files:
  lldb/include/lldb/Symbol/SymbolFile.h
  lldb/include/lldb/Target/Target.h
  lldb/include/lldb/Target/TargetStats.h
  lldb/include/lldb/lldb-forward.h
  lldb/source/API/SBTarget.cpp
  lldb/source/Commands/CommandObjectExpression.cpp
  lldb/source/Commands/CommandObjectFrame.cpp
  lldb/source/Commands/CommandObjectStats.cpp
  lldb/source/Commands/Options.td
  lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.h
  lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
  lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
  lldb/source/Target/CMakeLists.txt
  lldb/source/Target/Target.cpp
  lldb/source/Target/TargetStats.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D107407.363900.patch
Type: text/x-patch
Size: 19843 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20210803/ed3ab092/attachment-0001.bin>


More information about the lldb-commits mailing list