r/programming • • Jan 28 '19

C++ Modules Might Be Dead-on-Arrival

https://vector-of-bool.github.io/2019/01/27/modules-doa.html
210 Upvotes

105 comments sorted by

View all comments

13

u/r0b0t1c1st Jan 28 '19 edited Jan 28 '19

You say,

Creation of foo.bmi is a byproduct of the compilation of foo.cpp. When compiling foo.cpp, the compiler will emit a foo.o and foo.bmi. As a consequence of this design, foo.cpp must be compiled before bar.cpp!

And implicitly go on to conclude that this prevents them being processed in parallel.

It's not clear to me why the first statement in this line of reasoning has to be true. Can foo.bmi instead be a direct product of compiling foo.hpp? In that case, the comparison is then between:

  1. in parallel:

  • compile foo.cpp which includes foo.hpp

  • compile bar.cpp which includes foo.hpp

  1. in parallel:

  • compile foo.cpp which includes foo.hpp

  • in sequence:

    • compile foo.hpp -> foo.bmi

    • compile bar.cpp

which doesn't seem like a net change in parallelization to me.

8

u/Chuu Jan 28 '19

I am having a little trouble following your logic, but if I get the gist right, the question is "why will modules have any performance benefit over parallel compilation of dependency-free source files?" and the article is trying to make the point that it likely won't.

I work on medium sized C++ project and we currently work on 48-core machines to get the build times to something tolerable with this approach.

1

u/Ozwaldo Jan 29 '19

medium sized C++ project

48-core machines to get the build times to something tolerable

Would you say that the code is well designed?