This is an archive of the discontinued LLVM Phabricator instance.

[lldb] Allow DataFileCache to be constructed with a different policy
ClosedPublic

Authored by augusto2112 on Aug 9 2022, 4:52 PM.

Diff Detail

Event Timeline

augusto2112 created this revision.Aug 9 2022, 4:52 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 9 2022, 4:52 PM
augusto2112 requested review of this revision.Aug 9 2022, 4:52 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 9 2022, 4:52 PM

Is this new constructor going to be used elsewhere? It would be great to get more description on why this is desired/needed?

JDevlieghere added inline comments.Aug 9 2022, 11:43 PM
lldb/source/Core/DataFileCache.cpp
22–49

Would it make sense to extract this into a static function say DefaultCachePruningPolicy and then have one constructor with an optional policy argument? Something like this:

DataFileCache(llvm::StringRef path, llvm::CachePruningPolicy policy = DataFileCache::DefaultCachePruningPolicy);

In addition to having only one constructor, the new function also provides a natural place to document the policy.

50

Is it intentional that we now call this twice?

Is this new constructor going to be used elsewhere? It would be great to get more description on why this is desired/needed?

I'm implementing a cache for swift type metadata for downstream lldb. I thought it made sense to separate its configuration from this index cache one, since we might want to enable either of them independently of the other, set different sizes, expiration dates, etc.

lldb/source/Core/DataFileCache.cpp
22–49

Sounds like a good idea!

50

No! Thanks.

Added a static 'GetLLDBIndexCachePolicy' function, removed the constructor without any policies

JDevlieghere added inline comments.Aug 10 2022, 10:47 AM
lldb/include/lldb/Core/DataFileCache.h
86

It's a little weird that GetLLDBIndexCachePolicy would be private, if only from a documentation point of view so that you can refer to it in the constructor.

87

Comment is incomplete

Made GetLLDBIndexCachePolicy public

augusto2112 marked 4 inline comments as done.Aug 10 2022, 10:57 AM
JDevlieghere accepted this revision.Aug 10 2022, 1:20 PM

LGTM

lldb/source/Core/DataFileCache.cpp
23–50

I was worried that by caching the policy here, changing the lldb-index-cache- settings after the first DataFileCache has been created won't have any effect. But it looks like the DataFileCache is already a static/global used by the Modules, so that's already the case in practice. Maybe a follow-up patch could make that explicit in the help enable-lldb-index-cache help description.

This revision is now accepted and ready to land.Aug 10 2022, 1:20 PM
clayborg accepted this revision.Aug 10 2022, 8:47 PM