Reducing StdlibUnittest compile time


(Dmitri Gribenko) #1

Hi,

StdlibUnittest is an internal library that we use to write tests for the
standard library, and some parts of the runtime and the compiler (for example,
the implementation of bridging for Objective-C collections). We heavily rely
on these tests to check correctness of the Swift compiler and standard library.

But there is an issue: today, StdlibUnittest takes a long time to build.
The following table shows the time it takes to build StdlibUnittest.

Compiler Library StdlibUnittest build time
ReleaseAssert Release 1m 43s
ReleaseAssert ReleaseAssert 4m 26s
DebugAssert DebugAssert 2m 25s

I investigated the issue a little bit, and I moved the code that tests
sequences and collections into a new library, StdlibCollectionUnittest, which
only gets built when validation tests are run.

Compiler Library StdlibUnittest StdlibCollectionUnittest
                            build time build time
ReleaseAssert Release 30s 58s
ReleaseAssert ReleaseAssert 1m 10s 1m 20s
DebugAssert DebugAssert 53s 50s

These time measurements show that the build time of the combined module is
greater than the sum of the build times of the pieces, and much more so when
the optimization is turned on. We can make a conjecture that the optimizer is
not scaling well with the module size.

The last commit before the library split was
8aebe8d864ea6094355b365e0f505bb117e29304. It would be great if someone could
look into the compiler issue.

Dmitri

···

--
main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
(j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr@gmail.com>*/