This is an archive of the discontinued LLVM Phabricator instance.

NFC delay tilde expansion on source path remappings until we are opening a source file
ClosedPublic

Authored by jasonmolenda on May 25 2022, 4:37 PM.

Details

Summary

Internal to Apple, we have dSYMs that include source path remappings from the build-system paths to the long-term storage, and the latter point to NFS mounted directories, using a tilde username component. Currently, lldb expands those tilde paths to absolute paths when it is parsing the dSYMs, but this requires a stat of the full NFS filepath to the source directory -- and over a slow network, that delay can be significant. These initial realpath & stat's would all happen at initial file load / process launch, which is already a huge perf bottleneck. It's quite easy to move them out of there, and over a slow network connection, can yield a large time savings.

This patch keeps the source path remapping names in terms of tilde-username until we are actually opening one of the source files, at which point we realpath and test for the path existence. We'll be opening the source file anyway in a second, so walking the inodes would be done for that - there's no additional perf penalty from doing the expansion-and-check here.

Diff Detail

Event Timeline

jasonmolenda created this revision.May 25 2022, 4:37 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 25 2022, 4:37 PM
jasonmolenda requested review of this revision.May 25 2022, 4:37 PM

Very nice

lldb/source/Core/SourceManager.cpp
76–80

I would create a little helper function (resolve_tilde(FileSpec& s) or something) to avoid duplicating this code on line 541?

407

I guess this shouldn't be here?

Address Jonas' feedback.

This revision is now accepted and ready to land.May 25 2022, 11:36 PM

Temporarily reverted for an x86_64 debian bot failure. Probably my comparison of the first character of the FileSpec path with '~' in resolve_tilde() is crashing with some code path that hands us an empty/uninitialized FileSpec. Will try again tomorrow after looking more closely.