diff --git a/clang-tools-extra/clangd/ClangdServer.cpp b/clang-tools-extra/clangd/ClangdServer.cpp --- a/clang-tools-extra/clangd/ClangdServer.cpp +++ b/clang-tools-extra/clangd/ClangdServer.cpp @@ -40,9 +40,11 @@ #include "llvm/Support/FileSystem.h" #include "llvm/Support/Path.h" #include "llvm/Support/raw_ostream.h" +#include #include #include #include +#include namespace clang { namespace clangd { @@ -117,8 +119,7 @@ : nullptr), GetClangTidyOptions(Opts.GetClangTidyOptions), SuggestMissingIncludes(Opts.SuggestMissingIncludes), - TweakFilter(Opts.TweakFilter), - WorkspaceRoot(Opts.WorkspaceRoot), + TweakFilter(Opts.TweakFilter), WorkspaceRoot(Opts.WorkspaceRoot), // Pass a callback into `WorkScheduler` to extract symbols from a newly // parsed file and rebuild the file index synchronously each time an AST // is parsed. @@ -144,7 +145,8 @@ BackgroundIdx = llvm::make_unique( Context::current().clone(), FSProvider, CDB, BackgroundIndexStorage::createDiskBackedStorageFactory( - [&CDB](llvm::StringRef File) { return CDB.getProjectInfo(File); })); + [&CDB](llvm::StringRef File) { return CDB.getProjectInfo(File); }), + std::max(Opts.AsyncThreadsCount, static_cast(1))); AddIndex(BackgroundIdx.get()); } if (DynamicIdx) diff --git a/clang-tools-extra/clangd/tool/ClangdMain.cpp b/clang-tools-extra/clangd/tool/ClangdMain.cpp --- a/clang-tools-extra/clangd/tool/ClangdMain.cpp +++ b/clang-tools-extra/clangd/tool/ClangdMain.cpp @@ -267,7 +267,8 @@ opt WorkerThreadsCount{ "j", cat(Misc), - desc("Number of async workers used by clangd"), + desc("Number of async workers used by clangd. Background index also " + "uses this many workers."), init(getDefaultAsyncThreadsCount()), }; @@ -308,7 +309,8 @@ opt Sync{ "sync", cat(Misc), - desc("Parse on main thread. If set, -j is ignored"), + desc("Handle client requests on main thread. Background index still uses " + "its own thread."), init(false), Hidden, };