Skip to content

[clang Dependency Scanning] Out-of-Date Scanning File System Cache Entry Reporting C-APIs #10927

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 10 commits into
base: next
Choose a base branch
from

Conversation

qiongsiwu
Copy link

@qiongsiwu qiongsiwu commented Jun 30, 2025

This PR implements the C-APIs to report a scanning file system cache's out-of-date entries. The C-APIs contains a function to return a set of file system cache out-of-date entries, functions to facilitate looping through all the entries, and reporting the relevant information from the entries.

The APIs are based on llvm#144105.

rdar://152247357

@qiongsiwu
Copy link
Author

Note to reviewers: I don't see a good way to cleanly test these APIs through c-index tests. Ideally, I'd like to create an underlying service whose file system cache I can manipulate directly to test these APIs directly (something similar to https://github.com/llvm/llvm-project/pull/144105/files#diff-25ec4b41a8aed83f312f2bb7b409f379f38dd9d1597d6e4e45e17681260dfcc2R205).

Do we think it is reasonable to create unit tests for these C-APIs? If so, I will try making some unit tests.

@qiongsiwu qiongsiwu requested a review from owenv June 30, 2025 21:38
@qiongsiwu qiongsiwu self-assigned this Jul 2, 2025
@qiongsiwu qiongsiwu marked this pull request as ready for review July 2, 2025 18:15
@qiongsiwu
Copy link
Author

@swift-ci please test llvm.

@qiongsiwu
Copy link
Author

@swift-ci please test llvm.

@qiongsiwu
Copy link
Author

qiongsiwu commented Jul 2, 2025

The two failing tests do not relate to this PR. rdar://154865941 is tracking them.

@qiongsiwu
Copy link
Author

Gentle ping for review. Thanks!

@jansvoboda11
Copy link

Adding the unit test is a nice bonus, but I'd be in favor in keeping the old c-index-test test around. I think it's nice that c-index-test is a nice one-stop-shop for anything libclang.

@qiongsiwu
Copy link
Author

qiongsiwu commented Jul 7, 2025

Adding the unit test is a nice bonus, but I'd be in favor in keeping the old c-index-test test around. I think it's nice that c-index-test is a nice one-stop-shop for anything libclang.

This is a good point. The difficulty is that it is not easy to create out-date-entries exactly as we desired to make sure we have good coverage of all the APIs. I can recover the removed c-index-test that at least runs through the APIs obtaining the out-of-date entry set and disposing it. The set will contain no entry. Does that sound reasonable?

@qiongsiwu qiongsiwu requested a review from jansvoboda11 July 7, 2025 19:19
@qiongsiwu
Copy link
Author

@swift-ci please test llvm.

@qiongsiwu
Copy link
Author

@swift-ci please test llvm.

@qiongsiwu qiongsiwu requested a review from jansvoboda11 July 8, 2025 16:47
@qiongsiwu
Copy link
Author

@swift-ci please test llvm.

Copy link

@jansvoboda11 jansvoboda11 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great, thank you! LGTM sans the small nits.

@@ -131,7 +131,11 @@ DependencyScanningFilesystemSharedCache::getOutOfDateEntries(
// later. The cache entry is not invalidated (as we have no good
// way to do it now), which may lead to missing file build errors.
InvalidDiagInfo.emplace_back(Path.data());
} else {
} else if (Status->getType() ==

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, this ignores symlinks that now point to path of different size. I don't think it's crucial to add support for those right now, but maybe it's worth pointing out in the comment below.

@@ -131,7 +131,11 @@ DependencyScanningFilesystemSharedCache::getOutOfDateEntries(
// later. The cache entry is not invalidated (as we have no good
// way to do it now), which may lead to missing file build errors.
InvalidDiagInfo.emplace_back(Path.data());
} else {
} else if (Status->getType() ==

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also makes me think of edge-cases where the type of the FS entry changed. Can we make sure we're comparing apples to apples (files to files) by checking Entry->getStatus()->getType() too? (Maybe we should explicitly report entries that changed type, but let's not block this PR on that.)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think changes here should also go upstream, right? (It's fine to do as a follow-up to reduce churn and waiting.)


EXPECT_TRUE(CheckedNegativelyCached && CheckedSizeChanged);

clang_experimental_DepScanFSCacheOutOfDateEntrySet_disposeSet(Entries);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably dispose of the other objects as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants