[clangd] Rewrite of logic to rebuild the background index serving structures.
authorSam McCall <sam.mccall@gmail.com>
Tue, 9 Jul 2019 18:30:49 +0000 (18:30 +0000)
committerSam McCall <sam.mccall@gmail.com>
Tue, 9 Jul 2019 18:30:49 +0000 (18:30 +0000)
commit2f760c44e6c7472fc72808c3d6f69ad265cada42
treecf27d0d1a4d5fdb40425723edb5256ce369c1064
parent3ce33947d4f017197e4ba8f29e70d8ae76defc64
[clangd] Rewrite of logic to rebuild the background index serving structures.

Summary:
Previously it was rebuilding every 5s by default, which was much too frequent
in the long run - the goal was to provide an early build. There were also some
bugs. There were also some bugs, and a dedicated thread was used in production
but not tested.

 - rebuilds are triggered by #TUs built, rather than time. This should scale
   more sensibly to fast vs slow machines.
 - there are two separate indexed-TU thresholds to trigger index build: 5 TUs
   for the first build, 100 for subsequent rebuilds.
 - rebuild is always done on the regular indexing threads, and is affected by
   blockUntilIdle. This means unit/lit tests run the production configuration.
 - fixed a bug where we'd rebuild after attempting to load shards, even if there
   were no shards.
 - the BackgroundIndexTests don't really test the subtleties of the rebuild
   policy (for determinism, we call blockUntilIdle, so rebuild-on-idle is enough
   to pass the tests). Instead, we expose the rebuilder as a separate class and
   have fine-grained tests for it.

Reviewers: kadircet

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, jfb, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D64291

llvm-svn: 365531
clang-tools-extra/clangd/CMakeLists.txt
clang-tools-extra/clangd/ClangdServer.cpp
clang-tools-extra/clangd/ClangdServer.h
clang-tools-extra/clangd/index/Background.cpp
clang-tools-extra/clangd/index/Background.h
clang-tools-extra/clangd/index/BackgroundRebuild.cpp [new file with mode: 0644]
clang-tools-extra/clangd/index/BackgroundRebuild.h [new file with mode: 0644]
clang-tools-extra/clangd/test/background-index.test
clang-tools-extra/clangd/tool/ClangdMain.cpp
clang-tools-extra/clangd/unittests/BackgroundIndexTests.cpp