This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Partition include graph on auto-index.
ClosedPublic

Authored by kadircet on Nov 29 2018, 9:41 AM.

Details

Summary

Partitions include graphs in auto-index so that each shards contains
only part of the include graph related to itself.

Event Timeline

kadircet created this revision.Nov 29 2018, 9:41 AM
ilya-biryukov added inline comments.Nov 30 2018, 2:45 AM
clangd/index/Background.cpp
207

We should make the function static or put it into the anonymous namespace.
While here the same should be done for URIToFileCache.

210

NIT: Maybe accept a URI directly? E.g. if we ever have clients that already store a URI they won't need to do double conversions.

217

Maybe add a comment mentioning we do this merely to intern the strings?
This might be hard to follow on the first read.

385–386

Maybe also log the stats from the include graph?
It's probably less useful than symbols and refs count, but still...

388

Same here, maybe also attach some stats from the include graph?

unittests/clangd/BackgroundIndexTests.cpp
192

This sets a compile command for a directory. Should it be "root/A.cc" or am I missing something?

kadircet updated this revision to Diff 176090.Nov 30 2018, 4:44 AM
kadircet marked 7 inline comments as done.
  • Address comments
kadircet added inline comments.Nov 30 2018, 4:44 AM
unittests/clangd/BackgroundIndexTests.cpp
192

WOW! Thanks for noticing it :D It was working correctly before because we were deducing the file's absolute path from the compile command itself rather than what we've received by watching the CDB. Changed all references in the file.

ilya-biryukov added inline comments.Nov 30 2018, 9:18 AM
clangd/index/Background.cpp
70

Naming: technically the variable name should be URI, but to avoid clashing with the type name we could use U

259

Maybe use auto? The type is spelled explicitly in the rhs

260

What are the cases when it happens in practice? Do we ever run the indexer without producing the include graph?

386–391

add a comma before {3} sources?

kadircet updated this revision to Diff 176323.Dec 3 2018, 1:47 AM
kadircet marked 5 inline comments as done.
  • Address comments
clangd/index/Background.cpp
260

You are right that's not the case any more.

Everything looks good, just a single important request about testing the included files do not have any edges in the resulting graph

clangd/index/Background.cpp
79

NIT: the comment could probably be simplified to something like URIs inside nodes must point into the keys of the same IncludeGraph

386

"sources" might be a bit confusing. I'd probably use "files" instead, but that doesn't look ideal too.

unittests/clangd/BackgroundIndexTests.cpp
197

Maybe check the full shape of the graph? E.g. also add a check that A.h does not have any includes and its digest is populated.

kadircet updated this revision to Diff 176415.Dec 3 2018, 8:37 AM
kadircet marked 3 inline comments as done.
  • Addresss comments
  • Make sure there are no uninitialized values in IncludeGraphNode.
ilya-biryukov accepted this revision.Dec 4 2018, 12:57 AM

LGTM

unittests/clangd/BackgroundIndexTests.cpp
199

NIT: maybe also check the hash of A.cc is initialized (the value doesn't matter, probably, just to make sure it's not 0)?

207

NIT: maybe add a comma? A.h, B.h

This revision is now accepted and ready to land.Dec 4 2018, 12:57 AM
kadircet updated this revision to Diff 176594.Dec 4 2018, 3:33 AM
kadircet marked 2 inline comments as done.
  • Address comments
This revision was automatically updated to reflect the committed changes.