This revision was automatically updated to reflect the committed changes. Closed by commit rL368498: clangd: use -j for background index pool (authored by sammccall, committed by ). Herald added a project: LLVM. Herald added a subscriber: llvm-commits.
Changed prior to commit: https://reviews.llvm.org/D66031?vs=214463&id=214475#toc Repository: rL LLVM CHANGES SINCE LAST ACTION https://reviews.llvm.org/D66031/new/ https://reviews.llvm.org/D66031 Files: clang-tools-extra/trunk/clangd/ClangdServer.cpp clang-tools-extra/trunk/clangd/TUScheduler.cpp clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp Index: clang-tools-extra/trunk/clangd/TUScheduler.cpp =================================================================== --- clang-tools-extra/trunk/clangd/TUScheduler.cpp +++ clang-tools-extra/trunk/clangd/TUScheduler.cpp @@ -54,6 +54,7 @@ #include "llvm/ADT/ScopeExit.h" #include "llvm/Support/Errc.h" #include "llvm/Support/Path.h" +#include "llvm/Support/Threading.h" #include <algorithm> #include <memory> #include <queue> @@ -801,10 +802,10 @@ } // namespace unsigned getDefaultAsyncThreadsCount() { - unsigned HardwareConcurrency = std::thread::hardware_concurrency(); - // C++ standard says that hardware_concurrency() - // may return 0, fallback to 1 worker thread in - // that case. + unsigned HardwareConcurrency = llvm::heavyweight_hardware_concurrency(); + // heavyweight_hardware_concurrency may fall back to hardware_concurrency. + // C++ standard says that hardware_concurrency() may return 0; fallback to 1 + // worker thread in that case. if (HardwareConcurrency == 0) return 1; return HardwareConcurrency; Index: clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp =================================================================== --- clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp +++ clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp @@ -267,7 +267,8 @@ opt<unsigned> 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<bool> 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, }; Index: clang-tools-extra/trunk/clangd/ClangdServer.cpp =================================================================== --- clang-tools-extra/trunk/clangd/ClangdServer.cpp +++ clang-tools-extra/trunk/clangd/ClangdServer.cpp @@ -40,9 +40,11 @@ #include "llvm/Support/FileSystem.h" #include "llvm/Support/Path.h" #include "llvm/Support/raw_ostream.h" +#include <algorithm> #include <future> #include <memory> #include <mutex> +#include <type_traits> 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<BackgroundIndex>( 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, 1u)); AddIndex(BackgroundIdx.get()); } if (DynamicIdx)
Index: clang-tools-extra/trunk/clangd/TUScheduler.cpp =================================================================== --- clang-tools-extra/trunk/clangd/TUScheduler.cpp +++ clang-tools-extra/trunk/clangd/TUScheduler.cpp @@ -54,6 +54,7 @@ #include "llvm/ADT/ScopeExit.h" #include "llvm/Support/Errc.h" #include "llvm/Support/Path.h" +#include "llvm/Support/Threading.h" #include <algorithm> #include <memory> #include <queue> @@ -801,10 +802,10 @@ } // namespace unsigned getDefaultAsyncThreadsCount() { - unsigned HardwareConcurrency = std::thread::hardware_concurrency(); - // C++ standard says that hardware_concurrency() - // may return 0, fallback to 1 worker thread in - // that case. + unsigned HardwareConcurrency = llvm::heavyweight_hardware_concurrency(); + // heavyweight_hardware_concurrency may fall back to hardware_concurrency. + // C++ standard says that hardware_concurrency() may return 0; fallback to 1 + // worker thread in that case. if (HardwareConcurrency == 0) return 1; return HardwareConcurrency; Index: clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp =================================================================== --- clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp +++ clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp @@ -267,7 +267,8 @@ opt<unsigned> 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<bool> 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, }; Index: clang-tools-extra/trunk/clangd/ClangdServer.cpp =================================================================== --- clang-tools-extra/trunk/clangd/ClangdServer.cpp +++ clang-tools-extra/trunk/clangd/ClangdServer.cpp @@ -40,9 +40,11 @@ #include "llvm/Support/FileSystem.h" #include "llvm/Support/Path.h" #include "llvm/Support/raw_ostream.h" +#include <algorithm> #include <future> #include <memory> #include <mutex> +#include <type_traits> 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<BackgroundIndex>( 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, 1u)); AddIndex(BackgroundIdx.get()); } if (DynamicIdx)
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits