llvm-project/clang-tools-extra/clangd/index
Kadir Cetinkaya 001e88ac83
[clangd] Performance improvements and cleanup
- Inline SymbolID hashing to header
- Don't collect references for symbols without a SymbolID
- Store referenced symbols, rather than separately storing decls and
  macros.
- Don't defer ref collection to end of translation unit
- Perform const_cast when updating reference counts (~0.5% saving)
- Introduce caching for getSymbolID in SymbolCollector. (~30% saving)
- Don't modify symbolslab if there's no definition location
- Don't lex the whole file to deduce spelled tokens, just lex the
  relevant piece (~8%)

Overall this achieves ~38% reduction in time spent inside
SymbolCollector compared to baseline (on my machine :)).

I'd expect the last optimization to affect dynamic index a lot more, I
was testing with clangd-indexer on clangd subfolder of LLVM. As
clangd-indexer runs indexing of whole TU at once, we indeed see almost
every token from every source included in the TU (hence lexing full
files vs just lexing referenced tokens are almost the same), whereas
during dynamic indexing we mostly index main file symbols, but we would
touch the files defining/declaring those symbols, and lex complete files
for nothing, rather than just the token location.

The last optimization is also a functional change (added test),
previously we used raw tokens from syntax::tokenize, which didn't
canonicalize trigraphs/newlines in identifiers, wheres
Lexer::getSpelling canonicalizes them.

Differential Revision: https://reviews.llvm.org/D122894
2022-04-11 17:15:25 +02:00
..
dex [clangd] Make dexp command line options sticky 2022-03-09 13:00:25 +07:00
remote Add 'clangd' prefix to remote index proto targets 2022-01-29 02:20:52 +01:00
Background.cpp [clangd] Clean up unused includes. NFCI 2022-02-26 12:00:16 +01:00
Background.h [clangd] Clean up unused includes. NFCI 2022-02-26 12:00:16 +01:00
BackgroundIndexLoader.cpp [clangd] Clean up unused includes. NFCI 2022-02-26 12:00:16 +01:00
BackgroundIndexLoader.h [clangd] Clean up unused includes. NFCI 2022-02-26 12:00:16 +01:00
BackgroundIndexStorage.cpp [clangd] Clean up unused includes. NFCI 2022-02-26 12:00:16 +01:00
BackgroundQueue.cpp [clangd] Explicitly avoid background-indexing the same file twice. 2021-01-13 17:29:30 +01:00
BackgroundRebuild.cpp [clangd] Clean up unused includes. NFCI 2022-02-26 12:00:16 +01:00
BackgroundRebuild.h [clangd] Clean up unused includes. NFCI 2022-02-26 12:00:16 +01:00
CanonicalIncludes.cpp [clangd] Use stable keys for CanonicalIncludes mappings 2022-04-05 16:27:54 +02:00
CanonicalIncludes.h [clangd] Use stable keys for CanonicalIncludes mappings 2022-04-05 16:27:54 +02:00
FileIndex.cpp [clangd] Remove trivial uses of FileEntry::getName 2022-04-04 20:59:51 +02:00
FileIndex.h [clangd] Clean up unused includes. NFCI 2022-02-26 12:00:16 +01:00
Index.cpp [clangd] Clean up unused includes. NFCI 2022-02-26 12:00:16 +01:00
Index.h [clangd] Clean up unused includes. NFCI 2022-02-26 12:00:16 +01:00
IndexAction.cpp [clangd] Fix wrong included header. NFC 2022-02-26 14:21:52 +01:00
IndexAction.h [clangd] Clean up unused includes. NFCI 2022-02-26 12:00:16 +01:00
MemIndex.cpp [clangd] Clean up unused includes. NFCI 2022-02-26 12:00:16 +01:00
MemIndex.h [clangd] Clean up unused includes. NFCI 2022-02-26 12:00:16 +01:00
Merge.cpp [clangd] Clean up unused includes. NFCI 2022-02-26 12:00:16 +01:00
Merge.h [clangd] Clean up unused includes. NFCI 2022-02-26 12:00:16 +01:00
ProjectAware.cpp [clangd] Clean up unused includes. NFCI 2022-02-26 12:00:16 +01:00
ProjectAware.h [clangd] cleanup of header guard names 2021-12-02 15:58:35 +00:00
Ref.cpp [clangd] Avoid wasteful data structures in RefSlab::Builder 2020-05-18 22:34:59 +02:00
Ref.h [clangd] Clean up unused includes. NFCI 2022-02-26 12:00:16 +01:00
Relation.cpp [clangd] Add OverridenBy Relation to index. 2020-11-18 06:59:49 +01:00
Relation.h [clangd] Clean up unused includes. NFCI 2022-02-26 12:00:16 +01:00
Serialization.cpp [Support] Change zlib::compress to return void 2022-03-14 11:38:04 -07:00
Serialization.h [clangd] Clean up unused includes. NFCI 2022-02-26 12:00:16 +01:00
Symbol.cpp [clangd] Drop TestTUs dependency on gtest 2021-06-07 13:25:22 +02:00
Symbol.h [clangd] Clean up unused includes. NFCI 2022-02-26 12:00:16 +01:00
SymbolCollector.cpp [clangd] Performance improvements and cleanup 2022-04-11 17:15:25 +02:00
SymbolCollector.h [clangd] Performance improvements and cleanup 2022-04-11 17:15:25 +02:00
SymbolID.cpp [clangd] Performance improvements and cleanup 2022-04-11 17:15:25 +02:00
SymbolID.h [clangd] Performance improvements and cleanup 2022-04-11 17:15:25 +02:00
SymbolLocation.cpp [clangd] Avoid wasteful data structures in RefSlab::Builder 2020-05-18 22:34:59 +02:00
SymbolLocation.h [clangd] cleanup of header guard names 2021-12-02 15:58:35 +00:00
SymbolOrigin.cpp [clangd] Extend SymbolOrigin, stop serializing it 2022-01-13 08:26:12 +01:00
SymbolOrigin.h [clangd] Extend SymbolOrigin, stop serializing it 2022-01-13 08:26:12 +01:00
YAMLSerialization.cpp [clangd] Clean up unused includes. NFCI 2022-02-26 12:00:16 +01:00