This is an archive of the discontinued LLVM Phabricator instance.

[NFC] two small perf fixes for when using a DebugSymbols DBGShellCommands to find a dSYM
ClosedPublic

Authored by jasonmolenda on May 14 2022, 1:06 PM.

Details

Summary

SymbolVendorMacOSX::CreateInstance() calls LocateMacOSXFilesUsingDebugSymbols(), to the DebugSymbols framework on macOS, to find a dSYM on the local computer or from a remote server. This method constructs a Module, and it finds a dSYM, creates an ObjectFile for it, then calls SymbolVendor::AddSymbolFileRepresentation with that ObjectFile. The location of the dSYM hasn't been recorded in the Module anywhere, so AddSymbolFileRepresentation eventually (under many layers) calls LocateMacOSXFilesUsingDebugSymbols() again. So we call into the DebugSymbols framework twice. It's easy to fix; have SymbolVendorMacOSX::CreateInstance() add the dSYM path we found from the first call into LocateMacOSXFilesUsingDebugSymbols() in the Module before we call AddSymbolFileRepresentation().

The second perf fix is to LocateMacOSXFilesUsingDebugSymbols() so when it is handed a ModuleSpec that has a binary file path, and that file exists, one of the keys we get back from the DebugSymbols framework gives us a "symbol rich binary" (possibly unstripped). This isn't adding anything when we have the dSYM - we can use the original (possibly stripped) binary that we had to begin with. The symbol rich binary may even be over an NFS filesystem, introducing a large performance cost to using it over the local stripped binary.

Pretty straightforward stuff, not sure who to ask for review, this is more my area than anyone else I can think of these days. If anyone has comments, please let me know.

rdar://84576917

Diff Detail

Event Timeline

jasonmolenda created this revision.May 14 2022, 1:06 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 14 2022, 1:06 PM
jasonmolenda requested review of this revision.May 14 2022, 1:06 PM
JDevlieghere added inline comments.May 16 2022, 8:19 AM
lldb/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp
155
lldb/source/Symbol/LocateSymbolFileMacOSX.cpp
152–153

I assume an empty file spec wouldn't exist. Can this be simplified?

163–167

The macro checks if log is NULL.

183–189
195–197
jasonmolenda added inline comments.May 16 2022, 10:45 AM
lldb/source/Symbol/LocateSymbolFileMacOSX.cpp
152–153

I was worried that FileSystem::Exists might return true for an empty string filepath; it looks like this devolves down to a access() call, it's probably fine.

163–167

Ah good catch. I was copy & pasting from nearby code that did the same, I'll fix both.

Update to address Jonas' comments.

This revision is now accepted and ready to land.May 16 2022, 11:39 AM