This is an archive of the discontinued LLVM Phabricator instance.

[clangd] BackgroundIndex stores shards to the closest project
ClosedPublic

Authored by kadircet on Jul 15 2019, 7:46 AM.

Details

Summary

Changes persistance logic to store shards at the directory of closest
CDB. Previously we were storing all shards to directory of the CDB that
triggered indexing, it had its downsides.

For example, if you had two TUs coming from a different CDB but depending on the
same header foo.h, we will store the foo.h only for the first CDB, and it would
be missing for the second and we would never persist it since it was actually
present in the memory and persisted before.

This patch still stores only a single copy of a shard, but makes the directory a
function of the file name. So that the shard place will be unique even with
multiple CDBs accessing the file. This directory is determined as the first
directory containing a CDB in the file's parent directories, if no such
directory exists we make use of the home directory.

Diff Detail

Repository
rL LLVM

Event Timeline

kadircet created this revision.Jul 15 2019, 7:46 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 15 2019, 7:46 AM
sammccall accepted this revision.Jul 18 2019, 9:14 AM

LG apart from the second global CDB

clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp
128 ↗(On Diff #209860)

Why does this have its own CDB? AFAICS it can use the shared CDB, possibly indirecting through a std::function

149 ↗(On Diff #209860)

This assertion will be hit if home_directory() fails. It shouldn't, but... maybe keep the "return nullstorage" to cover this case (and also the assert?)

This revision is now accepted and ready to land.Jul 18 2019, 9:14 AM
kadircet updated this revision to Diff 210621.Jul 18 2019, 10:07 AM
kadircet marked 3 inline comments as done.
  • Address comments
kadircet added inline comments.Jul 18 2019, 10:07 AM
clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp
149 ↗(On Diff #209860)

elog'ing instead of assertion, since this indeed happens in one of our lit-tests

This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptJul 18 2019, 10:24 AM
clang-tools-extra/trunk/clangd/index/BackgroundIndexStorage.cpp