<div dir="auto"><span class="gmail_chip gmail_plusreply" dir="auto"><a href="mailto:clangd-dev@lists.llvm.org" style="color:#15c;text-decoration:underline">+clangd-dev@lists.llvm.org</a></span><span> </span></div><br><div class="gmail_quote"><div dir="ltr">On Tue, Nov 6, 2018, 19:23 David Blaikie via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Thanks for sending this out!<br><br>Yeah, I'm super interested in how (future standard) C++ modules will interact with build systems, as it's unlikely to be feasible to use an implicit compilation model (in part because of the code generation/linkage requirements - you could put everything from a C++ Modules definition in comdats, etc as is done for headers today (rather than in separate object files), but not really how it's meant to work).<br><br>All models boil down to something like this - the build system having some explicit knowledge (through library dependencies within a project) and having to do some discovery (to find external dependencies (the standard library (if/once modularized and used as such), other external libraries written using modules) and to reduce internal dependencies (not all code in one library depends on all the libraries that library depends on - so by discovering the specific modular imports used in a given module, that module may be able to be built sooner (when only some of its libraries dependencies have been built, because it only needs that subset)) before executing any compilation steps (& then, ideally, passing around the compilation inputs/outputs rather than relying on the compiler to discover them itself in a cache directory or the like).<br><br>You mentioned a few performance metrics<br>Up to 10x speedup in non-modular dependency scanning - what do you mean by non-modular dependency scanning? (what's the non-modular part - in contrast to?)<br>4x when run on the first 1000 files in Clang's compilation database, compared to clang -Eonly - so this is running the whole tool, including generating the trimmed preprocessed files, and then reading those to discover the header module dependencies, compared to running -Eonly, then scanning those files? & the output is currently in what form? .d-like files?<br><br>You mention relying on the compilation database for discovering the files to run over - is this the long term goal/design, or a current stepping stone? I was about to say that seems circular (thinking that the compiler/compilation phase generates the compilation database) but then realized/remembered that it's the build system that generates that, not the compiler, so you can have/use/run over the compilation database before compilation has begun. Sounds good. So the build system would have to have a phase that runs after generating the compilation database that runs this tool, then adds the module compilations produced by this tool to the list of commands it will execute (& probably also adds them back into the compilation database, too, really).<br><br>So, as you mentioned (maybe in the phab review), the format of the output of this tool is still unknown, but the input is currently a (currently the classic json, I assume - but if the tool uses the compilation database access APIs, other sources implemented in that API could be used) compilation database - cool cool.<br><br>Thanks again!<br><br>- Dave</div><br><div class="gmail_quote"><div dir="ltr">On Tue, Oct 16, 2018 at 6:53 PM Alex L <<a href="mailto:arphaman@gmail.com" target="_blank" rel="noreferrer">arphaman@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div dir="ltr"><p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:"Helvetica Neue"">Hi,</p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:"Helvetica Neue";min-height:14px"><br></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:"Helvetica Neue"">Bruno (CCed), Duncan (CCed) and I have been exploring if we can migrate some of our clients to explicit modules. As part of this work Duncan and I developed a new prototype dependency scanning service tool (clang-scan-deps) that computes the set of file dependencies for a particular compiler invocation using some optimizations that are outlined below. This tool makes the non-modular dependency scanning up to 10 times faster for particular workloads (e.g. llc target, 1542 C++ files) on one of our machines, when compared to parallel invocations of clang with -Eonly. We are still in the early stages of proper modules support, but our initial crude prototype can get up to 4x when run on the first 1000 files from clang’s compilation database for a build of LLVM with modules turned on.</p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:"Helvetica Neue";min-height:14px"><br></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:"Helvetica Neue"">We still run the full Clang preprocessor. Here’s what we do to reduce its workload:</p>
<ul>
<li style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:"Helvetica Neue"">Minimize sources by stripping away unused tokens. We keep only the interesting PP directives (#define, #if, #include, etc.), i.e. those that might impact the set of dependencies. </li>
<li style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:"Helvetica Neue"">Assume the filesystem is immutable for one run of the service, and cache the files and their minimized contents in memory in a global cache.</li>
<li style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:"Helvetica Neue"">Skip over excluded preprocessor ranges by bumping up the buffer pointer in the lexer instead of lexing the skipped tokens.</li>
</ul>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:"Helvetica Neue";min-height:14px"><br></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:"Helvetica Neue"">We intend to upstream this service in the upcoming months. We also would like to integrate this service into Clangd as part of our migration to Clangd to help us determine a good compilation command for a header file from a set of known compilation invocations.</p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:"Helvetica Neue";min-height:14px"><br></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:"Helvetica Neue"">I posted a very rough WIP patch on Phabricator (<a href="https://reviews.llvm.org/D53354" target="_blank" rel="noreferrer"><span style="color:rgb(220,161,13)">https://reviews.llvm.org/D53354</span></a>). It’s based on LLVM checkout r343343. Please take a look if you’re interested.</p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:"Helvetica Neue"">Duncan, Bruno and I will be at the LLVM dev meeting. We are interested in discussing this prototype and collecting feedback from anyone who might be interested in this work.</p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:"Helvetica Neue";min-height:14px"><br></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:"Helvetica Neue"">Thanks,</p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:"Helvetica Neue"">Alex</p></div></div>
</blockquote></div>
_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org" target="_blank" rel="noreferrer">cfe-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br>
</blockquote></div>