Skip to content

Commit b4992fb

Browse files
author
George Hu
committed
Add download time for each module in statistics
1 parent 464286b commit b4992fb

File tree

8 files changed

+58
-11
lines changed

8 files changed

+58
-11
lines changed

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 download any extra symbol files.
426+
///
427+
/// \returns 0.0 if no extra symbol files need to be downloaded
428+
virtual double GetSymbolDownloadTime() { return 0.0; }
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_download_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/include/lldb/Utility/FileSpec.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ class FileSpec {
7575
/// \see FileSpec::SetFile (const char *path)
7676
explicit FileSpec(llvm::StringRef path, Style style = Style::native);
7777

78+
explicit FileSpec(llvm::StringRef path, const double download_time,
79+
Style style = Style::native);
80+
7881
explicit FileSpec(llvm::StringRef path, const llvm::Triple &triple);
7982

8083
bool DirectoryEquals(const FileSpec &other) const;
@@ -416,6 +419,9 @@ class FileSpec {
416419
/// The lifetime of the StringRefs is tied to the lifetime of the FileSpec.
417420
std::vector<llvm::StringRef> GetComponents() const;
418421

422+
/// Get the download time of the file.
423+
double GetDownloadTime() { return m_download_time; }
424+
419425
protected:
420426
// Convenience method for setting the file without changing the style.
421427
void SetFile(llvm::StringRef path);
@@ -430,6 +436,8 @@ class FileSpec {
430436
No
431437
};
432438

439+
/// The download time of the file.
440+
double m_download_time = 0.0;
433441
/// The unique'd directory path.
434442
ConstString m_directory;
435443

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4349,6 +4349,13 @@ LanguageType SymbolFileDWARF::GetLanguageFamily(DWARFUnit &unit) {
43494349
return LanguageTypeFromDWARF(lang);
43504350
}
43514351

4352+
double SymbolFileDWARF::GetSymbolDownloadTime() {
4353+
double time = GetObjectFile()->GetFileSpec().GetDownloadTime();
4354+
if (m_dwp_symfile)
4355+
time += m_dwp_symfile->GetObjectFile()->GetFileSpec().GetDownloadTime();
4356+
return time;
4357+
}
4358+
43524359
StatsDuration::Duration SymbolFileDWARF::GetDebugInfoIndexTime() {
43534360
if (m_index)
43544361
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+
double GetSymbolDownloadTime() override;
314+
312315
StatsDuration::Duration GetDebugInfoIndexTime() override;
313316

314317
StatsDuration &GetDebugInfoParseTimeRef() { return m_parse_time; }

lldb/source/Plugins/SymbolLocator/Debuginfod/SymbolLocatorDebuginfod.cpp

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -188,17 +188,26 @@ GetFileForModule(const ModuleSpec &module_spec,
188188
std::string cache_file_name = llvm::toHex(build_id, true);
189189
if (!file_name.empty())
190190
cache_file_name += "-" + file_name.str();
191-
llvm::Expected<std::string> result = llvm::getCachedOrDownloadArtifact(
192-
cache_file_name, url_path, cache_path, debuginfod_urls, timeout);
193-
if (result)
194-
return FileSpec(*result);
195-
196-
Log *log = GetLog(LLDBLog::Symbols);
197-
auto err_message = llvm::toString(result.takeError());
198-
LLDB_LOGV(log,
199-
"Debuginfod failed to download symbol artifact {0} with error {1}",
200-
url_path, err_message);
201-
return {};
191+
StatsDuration duration;
192+
std::string local_path;
193+
{
194+
ElapsedTime elapsed(duration);
195+
llvm::Expected<std::string> result = llvm::getCachedOrDownloadArtifact(
196+
cache_file_name, url_path, cache_path, debuginfod_urls, timeout);
197+
198+
if (!result) {
199+
Log *log = GetLog(LLDBLog::Symbols);
200+
auto err_message = llvm::toString(result.takeError());
201+
LLDB_LOGV(
202+
log,
203+
"Debuginfod failed to download symbol artifact {0} with error {1}",
204+
url_path, err_message);
205+
return {};
206+
}
207+
local_path = *result;
208+
}
209+
210+
return FileSpec(local_path, duration.get().count());
202211
}
203212

204213
std::optional<ModuleSpec> SymbolLocatorDebuginfod::LocateExecutableObjectFile(

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("symbolDownloadTime", symbol_download_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_download_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_download_time += sym_file->GetSymbolDownloadTime();
351+
if (sym_file->GetObjectFile() != module->GetObjectFile())
352+
module_stat.symbol_download_time +=
353+
module->GetObjectFile()->GetFileSpec().GetDownloadTime();
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_download_time += module_stat.symbol_download_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+
{"totalSymbolDownloadTime", symbol_download_time},
394402
{"totalSymbolTableParseTime", symtab_parse_time},
395403
{"totalSymbolTableIndexTime", symtab_index_time},
396404
{"totalSymbolTablesLoadedFromCache", symtabs_loaded},

lldb/source/Utility/FileSpec.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,12 @@ FileSpec::FileSpec(llvm::StringRef path, Style style) : m_style(style) {
7272
SetFile(path, style);
7373
}
7474

75+
FileSpec::FileSpec(llvm::StringRef path, const double download_time,
76+
Style style)
77+
: m_download_time(download_time) {
78+
SetFile(path, style);
79+
}
80+
7581
FileSpec::FileSpec(llvm::StringRef path, const llvm::Triple &triple)
7682
: FileSpec{path, triple.isOSWindows() ? Style::windows : Style::posix} {}
7783

0 commit comments

Comments
 (0)