This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Skip function bodies inside processed files while indexing
ClosedPublic

Authored by ilya-biryukov on Aug 14 2019, 9:16 AM.

Details

Summary

This significantly improves performance of background indexing.

We do not collect references and declarations inside the processed
files, so this does not affect the final indexing results.

The idea is borrowed from libclang, which has a similar optimization in
its indexing functionality.

Measurements show a nice decrease in indexing time, up to ~40% for
building the whole index. These are not proper benchmarks, so one should
not rely on these results too much.

  1. Rebuilding the whole index for LLVM:
    • Before. Total time: 14m58s. ./bin/clangd -pch-storage=memory < ./clangd.input 23917.67s user 515.86s system 2718% cpu 14:58.68 total
    • After. Total time: 8m41s. ./bin/clangd -pch-storage=memory < ./clangd.input 13627.29s user 288.10s system 2672% cpu 8:40.67 total
  1. Rebuilding index after removing shards matching '*clangd*' (case-insensitively):
    • Before. Total time: 30s. ./bin/clangd -pch-storage=memory < ./clangd.input 130.94s user 6.82s system 452% cpu 30.423 total
    • After. Total time: 26s. ./bin/clangd -pch-storage=memory < ./clangd.input 80.51s user 5.40s system 333% cpu 25.777 total

Diff Detail

Repository
rL LLVM

Event Timeline

ilya-biryukov created this revision.Aug 14 2019, 9:16 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 14 2019, 9:16 AM
ilya-biryukov edited the summary of this revision. (Show Details)Aug 14 2019, 9:16 AM

This looks great, thanks!

clang-tools-extra/clangd/index/SymbolCollector.cpp
745 ↗(On Diff #215139)

we already have shouldIndexFile as an anonymous function inside this file, which performs a similar operation with a cache (since FileFilter performs symlink resolution and a disk read).

Could you make that one a member instead and use it?

  • Expose the existing helper instead of introducing a new one
ilya-biryukov marked 2 inline comments as done.Aug 20 2019, 1:31 AM
ilya-biryukov added inline comments.
clang-tools-extra/clangd/index/SymbolCollector.cpp
745 ↗(On Diff #215139)

Thanks, did not notice it on the first go. Done.

ilya-biryukov marked an inline comment as done.Aug 20 2019, 1:32 AM
kadircet accepted this revision.Aug 20 2019, 1:37 AM
kadircet added inline comments.
clang-tools-extra/clangd/index/IndexAction.cpp
194 ↗(On Diff #216066)

nit: can you make these non-doxygen(just two slashes)?

This revision is now accepted and ready to land.Aug 20 2019, 1:37 AM
ilya-biryukov marked an inline comment as done.
  • Change / to
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptAug 20 2019, 1:55 AM