This is an archive of the discontinued LLVM Phabricator instance.

Speed up modules compilation.
ClosedPublic

Authored by klimek on May 5 2015, 8:07 AM.

Details

Reviewers
djasper
rsmith
Summary

Allow skipping children in the module visitor and use that to speed up
decl-chain loading.

Diff Detail

Event Timeline

klimek updated this revision to Diff 24947.May 5 2015, 8:07 AM
klimek retitled this revision from to Speed up modules compilation..
klimek updated this object.
klimek edited the test plan for this revision. (Show Details)
klimek added reviewers: rsmith, djasper.
klimek added a subscriber: Unknown Object (MLST).
silvas added a subscriber: silvas.May 6 2015, 12:45 PM

Numbers on the speedup?

Numbers on the speedup?

On my tests this is a 40% speedup for a TU using ~1000 transitive modules. I didn't include the number in the description because it is misleading; we are still merging too much, and we have merging-heavy TUs.

rsmith accepted this revision.May 19 2015, 1:30 PM
rsmith edited edge metadata.

Essentially this seems fine. It'd be better if visitDepthFirst didn't actually walk the the entire module graph in the case where it's been told to SkipChildren, but we can leave that improvement for a later change.

include/clang/Serialization/ModuleManager.h
297–300

These parameters seem backwards to me (on each node, we'll call the preorder visitor before the postorder one, so it would seem more natural for the preorder one to be written first in a call to this function).

lib/Serialization/ASTReaderDecl.cpp
3374

Children here is ambiguous, and entirely backwards from the way I think of the imports graph (where the roots import nothing and the leaves are not imported by anything). Calling this Imports would remove the ambiguity (likewise in the DFSPreorderControl enum).

3387–3389

A comment explaining what's going on here ("we don't need to visit a module or any of its imports if we've already deserialized the redecls from this module") would help.

This revision is now accepted and ready to land.May 19 2015, 1:30 PM
klimek updated this revision to Diff 26138.May 20 2015, 3:26 AM
klimek edited edge metadata.

Review comments.

Essentially this seems fine. It'd be better if visitDepthFirst didn't actually walk the the entire module graph in the case where it's been told to SkipChildren, but we can leave that improvement for a later change.

I'm not sure how that would be possible due to imports building a DAG.
The trade-off seems to be: either we remember the knowledge that all transitive deps do not need to be visited, or we might have to re-calculate that information when we come in via a different edge. My experiments indicate that the latter is common enough to offset the cost of the former.

include/clang/Serialization/ModuleManager.h
297–300

... says the person whose trees grow upside-down ;) Done.

lib/Serialization/ASTReaderDecl.cpp
3374

Note that there is precedence in the ModuleManager.h of calling the imports "children" :P
Your trees grow the wrong way (granted, this isn't *really* a tree).
On the other hand, "imports" is clearly the better name, so Done :D

3387–3389

Done.

klimek closed this revision.Jul 2 2015, 6:47 AM