From 951b85359a8b4781bae9e0735a893aee07b3dd1e Mon Sep 17 00:00:00 2001 From: Rintaro Ishizaki Date: Tue, 14 Jan 2020 13:06:57 -0800 Subject: [PATCH] [SourceKit] Disable module system headers validation in all SourceKit requests. This validation may call many stat(2). Since we don't expect system files are edited. Disable it for SourceKit requests. Even if they are edited, manual builds can validates and updates them. rdar://problem/58550697 --- lib/IDE/CompletionInstance.cpp | 5 ----- tools/SourceKit/lib/SwiftLang/SwiftASTManager.cpp | 5 +++++ tools/swift-ide-test/swift-ide-test.cpp | 2 ++ 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/IDE/CompletionInstance.cpp b/lib/IDE/CompletionInstance.cpp index 44dbf98a3fadd..632a3b5f6542a 100644 --- a/lib/IDE/CompletionInstance.cpp +++ b/lib/IDE/CompletionInstance.cpp @@ -324,11 +324,6 @@ bool swift::ide::CompletionInstance::performOperation( // source text. That breaks an invariant of syntax tree building. Invocation.getLangOptions().BuildSyntaxTree = false; - // This validation may call stat(2) many times. Disable it to prevent - // performance regression. - Invocation.getSearchPathOptions().DisableModulesValidateSystemDependencies = - true; - // FIXME: ASTScopeLookup doesn't support code completion yet. Invocation.disableASTScopeLookup(); diff --git a/tools/SourceKit/lib/SwiftLang/SwiftASTManager.cpp b/tools/SourceKit/lib/SwiftLang/SwiftASTManager.cpp index 1e2b1fd10a211..1ebbcfeb25441 100644 --- a/tools/SourceKit/lib/SwiftLang/SwiftASTManager.cpp +++ b/tools/SourceKit/lib/SwiftLang/SwiftASTManager.cpp @@ -539,6 +539,11 @@ bool SwiftASTManager::initCompilerInvocation( // We don't care about LLVMArgs FrontendOpts.LLVMArgs.clear(); + // This validation may call stat(2) many times. Disable it to prevent + // performance issues. + Invocation.getSearchPathOptions().DisableModulesValidateSystemDependencies = + true; + // SwiftSourceInfo files provide source location information for decls coming // from loaded modules. For most IDE use cases it either has an undesirable // impact on performance with no benefit (code completion), results in stale diff --git a/tools/swift-ide-test/swift-ide-test.cpp b/tools/swift-ide-test/swift-ide-test.cpp index 995eaaaab5eef..fb2b67b7225fb 100644 --- a/tools/swift-ide-test/swift-ide-test.cpp +++ b/tools/swift-ide-test/swift-ide-test.cpp @@ -3436,6 +3436,8 @@ int main(int argc, char *argv[]) { options::DebugForbidTypecheckPrefix; InitInvok.getTypeCheckerOptions().DebugConstraintSolver = options::DebugConstraintSolver; + InitInvok.getSearchPathOptions().DisableModulesValidateSystemDependencies = + true; for (auto ConfigName : options::BuildConfigs) InitInvok.getLangOptions().addCustomConditionalCompilationFlag(ConfigName);