> Cool! The numbers look pretty off, though. Starting a compiler process is
> usually considered to be pretty cheap (both gcc and clang fork a second
> process for the actual compilation for example – pas -### to see child
> processes the compiler driver starts). It's probably a bit more expensive on
> Windows, but not 1s expensive.
For Windows you are typically looking at 0.1-0.3s, but if you are
going through something like Cygwin/Mingw in the worst case you can
hit 1s.
> Also, it's true that the compiler needs to read .h files just once, but it
> can't precompile them except in special cases, since the first include in
> the two translation units could change the behavior of all #ifdefs in all
> following headers. Saving the redundant read of .h files might shave of
> fractions of a second (again, possibly a bit more on Windows).
The MSVC precompile mechanism is often used to precompile things like
system headers, so things like Windows.h are precompiled in. Most well
written libraries tend to double inclusion. You also use
precompilation very explicitly, saying which headers end up in the
precompilation file, and building that precompile file explicitly. It
also isn't semantics preserving - anything precompiled in is available
anywhere using that precompile file, even if that file doesn't include
the precompiled headers itself. While it has many weaknesses, when I
first measured it the build times on my project dropped 40%, so it is
definitely worth it. However, batching calls to cl doesn't help at
all, you just make all your .obj files depend on the .pch (precompiled
header) file, and have a rule to build the .pch - Ninja handles it
just fine already.
> I think better motivating examples are things like node.js, possibly javac,
> things that do network requests and would rather do fewer and larger
> requests, etc.
My motivating example would be anything operating over SSH. Setting up
the connection is very expensive, running multiple things on the
server is quick. If you have two rules A.txt and B.txt both of which
just get something off the same remote server batching them might be
far quicker.
Thanks, Neil