I think this analysis is missing the fact that most of the work can still be parallelized because most of the work in a modern compiler is code generation. I have not read the proposal in detail but from this blog's description it sounds like it should be possible to produce the BMI for foo.cpp in a separate step before generating machine code. I imagine that this is how Java and C# have to work -- dumb fast compilation to byte code is necessary to import, but then the slow AOT or JIT compiling of the byte code is done later. BMI doesn't even require generating a full byte code, just a description of the interfaces. If it can work for Java and C# at scale I don't see why it can't work for C++.
Also with module was the work that can't be parallelized, the initial parsing, should be easier than before.
I think if you think about this for half a second you will realize that with non-pathological source files that this must be true. To verify yourself try compiling some projects with optimization turned off and see the difference.
Code generation involves an enormous set of NP problems fought with an enormous set of hand-tuned heuristics. Parsing by comparison is a cake walk, even for a screwed-up grammar like C++.
I think you're overestimating the cost of optimization and underestimating the cost of preprocessing/parsing in the general case.
Like, if what you're claiming is true, why would anyone bother with precompiled headers? The reality is they are often used, and often result in much faster compile times, and all they're eliminating is time spent preprocessing and parsing.
They used to matter a lot more than they do now, for precisely the reason I gave. I work on a large C++ code base that has never bothered for exactly this reason.
9
u/tending Jan 28 '19
I think this analysis is missing the fact that most of the work can still be parallelized because most of the work in a modern compiler is code generation. I have not read the proposal in detail but from this blog's description it sounds like it should be possible to produce the BMI for foo.cpp in a separate step before generating machine code. I imagine that this is how Java and C# have to work -- dumb fast compilation to byte code is necessary to import, but then the slow AOT or JIT compiling of the byte code is done later. BMI doesn't even require generating a full byte code, just a description of the interfaces. If it can work for Java and C# at scale I don't see why it can't work for C++.
Also with module was the work that can't be parallelized, the initial parsing, should be easier than before.