This is an archive of the discontinued LLVM Phabricator instance.

Cache tilde expansions to avoid redundant lookups
AbandonedPublic

Authored by jasonmolenda on May 12 2022, 3:57 PM.

Details

Summary

We have tilde's in our dSYMs internally, and expanding these can involve a network access that is slow for some people. I'm not worried about tilde expanding to a different filepath during the lifetime of a single lldb session, and I believe people will see very few different tildes ever expanded -- I'd be surprised if anyone exceed five different tilde's -- so this would be something easy to cache in lldb given how TildeExpressionResolver::ResolveFullPath() is structured.

This patch creates a simple vector of <ConstString, std::string>'s with the tilde names (ConstString to make comparisons cheap) and the expanded filepath. The method accepts a filepath as a StringRef and returns an expanded path in a SmallVectorImpl<char>, but I don't think the specific container used is important one way or the other. I'm not wedded to this impl though.

This bit of code has been untouched in years, but adding Jonas who did touch it a couple years ago.

rdar://77091379

Diff Detail

Event Timeline

jasonmolenda created this revision.May 12 2022, 3:57 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 12 2022, 3:57 PM
jasonmolenda requested review of this revision.May 12 2022, 3:57 PM
jingham requested changes to this revision.May 12 2022, 4:17 PM
jingham added a subscriber: jingham.

I don't think the cache belongs in a global in the TildeExpressionResolver class. The derived ExpressionResolvers might very well resolve the same ~foo to different paths (e.g. if there were a RemoteTildeExpressionResolver.) So the cache needs to be kept in the derived class rather than in a global object. Maybe just add an abstract GetTildeCache method to TildeExpressionResolver to fetch the cache from the subclass?

This revision now requires changes to proceed.May 12 2022, 4:17 PM

Yeah, you're right. And as I walk through in my head what I'm solving with this -- it's not the really expensive part of this whole operation, I don't think. I should check more carefully but it's the stat's over NFS partitions that are impacting performance, and I doubt the realpath() to expand the tilde's is a significant factor (the kernel should cache all of these inodes anyway if we're doing it in a hot fashion). I'll probably abandon this altogether unless I can prove to myself that it's important, and hoist it into the base class.

jasonmolenda abandoned this revision.May 12 2022, 5:12 PM