Share your compile times

The subject has been brought up a few times in the past and I’m curious what is everybody’s experiences.
My application takes a little under 4 minutes (without --release) and about an hour (with --release), with 260.490 LOC (poor metric, but what else is there) under WSL and an i7-8700.

Anyone who’s willing to share, go ahead.

2200 LoC compiles in 2 seconds without and 39 with --release.

Funny, that almost scales linearly with your 100x times larger codebase.

Linux, debian i7-8565U

1 Like

Much better than scaling exponentially that’s for sure.

2 Likes

WSL has very slow file access. WSL2 is much faster. I recommend to get Windows Insider versions of Windows with WSL2,
I have 6 years old MacBookPro (Mid 2014) and I upgraded it to faster 1TB SSD.
It takes about a minute to compile Crystal compiler in debug mode.

Here is the run times:

bash-3.2$ ./build-debug.sh
Using /usr/local/opt/llvm/bin/llvm-config [version=10.0.0]
rm -rf .build
rm -rf ./docs
rm -rf src/llvm/ext/llvm_ext.o
rm -rf src/ext/sigfault.o src/ext/libcrystal.a
Using /usr/local/opt/llvm/bin/llvm-config [version=10.0.0]
c++ -c -g -O0 -o src/llvm/ext/llvm_ext.o src/llvm/ext/llvm_ext.cc -I/usr/local/Cellar/llvm/10.0.0_1/include -std=c++14 -stdlib=libc++   -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
cc -fPIC -g -O0 -emit-llvm -I/usr/local/opt/ruby/include -I/usr/local/opt/curl-openssl/include -I/usr/local/opt/llvm/include   -c -o src/ext/sigfault.o src/ext/sigfault.c
ar -rcs src/ext/libcrystal.a src/ext/sigfault.o
CRYSTAL_CONFIG_PATH="/Users/sergey/Projects/crystal/crystal/src" CRYSTAL_CONFIG_LIBRARY_PATH="/usr/local/Cellar/crystal/0.33.0/embedded/lib" CRYSTAL_CONFIG_BUILD_COMMIT="f81e50623" ./test-bin/crystal build --debug --error-trace --emit=llvm-ir -s -p -t -d --link-flags="-L/usr/local/opt/ruby/lib -L/usr/local/opt/curl-openssl/lib -L/usr/local/opt/llvm/lib "  -o .build/crystal src/compiler/crystal.cr -D without_openssl -D without_zlib
Parse:                             00:00:00.000113291 (   0.25MB)
Semantic (top level):              00:00:00.436790868 ( 106.66MB)
Semantic (new):                    00:00:00.003740392 ( 106.66MB)
Semantic (type declarations):      00:00:00.057943278 ( 122.66MB)
Semantic (abstract def check):     00:00:00.012873869 ( 122.66MB)
Semantic (ivars initializers):     00:00:05.205138141 ( 878.59MB)
Semantic (cvars initializers):     00:00:00.011416803 ( 878.59MB)
Semantic (main):                   00:00:08.764736526 (1118.59MB)
Semantic (cleanup):                00:00:00.187269115 (1118.59MB)
Semantic (recursive struct check): 00:00:00.002368904 (1118.59MB)
Codegen (crystal):                 00:00:09.495919997 (1266.59MB)
Codegen (bc+obj):                  00:00:45.840839222 (1266.59MB)
Codegen (linking):                 00:00:02.571180587 (1266.59MB)
dsymutil:                          00:00:01.509262768 (1266.59MB)

Macro runs:
 - /Users/sergey/Projects/crystal/crystal/src/ecr/process.cr: 00:00:07.545912228

Codegen (bc+obj):
 - no previous .o files were reused
1 Like

4 minutes? yikes. Hopefully sometime they can speed that up or parallelize it or something. In the meantime I hope you have some workaround where you can split out the code into smaller compile segments during dev???

Here’s mine:

crystal source git dir:
make touch src/slice.cr
$ time make

Late 2009 macbook
real 3m38.6s

ubuntu laptop i7-3540M CPU @ 3.00GHz
real 0m57.9s

vultr 4GB 2core “high frequency compute” instance
Intel Core Processor (Skylake, IBRS) 3.8GHz
real 0m32.9s

WSL i5-2500 3.3GHz
real 1m45s

For WSL sometimes disabling antivirus/windows defender can make a difference…

It takes me literally 30s to compile the compiler on linux. Does using OSX and windows slow things down so much?

$ time make                   
Using /usr/bin/llvm-config [version=9.0.1]
g++ -c  -o src/llvm/ext/llvm_ext.o src/llvm/ext/llvm_ext.cc -I/usr/include -std=c++11   -fno-exceptions -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
cc -fPIC    -c -o src/ext/sigfault.o src/ext/sigfault.c
ar -rcs src/ext/libcrystal.a src/ext/sigfault.o
CRYSTAL_CONFIG_PATH="/data/programming/crystal-lang/crystal/feature/shebang/src" CRYSTAL_CONFIG_LIBRARY_PATH="" CRYSTAL_CONFIG_BUILD_COMMIT="5a8b6de94" ./bin/crystal build  -o .build/crystal src/compiler/crystal.cr -D without_openssl -D without_zlib
make  49.66s user 5.77s system 180% cpu 30.675 total

I’d really like to hear of benchmarks (with --stats) on the same hardware between OSes, since I’ve always been impressed with crystal’s compile performance.

On a similar note - does anyone have any large projects other than the crystal spec suite? compiling all_spec.cr takes about two minutes for me.

Mine is similar on WSL2 with Ubuntu 18.04, i7 4770

$ time make
Using /usr/bin/llvm-config-10 [version=10.0.0]
g++ -c  -o src/llvm/ext/llvm_ext.o src/llvm/ext/llvm_ext.cc -I/usr/lib/llvm-10/include -std=c++14   -fno-exceptions -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
cc -fPIC    -c -o src/ext/sigfault.o src/ext/sigfault.c
ar -rcs src/ext/libcrystal.a src/ext/sigfault.o
CRYSTAL_CONFIG_PATH="/home/johannes/Projekte/crystal-lang/crystal/src" CRYSTAL_CONFIG_LIBRARY_PATH="/usr/bin/../lib/crystal/lib" CRYSTAL_CONFIG_BUILD_COMMIT="4401e90f0" ./bin/crystal build  -o .build/crystal src/compiler/crystal.cr -D without_openssl -D without_zlib

real    0m49.003s
user    1m44.642s
sys     0m12.488s
1 Like

MacBook Pro (Retina, Mid 2012)
2.3 GHz Intel Core i7

$ time make
Using /usr/local/opt/llvm@8/bin/llvm-config [version=8.0.1]
c++ -c  -o src/llvm/ext/llvm_ext.o src/llvm/ext/llvm_ext.cc -I/usr/local/Cellar/llvm@8/8.0.1/include -std=c++11   -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
cc -fPIC    -c -o src/ext/sigfault.o src/ext/sigfault.c
ar -rcs src/ext/libcrystal.a src/ext/sigfault.o
CRYSTAL_CONFIG_PATH="/Users/vlazar/Downloads/crystal/src" CRYSTAL_CONFIG_LIBRARY_PATH="/usr/local/Cellar/crystal/0.33.0/embedded/lib" CRYSTAL_CONFIG_BUILD_COMMIT="f69c54ca9" ./bin/crystal build  -o .build/crystal src/compiler/crystal.cr -D without_openssl -D without_zlib

real	0m49.805s
user	1m29.906s
sys		0m6.779s

This is for one of my main Lucky apps:

$ find . -name '*.cr' | xargs wc -l
141191 total
# Crystal 0.33.0 Release
$ time crystal build --release src/start_server.cr
crystal build --release src/start_server.cr  178.62s user 4.10s system 99% cpu 3:03.66 total

# Crystal 0.33.0
$ time crystal build src/start_server.cr
crystal build src/start_server.cr  30.36s user 4.44s system 237% cpu 14.630 total

# Crystal 0.34.0 Release
$ time crystal build --release src/start_server.cr
A total of 1 warnings were found.
crystal build --release src/start_server.cr  186.04s user 4.09s system 99% cpu 3:11.35 total

# Crystal 0.34.0
$ time crystal build --release src/start_server.cr
A total of 1 warnings were found.
crystal build src/start_server.cr  78.71s user 5.61s system 131% cpu 1:04.34 total

macOS 10.15.4 (late 2017) 2.7 GHz Quad-Core Intel Core i7, 16 GB 2133 MHz LPDDR3

2,6 GHz 6-Core Intel Core i7
16" Macbook Pro 2019
16 GB 2667 MHz DDR4

➜  crystal git:(0.34.0) ✗ time make
Using /usr/local/opt/llvm/bin/llvm-config [version=9.0.1]
c++ -c  -o src/llvm/ext/llvm_ext.o src/llvm/ext/llvm_ext.cc -I/usr/local/Cellar/llvm/9.0.1/include -std=c++11 -stdlib=libc++   -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
cc -fPIC    -c -o src/ext/sigfault.o src/ext/sigfault.c
ar -rcs src/ext/libcrystal.a src/ext/sigfault.o
CRYSTAL_CONFIG_PATH="/Users/lribeiro/Work/crystal/src" CRYSTAL_CONFIG_LIBRARY_PATH="/usr/local/Cellar/crystal/0.33.0/embedded/lib" CRYSTAL_CONFIG_BUILD_COMMIT="4401e90f0" ./bin/crystal build  -o .build/crystal src/compiler/crystal.cr -D without_openssl -D without_zlib

make  59.37s user 4.78s system 185% cpu 34.540 total

Compiling Crystal on an 3.2 GHz Intel i5 running Arch Linux, without and with release flag: (I also ran make clean before each build)

$ time make
Using /usr/bin/llvm-config [version=9.0.1]
...
make 50,07s user 3,67s system 160% cpu 33,562 total
$ time make crystal release=1
Using /usr/bin/llvm-config [version=9.0.1]
...
make crystal release=1  368,12s user 2,87s system 100% cpu 6:09,19 total

This seems to result in really similar numbers compared to everyone else :slight_smile:

I’m curious if that’s the first run or second run? Usually second run takes a lot of time off for me.

What about these other times? Are people posting initial compile time or after a warm cache?

Mine was just cd in to the directory, and run that command. So no warmup, just went in cold. But I prefer to see numbers at their worst. If I can live with it at that speed, then anything faster if a bonus.

Thankfully I never have to see those compile times on releases. I run deploy, and then come back a few min later and it’s all done. :joy:

1 Like

I’ve invited you to a github repo that you could try to compile if you want to stress the compiler further.

It doesn’t compile for me at all…

:thinking: too bad, but not entirely surprised.