www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Can DUB --combined builds be faster?

reply Guillaume Piolat <contact gam3sfrommars.fr> writes:
I'm cargo-culting the use of --combined with DUB because I 
somehow think inlining will be better in this way. (For thos who 
don't use DUB, what it does is compiling the whole program with a 
single compiler invokation instead of making one static library 
by package.)

But I've never measured much speed-up that way so I wonder if 
it's a dumb thing to do.

Is there a theoretical reason --combined builds may be faster?
Mar 14 2016
parent reply Rene Zwanenburg <renezwanenburg gmail.com> writes:
On Monday, 14 March 2016 at 11:03:41 UTC, Guillaume Piolat wrote:
 I'm cargo-culting the use of --combined with DUB because I 
 somehow think inlining will be better in this way. (For thos 
 who don't use DUB, what it does is compiling the whole program 
 with a single compiler invokation instead of making one static 
 library by package.)

 But I've never measured much speed-up that way so I wonder if 
 it's a dumb thing to do.

 Is there a theoretical reason --combined builds may be faster?
It shouldn't make a difference for the resulting executable, but compilation itself may be faster. I did a little test just to be sure. Two DUB packages, one with: module m; string foo() { return "asdf"; } And the other: import m; import std.stdio; void main() { writeln(foo()); } When building in release mode the call to foo() gets inlined just fine without --combined.
Mar 14 2016
next sibling parent Guillaume Piolat <name.lastname gmail.com> writes:
On Monday, 14 March 2016 at 11:50:38 UTC, Rene Zwanenburg wrote:
 It shouldn't make a difference for the resulting executable, 
 but compilation itself may be faster. I did a little test just 
 to be sure. Two DUB packages, one with:

 module m;
 string foo() { return "asdf"; }

 And the other:
 import m;
 import std.stdio;
 void main() { writeln(foo()); }

 When building in release mode the call to foo() gets inlined 
 just fine without --combined.
Thanks for the test!
Mar 14 2016
prev sibling parent reply thedeemon <dlang thedeemon.com> writes:
On Monday, 14 March 2016 at 11:50:38 UTC, Rene Zwanenburg wrote:

 When building in release mode the call to foo() gets inlined 
 just fine without --combined.
How does it work? Is it because the source of foo() is visible to the compiler when producing the result?
Mar 14 2016
parent Chris Wright <dhasenan gmail.com> writes:
On Tue, 15 Mar 2016 01:54:51 +0000, thedeemon wrote:

 On Monday, 14 March 2016 at 11:50:38 UTC, Rene Zwanenburg wrote:
 
 When building in release mode the call to foo() gets inlined just fine
 without --combined.
How does it work? Is it because the source of foo() is visible to the compiler when producing the result?
Yes.
Mar 14 2016