This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Explicitly avoid background-indexing the same file twice.
ClosedPublic

Authored by sammccall on Jan 12 2021, 8:48 AM.

Details

Summary

This used to implicitly never happen due to only discovering each CDB once.

We may want to carefully support reindexing one day, but we need to do it carefully (tricky tradeoffs) and it would need further support in background indexer.

Making this explicit here rather than just turning off rebroadcast in background index for a few reasons:

  • allows *new* files in the same CDB to be indexed
  • relying on bugs-at-a-distance cancelling each other out is bound to bite us
  • gets us closer to actually supporting reindexing, which requires similar tracking

Diff Detail

Event Timeline

sammccall created this revision.Jan 12 2021, 8:48 AM
sammccall requested review of this revision.Jan 12 2021, 8:48 AM
sammccall retitled this revision from [clangd] Avoid having the same file in the queue twice in the background index. (For future reference. We decided not to do this for now in favor of simply not re-indexing the same CDB multiple times, as too much infrastructure needs to be... to [clangd] Avoid having the same file in the queue twice in the background index..
sammccall edited the summary of this revision. (Show Details)

In fact, never index the same file twice at all.

sammccall retitled this revision from [clangd] Avoid having the same file in the queue twice in the background index. to [clangd] Explicitly avoid background-indexing the same file twice..Jan 12 2021, 10:13 AM
sammccall edited the summary of this revision. (Show Details)
sammccall added a reviewer: kadircet.
kadircet accepted this revision.Jan 13 2021, 12:34 AM

thank, as discussed offline this looks like the right thing to do before the branch cut. we might re-evaluate our decision around re-indexing on cmd changes and canonicalization one day ...

LGTM! (with some small comments)

clang-tools-extra/clangd/index/Background.cpp
143–144

nit: while here can we s/Cmd/FilePath ?

144

why do we drop std::move here ? these are strings in the end and indexFileTask is still expecting a value not a reference.

360

nit: might be nice to have this in a separate patch

clang-tools-extra/clangd/index/Background.h
222

i suppose this is no longer needed ?

clang-tools-extra/clangd/unittests/BackgroundIndexTests.cpp
848

both As are dropped here right ? not just one.

This revision is now accepted and ready to land.Jan 13 2021, 12:34 AM
This revision was automatically updated to reflect the committed changes.
sammccall marked 5 inline comments as done.