[PATCH] D106528: [clangd] Improve performance of dex by 45-60%

Kirill Bobyrev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 22 14:12:23 PDT 2021


kbobyrev updated this revision to Diff 360968.
kbobyrev added a comment.

Add another 7% compared to the patched version: cache Child->peek() in the
loop.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106528/new/

https://reviews.llvm.org/D106528

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


Index: clang-tools-extra/clangd/index/dex/Iterator.cpp
===================================================================
--- clang-tools-extra/clangd/index/dex/Iterator.cpp
+++ clang-tools-extra/clangd/index/dex/Iterator.cpp
@@ -106,9 +106,13 @@
           return;
         // If any child goes beyond given ID (i.e. ID is not the common item),
         // all children should be advanced to the next common item.
-        if (Child->peek() > SyncID) {
-          SyncID = Child->peek();
+        auto Candidate = Child->peek();
+        if (Candidate > SyncID) {
+          SyncID = Candidate;
           NeedsAdvance = true;
+          // Reset and make sure advanceTo happens much less frequently on
+          // large posting lists. This accounts for 45-60% performance boost.
+          break;
         }
       }
     } while (NeedsAdvance);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D106528.360968.patch
Type: text/x-patch
Size: 851 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210722/b4892d45/attachment.bin>


More information about the cfe-commits mailing list