summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clangd
diff options
context:
space:
mode:
Diffstat (limited to 'clang-tools-extra/clangd')
-rw-r--r--clang-tools-extra/clangd/index/Serialization.cpp10
-rw-r--r--clang-tools-extra/clangd/index/dex/Dex.cpp7
-rw-r--r--clang-tools-extra/clangd/index/dex/PostingList.h6
3 files changed, 12 insertions, 11 deletions
diff --git a/clang-tools-extra/clangd/index/Serialization.cpp b/clang-tools-extra/clangd/index/Serialization.cpp
index 4f5413a7ecf..5e16137f8b2 100644
--- a/clang-tools-extra/clangd/index/Serialization.cpp
+++ b/clang-tools-extra/clangd/index/Serialization.cpp
@@ -6,8 +6,10 @@
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
+
#include "Serialization.h"
#include "Index.h"
+#include "Logger.h"
#include "RIFF.h"
#include "Trace.h"
#include "dex/Dex.h"
@@ -433,8 +435,12 @@ std::unique_ptr<SymbolIndex> loadIndex(llvm::StringRef SymbolFilename,
}
trace::Span Tracer("BuildIndex");
- return UseDex ? dex::Dex::build(std::move(Symbols), URISchemes)
- : MemIndex::build(std::move(Symbols), std::move(Refs));
+ auto Index = UseDex ? dex::Dex::build(std::move(Symbols), URISchemes)
+ : MemIndex::build(std::move(Symbols), std::move(Refs));
+ vlog("Loaded {0} from {1} with estimated memory usage {2}",
+ UseDex ? "Dex" : "MemIndex", SymbolFilename,
+ Index->estimateMemoryUsage());
+ return Index;
}
} // namespace clangd
diff --git a/clang-tools-extra/clangd/index/dex/Dex.cpp b/clang-tools-extra/clangd/index/dex/Dex.cpp
index 29742227b52..4086d1f00e7 100644
--- a/clang-tools-extra/clangd/index/dex/Dex.cpp
+++ b/clang-tools-extra/clangd/index/dex/Dex.cpp
@@ -130,9 +130,6 @@ void Dex::buildIndex() {
for (const auto &TokenToPostingList : TempInvertedIndex)
InvertedIndex.insert(
{TokenToPostingList.first, PostingList(TokenToPostingList.second)});
-
- vlog("Built Dex with estimated memory usage {0} bytes.",
- estimateMemoryUsage());
}
/// Constructs iterators over tokens extracted from the query and exhausts it
@@ -248,8 +245,8 @@ size_t Dex::estimateMemoryUsage() const {
Bytes += SymbolQuality.size() * sizeof(float);
Bytes += LookupTable.getMemorySize();
Bytes += InvertedIndex.getMemorySize();
- for (const auto &P : InvertedIndex)
- Bytes += P.second.bytes();
+ for (const auto &TokenToPostingList : InvertedIndex)
+ Bytes += TokenToPostingList.second.bytes();
return Bytes + BackingDataSize;
}
diff --git a/clang-tools-extra/clangd/index/dex/PostingList.h b/clang-tools-extra/clangd/index/dex/PostingList.h
index 010fb1b039d..5b3c9b79f40 100644
--- a/clang-tools-extra/clangd/index/dex/PostingList.h
+++ b/clang-tools-extra/clangd/index/dex/PostingList.h
@@ -66,10 +66,8 @@ public:
/// go through the chunks and decompress them on-the-fly when necessary.
std::unique_ptr<Iterator> iterator() const;
- /// Returns in-memory size.
- size_t bytes() const {
- return sizeof(Chunk) + Chunks.capacity() * sizeof(Chunk);
- }
+ /// Returns in-memory size of external storage.
+ size_t bytes() const { return Chunks.capacity() * sizeof(Chunk); }
private:
const std::vector<Chunk> Chunks;
OpenPOWER on IntegriCloud