[PATCH] D52503: [clangd] More precise index memory usage estimate

Kirill Bobyrev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 25 09:06:22 PDT 2018


kbobyrev created this revision.
kbobyrev added reviewers: ioeric, sammccall.
kbobyrev added a project: clang-tools-extra.
Herald added subscribers: kadircet, arphaman, jkorous, MaskRay.

This patch adds `Token`'s string data to the memory estimation. While it is only responsible for a couple of extra megabytes of symbol index (out of ~150 MB) it still makes the estimate more precise.


https://reviews.llvm.org/D52503

Files:
  clang-tools-extra/clangd/index/dex/Dex.cpp


Index: clang-tools-extra/clangd/index/dex/Dex.cpp
===================================================================
--- clang-tools-extra/clangd/index/dex/Dex.cpp
+++ clang-tools-extra/clangd/index/dex/Dex.cpp
@@ -248,8 +248,9 @@
   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.first.Data.size() +
+             TokenToPostingList.second.bytes();
   return Bytes + BackingDataSize;
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D52503.166891.patch
Type: text/x-patch
Size: 635 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180925/97d1dc78/attachment.bin>


More information about the cfe-commits mailing list