Skip to content

[clang][deps] Share FileManager between modules #115065

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
merged 1 commit into from
Nov 6, 2024

Conversation

jansvoboda11
Copy link
Contributor

The FileManager sharing between module-building CompilerInstances 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%.

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%.
@llvmbot llvmbot added the clang Clang issues not falling into any other category label Nov 5, 2024
@llvmbot
Copy link
Member

llvmbot commented Nov 5, 2024

@llvm/pr-subscribers-clang

Author: Jan Svoboda (jansvoboda11)

Changes

The FileManager sharing between module-building CompilerInstances 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%.


Full diff: https://github.com/llvm/llvm-project/pull/115065.diff

1 Files Affected:

  • (modified) clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp (+3-1)
diff --git a/clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp b/clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
index d77187bfb1f2b8..1deffe68003804 100644
--- a/clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
+++ b/clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
@@ -335,7 +335,9 @@ class DependencyScanningAction : public tooling::ToolAction {
 
     ScanInstance.getFrontendOpts().GenerateGlobalModuleIndex = false;
     ScanInstance.getFrontendOpts().UseGlobalModuleIndex = false;
-    ScanInstance.getFrontendOpts().ModulesShareFileManager = false;
+    // This will prevent us compiling individual modules asynchronously since
+    // FileManager is not thread-safe, but it does improve performance for now.
+    ScanInstance.getFrontendOpts().ModulesShareFileManager = true;
     ScanInstance.getHeaderSearchOpts().ModuleFormat = "raw";
     ScanInstance.getHeaderSearchOpts().ModulesIncludeVFSUsage =
         any(OptimizeArgs & ScanningOptimizations::VFS);

@jansvoboda11 jansvoboda11 merged commit a6637ae into llvm:main Nov 6, 2024
10 checks passed
@jansvoboda11 jansvoboda11 deleted the share-file-manager branch November 6, 2024 22:21
jansvoboda11 added a commit to swiftlang/llvm-project that referenced this pull request Nov 11, 2024
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants