[clangd] BackgroundIndex stores shards to the closest project
authorKadir Cetinkaya <kadircet@google.com>
Thu, 18 Jul 2019 17:20:41 +0000 (17:20 +0000)
committerKadir Cetinkaya <kadircet@google.com>
Thu, 18 Jul 2019 17:20:41 +0000 (17:20 +0000)
commit006d1915e2defce50c05de5ba83727814e2ac11c
tree303ede35bfa088c1d9e8a48f390dfa6e730addc9
parentc2ccf4ccba295b1300018e65c658ff305992aa29
[clangd] BackgroundIndex stores shards to the closest project

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.

Reviewers: sammccall

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits

Tags: #clang

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

llvm-svn: 366467
clang-tools-extra/clangd/ClangdServer.cpp
clang-tools-extra/clangd/index/Background.cpp
clang-tools-extra/clangd/index/Background.h
clang-tools-extra/clangd/index/BackgroundIndexLoader.cpp
clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp
clang-tools-extra/clangd/test/Inputs/background-index/definition.jsonrpc
clang-tools-extra/clangd/test/Inputs/background-index/foo.cpp
clang-tools-extra/clangd/test/Inputs/background-index/sub_dir/compile_flags.txt [new file with mode: 0644]
clang-tools-extra/clangd/test/Inputs/background-index/sub_dir/foo.h [moved from clang-tools-extra/clangd/test/Inputs/background-index/foo.h with 100% similarity]
clang-tools-extra/clangd/test/background-index.test