[Lldb-commits] [lldb] Improve debug names index fetching global variables performance (PR #70231)
via lldb-commits
lldb-commits at lists.llvm.org
Wed Oct 25 10:26:48 PDT 2023
https://github.com/jeffreytan81 created https://github.com/llvm/llvm-project/pull/70231
While using dwarf5 `.debug_names` in internal large targets, we noticed a performance issue (around 10 seconds delay) while `lldb-vscode` tries to show `scopes` for a compile unit. Profiling shows the bottleneck is inside `DebugNamesDWARFIndex::GetGlobalVariables` which linearly search all index entries belongs to a compile unit.
This patch improves the performance by using the compile units list to filter first before checking index entries. This significantly improves the performance (drops from 10 seconds => under 1 second) in the split dwarf situation because each compile unit has its own named index.
>From c8d9a1f7387e3e4944d92ccb33699b6a9d0dcf89 Mon Sep 17 00:00:00 2001
From: jeffreytan81 <jeffreytan at fb.com>
Date: Wed, 25 Oct 2023 10:21:06 -0700
Subject: [PATCH] Improve debug names index fetching global variables
performance
---
.../Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
index 292ea2806c59dc7..f94491b29bdbe14 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
@@ -130,6 +130,17 @@ void DebugNamesDWARFIndex::GetGlobalVariables(
uint64_t cu_offset = cu.GetOffset();
bool found_entry_for_cu = false;
for (const DebugNames::NameIndex &ni: *m_debug_names_up) {
+ // Check if this name index contains an entry for the given CU.
+ bool has_match_cu = false;
+ for (uint32_t i = 0;i < ni.getCUCount();++i) {
+ if (ni.getCUOffset(i) == cu_offset) {
+ has_match_cu = true;
+ break;
+ }
+ }
+ if (!has_match_cu)
+ continue;
+
for (DebugNames::NameTableEntry nte: ni) {
uint64_t entry_offset = nte.getEntryOffset();
llvm::Expected<DebugNames::Entry> entry_or = ni.getEntry(&entry_offset);
More information about the lldb-commits
mailing list