This is an archive of the discontinued LLVM Phabricator instance.

[lldb] Add information on type systems to statistics dump command
ClosedPublic

Authored by bulbazord on Nov 1 2022, 1:41 PM.

Details

Summary

Context: I plan on using this change primarily downstream in the apple fork of llvm to track swift module loading time.

The idea is that TypeSystems from modules can self-report statistics when performing the statistics dump of a module.

Diff Detail

Event Timeline

bulbazord created this revision.Nov 1 2022, 1:41 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 1 2022, 1:41 PM
bulbazord requested review of this revision.Nov 1 2022, 1:41 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 1 2022, 1:41 PM

I have a pull request to apple's fork to show how this is used for swift: https://github.com/apple/llvm-project/pull/5540

I primarily wanted this portion to be upstream so that the patch is easier to maintain downstream, but it could be useful for clang-produced TypeSystems as well.

clayborg requested changes to this revision.Nov 1 2022, 2:03 PM
clayborg added inline comments.
lldb/source/Target/Statistics.cpp
269–274

Seems like we should be populating module_stat to contain a dictionary of TypeSystem plug-in name to stats. So adding something to the ModuleStats structure like:

std::map<std::string, json::Value> type_system_stats;

Then the loop below would look like:

module->ForEachTypeSystem([&](TypeSystem *ts) {
  if (auto stats = ts->ReportStatistics())
    module_stat. type_system_stats[ts->GetPluginName()] = stats.value();
  return true;
});

We currently don't have each type system reporting a plug-in name, but that would be easy to add to the two TypeSystem plug-ins. ModuleStat::ToJSON() would need to be modified to emit a "typeSystemInfo" only if there are any stats in the "module_stat.type_system_stats" member.

282

Remove {} for single line if statement per llvm coding guidelines

283

We have been doing camel case, but starting with lower case.

This revision now requires changes to proceed.Nov 1 2022, 2:03 PM
tschuett added inline comments.
lldb/include/lldb/Core/Module.h
818
tschuett added inline comments.Nov 1 2022, 2:18 PM
lldb/source/Target/Statistics.cpp
282

I am bit confused. If auto stats is an optional. Please remove .hasValue() and replace stats.getValue by *stats.

bulbazord updated this revision to Diff 472468.Nov 1 2022, 5:35 PM

Address feedback

bulbazord marked 5 inline comments as done.Nov 1 2022, 5:35 PM
clayborg accepted this revision.Nov 1 2022, 9:19 PM

Thanks for the changes. Looks good.

This revision is now accepted and ready to land.Nov 1 2022, 9:19 PM
tschuett added inline comments.Nov 2 2022, 1:08 AM
lldb/include/lldb/Core/Module.h
818

Nit: the const &is redundant. It is a function reference.

bulbazord updated this revision to Diff 472672.Nov 2 2022, 10:18 AM

Remove const & from argument to Module::ForEachTypeSystem