This is an archive of the discontinued LLVM Phabricator instance.

Remove unused modules from module cache
ClosedPublic

Authored by ovyalov on Sep 18 2015, 10:10 AM.

Details

Reviewers
zturner
clayborg
Summary

When putting a new module into module cache sysroot folder may contain existing hard link for an existing module with the same name but different build-id.
Use hard link counter to find out whether anybody else references an old module - if not, we can proceed with deleting unused module directory from $platform/.cache.
Move lock file location to $platform/.lock directory so we can create/delete module's directory while holding a lock.

Diff Detail

Event Timeline

ovyalov updated this revision to Diff 35096.Sep 18 2015, 10:10 AM
ovyalov retitled this revision from to Remove unused modules from module cache.
ovyalov updated this object.
ovyalov added reviewers: clayborg, zturner.
ovyalov added a subscriber: lldb-commits.
zturner added inline comments.Sep 18 2015, 10:18 AM
source/Host/windows/FileSystem.cpp
130

GENERIC_READ is too strong if all you want to do is call GetFileInformationByHandle. I think all you need is FILE_READ_ATTRIBUTES. Can you try with FILE_READ_ATTRIBUTES and see if GetFileInformationByHandle succeeds? If so, just use that.

source/Utility/ModuleCache.cpp
110

Shouldn't this be >= 2?

clayborg accepted this revision.Sep 18 2015, 10:21 AM
clayborg edited edge metadata.

Flow looks good, take care of Zachs issues and this is good to go.

This revision is now accepted and ready to land.Sep 18 2015, 10:21 AM
ovyalov updated this revision to Diff 35106.Sep 18 2015, 10:38 AM
ovyalov edited edge metadata.

Replaced GENERIC_READ with FILE_READ_ATTRIBUTES when using ::CreateFile.

ovyalov added inline comments.Sep 18 2015, 10:41 AM
source/Host/windows/FileSystem.cpp
130

Thanks for suggestion - it does work. Fixed.

source/Utility/ModuleCache.cpp
110

If link counter == 2, it's okay to delete a module because in this case a counter includes following files: $platform/.cache/$uuid and its sysroot link.

zturner edited edge metadata.Sep 18 2015, 10:42 AM
zturner added a subscriber: zturner.

Ok, lgtm then

ovyalov closed this revision.Sep 18 2015, 11:15 AM

Files:

/lldb/trunk/include/lldb/Host/FileSystem.h
/lldb/trunk/source/Host/posix/FileSystem.cpp
/lldb/trunk/source/Host/windows/FileSystem.cpp
/lldb/trunk/source/Utility/ModuleCache.cpp

Users:

ovyalov (Author)

http://reviews.llvm.org/rL248017