Skip to content

Commit 85bee8e

Browse files
author
George Hu
committed
Add locate time for each module in statistics
1 parent 464286b commit 85bee8e

File tree

8 files changed

+56
-7
lines changed

8 files changed

+56
-7
lines changed

lldb/include/lldb/Symbol/ObjectFile.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "lldb/Core/PluginInterface.h"
1414
#include "lldb/Symbol/Symtab.h"
1515
#include "lldb/Symbol/UnwindTable.h"
16+
#include "lldb/Target/Statistics.h"
1617
#include "lldb/Utility/AddressableBits.h"
1718
#include "lldb/Utility/DataExtractor.h"
1819
#include "lldb/Utility/Endian.h"
@@ -589,6 +590,8 @@ class ObjectFile : public std::enable_shared_from_this<ObjectFile>,
589590
/// this routine to set eTypeDebugInfo when loading debug link files.
590591
virtual void SetType(Type type) { m_type = type; }
591592

593+
virtual StatsDuration &GetLocateTime() { return m_locate_time; }
594+
592595
/// The object file should be able to calculate the strata of the object
593596
/// file.
594597
///
@@ -752,6 +755,7 @@ class ObjectFile : public std::enable_shared_from_this<ObjectFile>,
752755

753756
protected:
754757
// Member variables.
758+
StatsDuration m_locate_time; ///< Time to locate the object file
755759
FileSpec m_file;
756760
Type m_type;
757761
Strata m_strata;

lldb/include/lldb/Symbol/SymbolFile.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,11 @@ class SymbolFile : public PluginInterface {
422422
/// hasn't been indexed yet, or a valid duration if it has.
423423
virtual StatsDuration::Duration GetDebugInfoIndexTime() { return {}; }
424424

425+
/// Return the time it took to locate any extra symbol files.
426+
///
427+
/// \returns 0.0 if no extra symbol files need to be located
428+
virtual StatsDuration::Duration GetSymbolLocateTime() { return {}; }
429+
425430
/// Reset the statistics for the symbol file.
426431
virtual void ResetStatistics() {}
427432

lldb/include/lldb/Target/Statistics.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ struct ModuleStats {
122122
double symtab_index_time = 0.0;
123123
double debug_parse_time = 0.0;
124124
double debug_index_time = 0.0;
125+
double symbol_locate_time = 0.0;
125126
uint64_t debug_info_size = 0;
126127
bool symtab_loaded_from_cache = false;
127128
bool symtab_saved_to_cache = false;

lldb/source/Core/ModuleList.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -917,9 +917,13 @@ ModuleList::GetSharedModule(const ModuleSpec &module_spec, ModuleSP &module_sp,
917917

918918
// Fixup the incoming path in case the path points to a valid file, yet the
919919
// arch or UUID (if one was passed in) don't match.
920-
ModuleSpec located_binary_modulespec =
921-
PluginManager::LocateExecutableObjectFile(module_spec);
922-
920+
ModuleSpec located_binary_modulespec;
921+
StatsDuration locate_duration;
922+
{
923+
ElapsedTime elapsed(locate_duration);
924+
located_binary_modulespec =
925+
PluginManager::LocateExecutableObjectFile(module_spec);
926+
}
923927
// Don't look for the file if it appears to be the same one we already
924928
// checked for above...
925929
if (located_binary_modulespec.GetFileSpec() != module_file_spec) {
@@ -992,6 +996,7 @@ ModuleList::GetSharedModule(const ModuleSpec &module_spec, ModuleSP &module_sp,
992996
// By getting the object file we can guarantee that the architecture
993997
// matches
994998
if (module_sp && module_sp->GetObjectFile()) {
999+
module_sp->GetObjectFile()->GetLocateTime() += locate_duration;
9951000
if (module_sp->GetObjectFile()->GetType() ==
9961001
ObjectFile::eTypeStubLibrary) {
9971002
module_sp.reset();

lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4250,11 +4250,13 @@ const std::shared_ptr<SymbolFileDWARFDwo> &SymbolFileDWARF::GetDwpSymbolFile() {
42504250
ModuleSpec module_spec;
42514251
module_spec.GetFileSpec() = m_objfile_sp->GetFileSpec();
42524252
FileSpec dwp_filespec;
4253+
StatsDuration duration;
42534254
for (const auto &symfile : symfiles.files()) {
42544255
module_spec.GetSymbolFileSpec() =
42554256
FileSpec(symfile.GetPath() + ".dwp", symfile.GetPathStyle());
42564257
LLDB_LOG(log, "Searching for DWP using: \"{0}\"",
42574258
module_spec.GetSymbolFileSpec());
4259+
ElapsedTime elapsed(duration);
42584260
dwp_filespec =
42594261
PluginManager::LocateExecutableSymbolFile(module_spec, search_paths);
42604262
if (FileSystem::Instance().Exists(dwp_filespec)) {
@@ -4267,6 +4269,8 @@ const std::shared_ptr<SymbolFileDWARFDwo> &SymbolFileDWARF::GetDwpSymbolFile() {
42674269
// find the correct DWP file, as the Debuginfod plugin uses *only* this
42684270
// data to correctly match the DWP file with the binary.
42694271
module_spec.GetUUID() = m_objfile_sp->GetUUID();
4272+
duration.reset();
4273+
ElapsedTime elapsed(duration);
42704274
dwp_filespec =
42714275
PluginManager::LocateExecutableSymbolFile(module_spec, search_paths);
42724276
}
@@ -4279,6 +4283,7 @@ const std::shared_ptr<SymbolFileDWARFDwo> &SymbolFileDWARF::GetDwpSymbolFile() {
42794283
FileSystem::Instance().GetByteSize(dwp_filespec), dwp_file_data_sp,
42804284
dwp_file_data_offset);
42814285
if (dwp_obj_file) {
4286+
dwp_obj_file->GetLocateTime() += duration;
42824287
m_dwp_symfile = std::make_shared<SymbolFileDWARFDwo>(
42834288
*this, dwp_obj_file, DIERef::k_file_index_mask);
42844289
}
@@ -4349,6 +4354,14 @@ LanguageType SymbolFileDWARF::GetLanguageFamily(DWARFUnit &unit) {
43494354
return LanguageTypeFromDWARF(lang);
43504355
}
43514356

4357+
StatsDuration::Duration SymbolFileDWARF::GetSymbolLocateTime() {
4358+
StatsDuration total_time;
4359+
total_time += GetObjectFile()->GetLocateTime();
4360+
if (m_dwp_symfile)
4361+
total_time += m_dwp_symfile->GetObjectFile()->GetLocateTime();
4362+
return total_time;
4363+
}
4364+
43524365
StatsDuration::Duration SymbolFileDWARF::GetDebugInfoIndexTime() {
43534366
if (m_index)
43544367
return m_index->GetIndexTime();

lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,9 @@ class SymbolFileDWARF : public SymbolFileCommon {
309309
StatsDuration::Duration GetDebugInfoParseTime() override {
310310
return m_parse_time;
311311
}
312+
313+
StatsDuration::Duration GetSymbolLocateTime() override;
314+
312315
StatsDuration::Duration GetDebugInfoIndexTime() override;
313316

314317
StatsDuration &GetDebugInfoParseTimeRef() { return m_parse_time; }

lldb/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,14 +103,23 @@ SymbolVendorELF::CreateInstance(const lldb::ModuleSP &module_sp,
103103
module_spec.GetSymbolFileSpec() = fspec;
104104
module_spec.GetUUID() = uuid;
105105
FileSpecList search_paths = Target::GetDefaultDebugFileSearchPaths();
106-
FileSpec dsym_fspec =
107-
PluginManager::LocateExecutableSymbolFile(module_spec, search_paths);
106+
StatsDuration duration;
107+
FileSpec dsym_fspec;
108+
{
109+
ElapsedTime elapsed(duration);
110+
dsym_fspec =
111+
PluginManager::LocateExecutableSymbolFile(module_spec, search_paths);
112+
}
108113
if (!dsym_fspec || IsDwpSymbolFile(module_sp, dsym_fspec)) {
109114
// If we have a stripped binary or if we have a DWP file, SymbolLocator
110115
// plugins may be able to give us an unstripped binary or an
111116
// 'only-keep-debug' stripped file.
112-
ModuleSpec unstripped_spec =
113-
PluginManager::LocateExecutableObjectFile(module_spec);
117+
ModuleSpec unstripped_spec;
118+
duration.reset();
119+
{
120+
ElapsedTime elapsed(duration);
121+
unstripped_spec = PluginManager::LocateExecutableObjectFile(module_spec);
122+
}
114123
if (!unstripped_spec)
115124
return nullptr;
116125
// The default SymbolLocator plugin returns the original binary if no other
@@ -128,6 +137,7 @@ SymbolVendorELF::CreateInstance(const lldb::ModuleSP &module_sp,
128137
if (!dsym_objfile_sp)
129138
return nullptr;
130139

140+
dsym_objfile_sp->GetLocateTime() += duration;
131141
// This objfile is for debugging purposes. Sadly, ObjectFileELF won't
132142
// be able to figure this out consistently as the symbol file may not
133143
// have stripped the code sections, etc.

lldb/source/Target/Statistics.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ json::Value ModuleStats::ToJSON() const {
7171
module.try_emplace("debugInfoHadIncompleteTypes",
7272
debug_info_had_incomplete_types);
7373
module.try_emplace("symbolTableStripped", symtab_stripped);
74+
module.try_emplace("symbolLocateTime", symbol_locate_time);
7475
if (!symfile_path.empty())
7576
module.try_emplace("symbolFilePath", symfile_path);
7677

@@ -288,6 +289,7 @@ llvm::json::Value DebuggerStats::ReportStatistics(
288289

289290
json::Array json_targets;
290291
json::Array json_modules;
292+
double symbol_locate_time = 0.0;
291293
double symtab_parse_time = 0.0;
292294
double symtab_index_time = 0.0;
293295
double debug_parse_time = 0.0;
@@ -345,6 +347,10 @@ llvm::json::Value DebuggerStats::ReportStatistics(
345347
++debug_index_saved;
346348
module_stat.debug_index_time = sym_file->GetDebugInfoIndexTime().count();
347349
module_stat.debug_parse_time = sym_file->GetDebugInfoParseTime().count();
350+
module_stat.symbol_locate_time += sym_file->GetSymbolLocateTime().count();
351+
if (sym_file->GetObjectFile() != module->GetObjectFile())
352+
module_stat.symbol_locate_time +=
353+
module->GetObjectFile()->GetLocateTime().get().count();
348354
module_stat.debug_info_size =
349355
sym_file->GetDebugInfoSize(load_all_debug_info);
350356
module_stat.symtab_stripped = module->GetObjectFile()->IsStripped();
@@ -361,6 +367,7 @@ llvm::json::Value DebuggerStats::ReportStatistics(
361367
if (module_stat.debug_info_had_variable_errors)
362368
++num_modules_with_variable_errors;
363369
}
370+
symbol_locate_time += module_stat.symbol_locate_time;
364371
symtab_parse_time += module_stat.symtab_parse_time;
365372
symtab_index_time += module_stat.symtab_index_time;
366373
debug_parse_time += module_stat.debug_parse_time;
@@ -391,6 +398,7 @@ llvm::json::Value DebuggerStats::ReportStatistics(
391398
}
392399

393400
json::Object global_stats{
401+
{"totalSymbolLocateTime", symbol_locate_time},
394402
{"totalSymbolTableParseTime", symtab_parse_time},
395403
{"totalSymbolTableIndexTime", symtab_index_time},
396404
{"totalSymbolTablesLoadedFromCache", symtabs_loaded},

0 commit comments

Comments
 (0)