D compiles fast, right? Right??

Steven Schveighoffer schveiguy at yahoo.com
Mon Apr 2 19:28:02 UTC 2018


On 4/2/18 8:33 AM, Atila Neves wrote:

> No... that's ~11.583x with no unittests and ~43.75x with. The former 
> number not being interesting to me in the slightest.

Here is an interesting tidbit as well -- importing with -unittest takes 
4x as long AND NO CODE IS GENERATED OR WILL EVER BE GENERATED. 
Literally, the compiler is parsing, semantically analyzing, consuming 
300% more cycles just to "compile" code it will never actually use or 
generate files for, and as far as I know, it has no way of doing so.

I did a simple test:

dmd -c -v testpath.d | grep import | wc -l
60
dmd -c -v -unittest testpath.d | grep import | wc -l
87

So there are 27 more modules processed by DMD that make this 300% 
increase happen (Not to mention, ~60 imports for building paths...). 
Doing some bash-script work, I get the following differences

 > import    core.atomic
 > import    core.bitop
 > import    core.checkedint
 > import    core.math
 > import    core.stdc.fenv
 > import    core.stdc.math
 > import    core.sync.exception
 > import    core.sync.mutex
 > import    core.sys.darwin.mach.port
 > import    core.sys.darwin.mach.thread_act
 > import    core.sys.darwin.pthread
 > import    core.sys.posix.pthread
 > import    core.sys.posix.sched
 > import    core.sys.posix.semaphore
 > import    core.sys.posix.stdlib
 > import    core.sys.posix.sys.wait
 > import    core.thread
 > import    std.algorithm
 > import    std.algorithm.internal
 > import    std.algorithm.setops
 > import    std.algorithm.sorting
 > import    std.bitmanip
 > import    std.math
 > import    std.process
 > import    std.random
 > import    std.system
 > import    std.utf

One disconcerting thing here is, not all of these imports come from 
std.path. Some of them come from unit tests in modules imported by 
std.path unittests. Because inside a unit test you want to have free 
access to all of phobos to do whatever the hell you want for testing, 
it's quite easy to import ALL of phobos when you do unit tests.

We really need to change the unittest import strategy.

-Steve


More information about the Digitalmars-d mailing list