[PATCH] D40897: [clangd] Introduce a "Symbol" class.

Marc-Andre Laperle via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Dec 7 09:44:25 PST 2017


malaperle added inline comments.


================
Comment at: clangd/Symbol.h:37
+// The class presents a C++ symbol, e.g. class, function.
+struct Symbol {
+  // The symbol identifier, using USR.
----------------
sammccall wrote:
> hokein wrote:
> > malaperle wrote:
> > > I think it would be nice to have methods as an interface to get this data instead of storing them directly. So that an index-on-disk could go fetch the data. Especially the occurrences which can take a lot of memory (I'm working on a branch that does that). But perhaps defining that interface is not within the scope of this patch and could be better discussed in D40548 ?
> > I agree. We can't load all the symbol occurrences into the memory since they are too large. We need to design interface for the symbol occurrences. 
> > 
> > We could discuss the interface here, but CodeCompletion is the main thing which this patch focuses on. 
> > We can't load all the symbol occurrences into the memory since they are too large
> 
> I've heard this often, but never backed up by data :-)
> 
> Naively an array of references for a symbol could be doc ID + offset + length, let's say 16 bytes.
> 
> If a source file consisted entirely of references to 1-character symbols separated by punctuation (1 reference per 2 bytes) then the total size of these references would be 8x the size of the source file - in practice much less. That's not very big.
> 
> (Maybe there are edge cases with macros/templates, but we can keep them under control)
I'd have to break down how much memory it used by what, I'll come back to you on that. Indexing llvm with ClangdIndexDataStorage, which is pretty packed is about 200MB. That's already a lot considering we want to index code bases many times bigger. But I'll try to come up with more precise numbers. I'm open to different strategies.



Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D40897





More information about the cfe-commits mailing list