This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Proof of concept: indexing after the preamble is built
DraftPublic

Authored by sammccall on Dec 14 2021, 4:49 PM.
This is a draft revision that has not yet been submitted for review.

Details

Reviewers
None
Summary

We can use this technique to take preamble indexing off the critical path on startup.

Diff Detail

Unit TestsFailed

Event Timeline

sammccall created this revision.Dec 14 2021, 4:49 PM

@kadircet FYI this demonstrates how to extend the lifetime of the preamble AST beyond building the preamble, which would allow us to take preamble indexing off the critical path.
It's pretty hacky, but the doc comments on CompilerInstance more or less suggest this sort of thing!

In reality I imagine this looking more like: pass the whole CompilerInstance to the PreambleCallback, and have ClangdServer do the lifetime extension and throw the AliveAST struct onto a queue.
This ends up resembling https://reviews.llvm.org/D115232 a little bit, and they should share queues I think. So maybe I shouldn't develop this further until that one lands in some form.

nridge added a subscriber: nridge.Dec 19 2021, 2:48 PM

When you say "take preamble indexing off the critical path on startup", do you mean the first time a file is opened in general? Or is this specific to startup somehow?