forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 341
🍒 [clang][deps][modules] Speed up dependency scanning (2) #9573
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
Merged
jansvoboda11
merged 13 commits into
stable/20240723
from
jan_svoboda/stable-20240723-scanner-perf-2
Nov 12, 2024
Merged
🍒 [clang][deps][modules] Speed up dependency scanning (2) #9573
jansvoboda11
merged 13 commits into
stable/20240723
from
jan_svoboda/stable-20240723-scanner-perf-2
Nov 12, 2024
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This PR builds on top of llvm#113984 and attempts to avoid allocating input file paths eagerly. Instead, the `InputFileInfo` type used by `ASTReader` now only holds `StringRef`s that point into the PCM file buffer, and the full input file paths get resolved on demand. The dependency scanner makes use of this in a bit of a roundabout way: `ModuleDeps` now only holds (an owning copy of) the short unresolved input file paths, which get resolved lazily. This can be a big win, I'm seeing up to a 5% speedup. (cherry picked from commit 9d4837f)
(cherry picked from commit c605fa3)
(cherry picked from commit fa311ca)
The `FileManager` sharing between module-building `CompilerInstance`s was disabled a while ago due to `FileEntry::getName()` being unreliable. Now that we use `FileEntryRef::getNameAsRequested()` in places where it matters, re-enabling `FileManager` is sound and improves performance of `clang-scan-deps` by ~6.2%. (cherry picked from commit a6637ae)
(cherry picked from commit 85a6e90)
…scope (cherry picked from commit bcb64e1)
(cherry picked from commit 0276621)
…` scope (cherry picked from commit 304c412)
(cherry picked from commit 18e0eb4)
This patch removes `ASTWriter::Context` and starts passing `ASTContext &` explicitly to functions that actually need it. This is a non-functional change with the end-goal of being able to write lightweight PCM files with no `ASTContext` at all. (cherry picked from commit 53e49f1)
… only (llvm#115237) This PR builds on top of llvm#115235 and makes it possible to call `ASTWriter::WriteAST()` with `Preprocessor` only instead of full `Sema` object. So far, there are no clients that leverage the new capability - that will come in a follow-up commit. (cherry picked from commit a2f9d1d)
This patch builds on top of llvm#115237 and llvm#115235, only passing the `Preprocessor` object to `ASTWriter`. This reduces the size of scanning PCM files by 1/3 and speeds up scans by 16%. (cherry picked from commit 25d1ac1)
@swift-ci please test |
swiftlang/swift#77557 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR cherry-picks upstream commits that speed up the dependency scanning. This should be mostly NFC.