This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Rewrite of logic to rebuild the background index serving structures.
ClosedPublic

Authored by sammccall on Jul 6 2019, 1:40 PM.

Details

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.

Diff Detail

Repository
rL LLVM

Event Timeline

sammccall created this revision.Jul 6 2019, 1:40 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 6 2019, 1:40 PM
sammccall updated this revision to Diff 208282.Jul 6 2019, 1:48 PM

Fix broken format string

kadircet accepted this revision.Jul 9 2019, 2:53 AM

LGTM

clang-tools-extra/clangd/index/Background.cpp
186 ↗(On Diff #208282)

clang-format

clang-tools-extra/clangd/index/Background.h
141 ↗(On Diff #208282)
  • do we really want to make 5 and 100 hardcoded in the comments?
  • what about moving this class and its implementation to different header/source files?
This revision is now accepted and ready to land.Jul 9 2019, 2:53 AM
sammccall updated this revision to Diff 208756.Jul 9 2019, 11:27 AM
sammccall marked 3 inline comments as done.

Address comments

This revision was automatically updated to reflect the committed changes.