<div dir="ltr">Just to add on what Ilya said.<div><br></div><div>> Note that both indexes store absolute paths, so sharing the produced index across multiple machines would only be possible if the directory structure is kept the same.</div><div>> If having the same directory structure is plausible, please try it out and let us know if it works, we haven't tried sharing the same index across multiple machines.</div><div>Paths are stored as URI in the index. By default, "file" scheme is used, so URI would simply be absolute path (e.g. file:///user/home/llvm/x/y.h). But you could also define your own URI schemes. For example, you can choose to store relative paths in the URI (e.g. llvm:///x/y.h) in a custom scheme, and they can be resolved with potentially different project roots on users' machines to get correct full paths. For more information, please take a look at clangd/URI.h library. You could also find some sample URIScheme implementations in unit tests.</div><div><br></div><div>Cheers,</div><div>Eric</div><br class="gmail-Apple-interchange-newline"></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Apr 3, 2019 at 10:27 AM Ilya Biryukov via clangd-dev <<a href="mailto:clangd-dev@lists.llvm.org">clangd-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr">Hi William,<div><br></div><div>The difference between background-indexer and clangd-indexer is the layout of the output:</div><div>- background-indexer would put the resulting index into the folder <project-root>/.clangd/index.</div><div>  The index is split per-file, i.e. it's incremental and clangd would be able to update the files that changed after the index was built.</div><div>  You would need to run clangd with '-background-index' to load the index, it will also automatically update the index for files that changed on load.</div><div>- clangd-indexer would produce a <b>merged </b>index, it can't be incrementally updated and you have more control for the location of the output:</div><div>  ./bin/clangd-indexer -executor=all-TUs path/to/compile_commands.json > path/to/output.riff<br></div><div>  You would need to run clangd with '-index-file=path/to/output.riff' to load the index.</div><div><br></div><div>Note that both indexes store absolute paths, so sharing the produced index across multiple machines would only be possible if the directory structure is kept the same.</div><div>If having the same directory structure is plausible, please try it out and let us know if it works, we haven't tried sharing the same index across multiple machines.</div><div><br></div><div>Which option to prefer? Depending on your situation, either of the two might be better:</div><div>- If you always want an up-to-date index and storing the shared snapshot is just a performance optimization, use background-indexer.</div><div>- If you not wasting resources to rebuild the index for changed files is more important than the fact that some results are stale (e.g. it's too expensive, you want to save laptop battery, etc.), clangd-indexer might be a better choice.</div><div><br></div><div>Here's a short summary on what each index means:</div><div>- Static index is an index that is persisted across multiple runs of clangd. There are two flavours of it:</div><div>  1. Background index. Incremental (split per-file) index living in '<project-root>/.clangd/index'.  Built automatically by clangd when -background-index is specified. Long-term, we want this to be enabled by default (and possibly be the only option).</div><div>  2. Old-style "merged" index produced by clangd-indexer. The results will not get updated by clangd automatically, you can ask clangd to load it with '-index-file=path/to/index.riff'. </div><div>- Dynamic index is an overlay for a small number of updated files (currently the open files for which we built the AST). Kept in memory, not persisted across multiple runs. We use to adjust for the fact that static index might be stale. We want the correct results for the open files in all cases.</div><div>- Dex is an efficient implementation of running search queries (e.g. it models fuzzy-matching algorithm, etc.). It's an "index" in an information retrieval sense, it is not actually specific to C++ or clangd.</div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Apr 1, 2019 at 6:36 PM William Wagner (BLOOMBERG/ 731 LEX) via clangd-dev <<a href="mailto:clangd-dev@lists.llvm.org" target="_blank">clangd-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div class="gmail-m_-4105990047554174080gmail-m_-9189427934623238491rte-style-maintainer gmail-m_-4105990047554174080gmail-m_-9189427934623238491rte-pre-wrap" style="font-family:Arial,"BB.Proportional";white-space:pre-wrap;font-size:small"><div>Hello!</div><div><br></div><div>I work on a fairly large C++ project and wanted to figure out a way to regularly build (e.g. nightly via Jenkins) a global project index that can be shared with all the members of my team. I want to share it because it takes a fairly long time to build the index after starting up, and it seems pretty redundant to have each team member doing so, seeing as most of the code is not changing on a day-to-day basis. I’ve tried peeking around the mailing lists and commit history of clangd, but I’m not sure whether this is possible yet - and if it was, what flags to use, what indexer etc.</div><br><div>I see there’s background-indexer WIP (<a href="https://reviews.llvm.org/D59605" target="_blank"><span>https://reviews.llvm.org/D59605</span></a>) and an existing clangd-indexer <a href="https://github.com/llvm-mirror/clang-tools-extra/blob/master/clangd/indexer/IndexerMain.cpp" target="_blank"><span>https://github.com/llvm-mirror/clang-tools-extra/blob/master/clangd/indexer/IndexerMain.cpp</span></a></div><div>What is the difference between these?</div><br><div>Additionally, if anyone could provide some clarification on the different types of indexes clangd currently has (dex, background, static, etc.) that would be great :)</div><br><div>Thanks!</div><div><br></div></div></div>_______________________________________________<br>
clangd-dev mailing list<br>
<a href="mailto:clangd-dev@lists.llvm.org" target="_blank">clangd-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/clangd-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/clangd-dev</a><br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail-m_-4105990047554174080gmail_signature"><div dir="ltr"><div><div dir="ltr"><div>Regards,</div><div>Ilya Biryukov</div></div></div></div></div>
_______________________________________________<br>
clangd-dev mailing list<br>
<a href="mailto:clangd-dev@lists.llvm.org" target="_blank">clangd-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/clangd-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/clangd-dev</a><br>
</blockquote></div>