kadircet updated this revision to Diff 296113.
kadircet added a comment.
- Rebase
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D88414/new/
https://reviews.llvm.org/D88414
Files:
clang-tools-extra/clangd/index/Background.cpp
clang-tools-extra/clangd/index/Background.h
clang-tools-extra/clangd/index/FileIndex.cpp
clang-tools-extra/clangd/index/FileIndex.h
Index: clang-tools-extra/clangd/index/FileIndex.h
===================================================================
--- clang-tools-extra/clangd/index/FileIndex.h
+++ clang-tools-extra/clangd/index/FileIndex.h
@@ -24,6 +24,7 @@
#include "index/Relation.h"
#include "index/Serialization.h"
#include "index/Symbol.h"
+#include "support/MemoryTree.h"
#include "support/Path.h"
#include "clang/Lex/Preprocessor.h"
#include "clang/Tooling/CompilationDatabase.h"
@@ -87,6 +88,8 @@
DuplicateHandling DuplicateHandle = DuplicateHandling::PickOne,
size_t *Version = nullptr);
+ void attachMemoryUsage(MemoryTree &MT) const;
+
private:
struct RefSlabAndCountReferences {
std::shared_ptr<RefSlab> Slab;
@@ -116,6 +119,8 @@
/// `indexMainDecls`.
void updateMain(PathRef Path, ParsedAST &AST);
+ void attachMemoryUsage(MemoryTree &MT) const;
+
private:
bool UseDex; // FIXME: this should be always on.
bool CollectMainFileRefs;
Index: clang-tools-extra/clangd/index/FileIndex.cpp
===================================================================
--- clang-tools-extra/clangd/index/FileIndex.cpp
+++ clang-tools-extra/clangd/index/FileIndex.cpp
@@ -22,6 +22,7 @@
#include "index/SymbolOrigin.h"
#include "index/dex/Dex.h"
#include "support/Logger.h"
+#include "support/MemoryTree.h"
#include "support/Path.h"
#include "clang/AST/ASTContext.h"
#include "clang/Index/IndexingAction.h"
@@ -373,6 +374,16 @@
llvm_unreachable("Unknown clangd::IndexType");
}
+void FileSymbols::attachMemoryUsage(MemoryTree &MT) const {
+ std::lock_guard<std::mutex> Lock(Mutex);
+ for (const auto &SymSlab : SymbolsSnapshot)
+ MT.addDetail(SymSlab.first())->addUsage(SymSlab.second->bytes());
+ for (const auto &RefSlab : RefsSnapshot)
+ MT.addDetail(RefSlab.first())->addUsage(RefSlab.second.Slab->bytes());
+ for (const auto &RelSlab : SymbolsSnapshot)
+ MT.addDetail(RelSlab.first())->addUsage(RelSlab.second->bytes());
+}
+
FileIndex::FileIndex(bool UseDex, bool CollectMainFileRefs)
: MergedIndex(&MainFileIndex, &PreambleIndex), UseDex(UseDex),
CollectMainFileRefs(CollectMainFileRefs),
@@ -442,5 +453,11 @@
}
}
+void FileIndex::attachMemoryUsage(MemoryTree &MT) const {
+ PreambleSymbols.attachMemoryUsage(*MT.addChild("preamble_symbols"));
+ MT.addChild("preamble_index")->addUsage(PreambleIndex.estimateMemoryUsage());
+ MainFileSymbols.attachMemoryUsage(*MT.addChild("main_file_symbols"));
+ MT.addChild("main_file_index")->addUsage(MainFileIndex.estimateMemoryUsage());
+}
} // namespace clangd
} // namespace clang
Index: clang-tools-extra/clangd/index/Background.h
===================================================================
--- clang-tools-extra/clangd/index/Background.h
+++ clang-tools-extra/clangd/index/Background.h
@@ -16,9 +16,11 @@
#include "index/Index.h"
#include "index/Serialization.h"
#include "support/Context.h"
+#include "support/MemoryTree.h"
#include "support/Path.h"
#include "support/Threading.h"
#include "support/ThreadsafeFS.h"
+#include "support/Trace.h"
#include "clang/Tooling/CompilationDatabase.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/Support/Threading.h"
@@ -172,6 +174,8 @@
return Queue.blockUntilIdleForTest(TimeoutSeconds);
}
+ void attachMemoryUsage(MemoryTree &MT) const;
+
private:
/// Represents the state of a single file when indexing was performed.
struct ShardVersion {
Index: clang-tools-extra/clangd/index/Background.cpp
===================================================================
--- clang-tools-extra/clangd/index/Background.cpp
+++ clang-tools-extra/clangd/index/Background.cpp
@@ -414,5 +414,9 @@
return {TUsToIndex.begin(), TUsToIndex.end()};
}
+void BackgroundIndex::attachMemoryUsage(MemoryTree &MT) const {
+ IndexedSymbols.attachMemoryUsage(*MT.addChild("symbols"));
+ MT.addChild("index")->addUsage(estimateMemoryUsage());
+}
} // namespace clangd
} // namespace clang
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits