This is an archive of the discontinued LLVM Phabricator instance.

Increase performance of llvm-gsymutil by up to 200%.
ClosedPublic

Authored by clayborg on Jul 31 2023, 10:32 PM.

Details

Summary

llvm-gsymutil was maintaining an address ranges collection behind a mutex and having the multi-threaded code access this and hold the mutex was causing slowdown when converting DWARF to GSYM. This patch does the following:

  • removes the "Ranges" variable from the GsymCreator and any functions and places that used it
  • clients don't try to detect if a function has been added for an address range, we now remove any inferior copies of information in the GsymCreator::finalize() routine as was done before, we just have more items to remove, though performance is greator due to less mutex thread locking
  • after I started adding all of the inferior funtion info objects the previous patch that tried to remove infrior debug info had bugs in it, so I replace the removeIfBinary() function in GsymCreator with a more efficient and easier to debug way to do things which copies items from the GsymCreator::Funcs into a new vector of FunctionInfo objects and then replaces GsymCreator::Funcs at the end.
  • Sorting of FunctionInfo objects has been modified to also compare InlineInfo objects. We found cases where LTO was ruining inline function address ranges and we ended up with a variety of FunctionInfo objects for the same range that had varying amounts of valid debug info. This patch now ensure that two function info objects with different inline info for the same function address range, the best one will be picked to ensure the greatest fidelity.
  • If we detect that a DW_TAG_subprogram has inline functions and after parsing it, we don't end up with any valid inline information, we set the optional to std::nullopt to avoid emitting empty inline information and wasting space.

My tests show a 200% perf increase on M1 macs and a 100% performance increase on linux machines for the same complex large DWARF input binary.

Diff Detail

Event Timeline

clayborg created this revision.Jul 31 2023, 10:32 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 31 2023, 10:32 PM
clayborg requested review of this revision.Jul 31 2023, 10:32 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 31 2023, 10:32 PM
yinghuitan accepted this revision.Aug 1 2023, 9:24 AM

LGTM

llvm/lib/DebugInfo/GSYM/GsymCreator.cpp
248

Nit: Prev != Curr

272

Nit: Prev.Range.empty()?

This revision is now accepted and ready to land.Aug 1 2023, 9:24 AM
This revision was landed with ongoing or failed builds.Aug 1 2023, 1:48 PM
This revision was automatically updated to reflect the committed changes.