This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Simpler/more compact in-memory representation of RefSlab/Builder
Needs ReviewPublic

Authored by sammccall on Jul 8 2019, 1:29 AM.

Details

Reviewers
hokein
Summary

This reduces the total CPU time for readRIFF by >50%
It also reduces the memory size of the index by 3%.

For context, before this change: preparing the background index is around:

  • 15% computing SHA1 of files to check index validity
  • 30% readRIFF
  • 50% building serving structures afterwards

Diff Detail

Event Timeline

sammccall created this revision.Jul 8 2019, 1:29 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 8 2019, 1:29 AM
hokein added a comment.Jul 8 2019, 4:36 AM

just some nits to make the code more understandable.

clang-tools-extra/clangd/index/Ref.cpp
36–48

before this changes, we were doing deduplications on the fly, now we deduplicate them only at the final/reducing stage.

Note that with this patch, clangd-indexer will be OOMed when indexing large scale projects like chromium, but I think clangd-indexer is not a tool we'd recommend users to use, that's probably fine?

60

nit: explicitly set the default value to false;

could we split the two variables into two lines? I felt inlining them into one line hurts the code readability (I have thought NewRef is one of the constructor parameters).

88

nit: we have two seconds in the loop body, they means different kinds (I have to go-back-and-forth to understand the code here). Could we explicitly make StoredSymbol a structure?

clang-tools-extra/clangd/index/Ref.h
124

could we have some documentations here?

sammccall planned changes to this revision.Jul 8 2019, 11:25 AM
sammccall marked 3 inline comments as done.
sammccall added inline comments.
clang-tools-extra/clangd/index/Ref.cpp
36–48

Ugh, you're right - those are huge slabs with lots of duplication.

I mean, in principle we could document the limitation here and add a deduplicating map there (that site isn't very performance-sensitive). But that's kind of a mess. Let me think about this one.

sammccall updated this revision to Diff 208464.Jul 8 2019, 11:26 AM

clang-format and address comment