llvmorg-github-actions[bot] wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clangd

Author: Orgad Shaneh (orgads)

<details>
<summary>Changes</summary>

IndexBuilder::build() reserves the inverted index for the tokens it is going to 
have. It added RestrictedCCDocs.size() to that, which is the number of symbols 
that are indexed for code completion, although these are the posting list of a 
single token.

On a project with 195000 symbols, the inverted index of the background index 
had 262144 buckets for 50295 tokens. With the right number it has half of them, 
and the working set of clangd is 12 MB smaller: 474 MB instead of 486 MB.

Assisted-by: Claude Code

---
Full diff: https://github.com/llvm/llvm-project/pull/244530.diff


1 Files Affected:

- (modified) clang-tools-extra/clangd/index/dex/Dex.cpp (+4-6) 


``````````diff
diff --git a/clang-tools-extra/clangd/index/dex/Dex.cpp 
b/clang-tools-extra/clangd/index/dex/Dex.cpp
index 179d8c4da0b3ec..616304b6b314c9 100644
--- a/clang-tools-extra/clangd/index/dex/Dex.cpp
+++ b/clang-tools-extra/clangd/index/dex/Dex.cpp
@@ -84,12 +84,10 @@ class IndexBuilder {
 
   // Assemble the final compressed posting lists for the added symbols.
   llvm::DenseMap<Token, PostingList> build() && {
-    llvm::DenseMap<Token, PostingList> Result(/*InitialReserve=*/
-                                              TrigramDocs.size() +
-                                              RestrictedCCDocs.size() +
-                                              TypeDocs.size() +
-                                              ScopeDocs.size() +
-                                              ProximityDocs.size());
+    // RestrictedCCDocs is the posting list of a single token.
+    llvm::DenseMap<Token, PostingList> Result(
+        /*InitialReserve=*/TrigramDocs.size() + !RestrictedCCDocs.empty() +
+        TypeDocs.size() + ScopeDocs.size() + ProximityDocs.size());
     // Tear down intermediate structs as we go to reduce memory usage.
     // Since we're trying to get rid of underlying allocations, clearing the
     // containers is not enough.

``````````

</details>


https://github.com/llvm/llvm-project/pull/244530
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to