Practical parallelization of D compilation
Chris Katko
ckatko at gmail.com
Wed Jan 8 09:13:18 UTC 2020
On Wednesday, 8 January 2020 at 06:51:57 UTC, H. S. Teoh wrote:
> On Wed, Jan 08, 2020 at 04:40:02AM +0000, Guillaume Lathoud via
> Digitalmars-d-learn wrote:
>> [...]
> [...]
>
> Generally, the recommendation is to separately compile each
> package. E.g., if you have a source tree of the form:
>
> src/
> src/main.d
> src/pkg1/mod1.d
> src/pkg1/mod2.d
> src/pkg2/mod3.d
> src/pkg2/mod4.d
>
> then you'd have 3 separate compilations:
>
> dmd -ofpkg1.o src/pkg1/mod1.d src/pkg1/mod2.d
> dmd -ofpkg2.o src/pkg2/mod3.d src/pkg2/mod4.d
> dmd -ofmyprogram src/main.d pkg1.o pkg2.o
>
> The first two can be done in parallel, since they are
> independent of each other.
>
> The reason per-package granularity is suggested is because the
> accumulated overhead of separately compiling every file makes
> it generally not worth the effort. D compiles fast enough that
> per-package compilation is still reasonably fast, but you no
> longer incur as much overhead from separately compiling every
> file, yet you still retain the advantage of not recompiling the
> entire program after every change.
>
> (Of course, the above example is greatly simplified; generally
> you'd have about 10 or more files per package, and many more
> packages, so the savings can be quite significant.)
>
>
> T
What's the downsides / difficulties / "hoops to jump through"
penalty for putting code into modules instead of one massive
project? Is it just a little extra handwriting/boilerplate, or is
there a performance impact talking to other modules vs keeping it
all in one?
More information about the Digitalmars-d-learn
mailing list