[PATCH] D91051: [clangd] Improve clangd-indexer performance
Aleksandr Platonov via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Nov 11 03:39:23 PST 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rGdad804a193ed: [clangd] Improve clangd-indexer performance (authored by ArcsinX).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D91051/new/
https://reviews.llvm.org/D91051
Files:
clang-tools-extra/clangd/indexer/IndexerMain.cpp
Index: clang-tools-extra/clangd/indexer/IndexerMain.cpp
===================================================================
--- clang-tools-extra/clangd/indexer/IndexerMain.cpp
+++ clang-tools-extra/clangd/indexer/IndexerMain.cpp
@@ -43,6 +43,16 @@
std::unique_ptr<FrontendAction> create() override {
SymbolCollector::Options Opts;
Opts.CountReferences = true;
+ Opts.FileFilter = [&](const SourceManager &SM, FileID FID) {
+ const auto *F = SM.getFileEntryForID(FID);
+ if (!F)
+ return false; // Skip invalid files.
+ auto AbsPath = getCanonicalPath(F, SM);
+ if (!AbsPath)
+ return false; // Skip files without absolute path.
+ std::lock_guard<std::mutex> Lock(FilesMu);
+ return Files.insert(*AbsPath).second; // Skip already processed files.
+ };
return createStaticIndexingAction(
Opts,
[&](SymbolSlab S) {
@@ -56,7 +66,7 @@
}
},
[&](RefSlab S) {
- std::lock_guard<std::mutex> Lock(SymbolsMu);
+ std::lock_guard<std::mutex> Lock(RefsMu);
for (const auto &Sym : S) {
// Deduplication happens during insertion.
for (const auto &Ref : Sym.second)
@@ -64,7 +74,7 @@
}
},
[&](RelationSlab S) {
- std::lock_guard<std::mutex> Lock(SymbolsMu);
+ std::lock_guard<std::mutex> Lock(RelsMu);
for (const auto &R : S) {
Relations.insert(R);
}
@@ -82,9 +92,13 @@
private:
IndexFileIn &Result;
+ std::mutex FilesMu;
+ llvm::StringSet<> Files;
std::mutex SymbolsMu;
SymbolSlab::Builder Symbols;
+ std::mutex RefsMu;
RefSlab::Builder Refs;
+ std::mutex RelsMu;
RelationSlab::Builder Relations;
};
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D91051.304454.patch
Type: text/x-patch
Size: 1762 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20201111/f4696a12/attachment.bin>
More information about the cfe-commits
mailing list