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);
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);
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits