# Share your compile times

**URL:** <https://forum.crystal-lang.org/t/share-your-compile-times/1898>\
**Category:** Offtopic\
**Created:** [April 3, 2020, 7:42pm UTC](https://forum.crystal-lang.org/t/share-your-compile-times/1898 "2020-04-03T19:42:26Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![Exilor](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/exilor/32/780_2.png) [@Exilor](https://forum.crystal-lang.org/u/Exilor)\
**Post date:** [April 3, 2020, 7:42pm UTC](https://forum.crystal-lang.org/t/share-your-compile-times/1898/1 "2020-04-03T19:42:26Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![mavu](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/mavu/32/213_2.png) [@mavu](https://forum.crystal-lang.org/u/mavu)\
**Post date:** [April 3, 2020, 8:51pm UTC](https://forum.crystal-lang.org/t/share-your-compile-times/1898/2 "2020-04-03T20:51:43Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Exilor](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/exilor/32/780_2.png) [@Exilor](https://forum.crystal-lang.org/u/Exilor)\
**Post date:** [April 3, 2020, 9:32pm UTC](https://forum.crystal-lang.org/t/share-your-compile-times/1898/3 "2020-04-03T21:32:21Z")

</div>

> [@mavu](#):
>
> Funny, that almost scales linearly with your 100x times larger codebase.

Much better than scaling exponentially that’s for sure.

---

<div class="post-metadata">

**Author:** ![ComputerMage](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/computermage/32/719_2.png) [@ComputerMage](https://forum.crystal-lang.org/u/ComputerMage)\
**Post date:** [April 4, 2020, 6:09pm UTC](https://forum.crystal-lang.org/t/share-your-compile-times/1898/4 "2020-04-04T18:09:15Z")

</div>

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:

```auto
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

```

---

<div class="post-metadata">

**Author:** ![rogerdpack](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/rogerdpack/32/117_2.png) [@rogerdpack](https://forum.crystal-lang.org/u/rogerdpack)\
**Post date:** [April 9, 2020, 6:57am UTC](https://forum.crystal-lang.org/t/share-your-compile-times/1898/5 "2020-04-09T06:57:36Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![RX14](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/rx14/32/633_2.png) [@RX14](https://forum.crystal-lang.org/u/RX14)\
**Post date:** [April 9, 2020, 10:00am UTC](https://forum.crystal-lang.org/t/share-your-compile-times/1898/6 "2020-04-09T10:00:17Z")

</div>

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

```auto
$ 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.

---

<div class="post-metadata">

**Author:** ![straight-shoota](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/straight-shoota/32/36_2.png) [@straight-shoota](https://forum.crystal-lang.org/u/straight-shoota)\
**Post date:** [April 9, 2020, 11:51am UTC](https://forum.crystal-lang.org/t/share-your-compile-times/1898/7 "2020-04-09T11:51:17Z")

</div>

Mine is similar on WSL2 with Ubuntu 18.04, i7 4770

```auto
$ 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

```

---

<div class="post-metadata">

**Author:** ![vlazar](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/vlazar/32/31_2.png) [@vlazar](https://forum.crystal-lang.org/u/vlazar)\
**Post date:** [April 9, 2020, 12:04pm UTC](https://forum.crystal-lang.org/t/share-your-compile-times/1898/8 "2020-04-09T12:04:32Z")

</div>

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

```auto
$ 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

```

---

<div class="post-metadata">

**Author:** ![jwoertink](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/jwoertink/32/50_2.png) [@jwoertink](https://forum.crystal-lang.org/u/jwoertink)\
**Post date:** [April 9, 2020, 5:32pm UTC](https://forum.crystal-lang.org/t/share-your-compile-times/1898/9 "2020-04-09T17:32:09Z")

</div>

This is for one of my main Lucky apps:

```auto
$ find . -name '*.cr' | xargs wc -l
141191 total

```

```auto
# 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

---

<div class="post-metadata">

**Author:** ![lribeiro](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/lribeiro/32/635_2.png) [@lribeiro](https://forum.crystal-lang.org/u/lribeiro)\
**Post date:** [April 9, 2020, 6:27pm UTC](https://forum.crystal-lang.org/t/share-your-compile-times/1898/10 "2020-04-09T18:27:30Z")

</div>

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

```bash
➜ 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

```

---

<div class="post-metadata">

**Author:** ![tijn](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/tijn/32/61_2.png) [@tijn](https://forum.crystal-lang.org/u/tijn)\
**Post date:** [April 9, 2020, 6:57pm UTC](https://forum.crystal-lang.org/t/share-your-compile-times/1898/11 "2020-04-09T18:57:51Z")

</div>

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)

```bash
$ time make
Using /usr/bin/llvm-config [version=9.0.1]
...
make 50,07s user 3,67s system 160% cpu 33,562 total

```

```bash
$ 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 🙂

---

<div class="post-metadata">

**Author:** ![paulcsmith](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/paulcsmith/32/301_2.png) [@paulcsmith](https://forum.crystal-lang.org/u/paulcsmith)\
**Post date:** [April 9, 2020, 6:58pm UTC](https://forum.crystal-lang.org/t/share-your-compile-times/1898/12 "2020-04-09T18:58:15Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![jwoertink](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/jwoertink/32/50_2.png) [@jwoertink](https://forum.crystal-lang.org/u/jwoertink)\
**Post date:** [April 9, 2020, 7:56pm UTC](https://forum.crystal-lang.org/t/share-your-compile-times/1898/13 "2020-04-09T19:56:40Z")

</div>

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. 😂

---

<div class="post-metadata">

**Author:** ![Exilor](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/exilor/32/780_2.png) [@Exilor](https://forum.crystal-lang.org/u/Exilor)\
**Post date:** [April 9, 2020, 8:31pm UTC](https://forum.crystal-lang.org/t/share-your-compile-times/1898/14 "2020-04-09T20:31:03Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![RX14](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/rx14/32/633_2.png) [@RX14](https://forum.crystal-lang.org/u/RX14)\
**Post date:** [April 9, 2020, 9:23pm UTC](https://forum.crystal-lang.org/t/share-your-compile-times/1898/15 "2020-04-09T21:23:20Z")

</div>

It doesn’t compile for me at all…

---

<div class="post-metadata">

**Author:** ![Exilor](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/exilor/32/780_2.png) [@Exilor](https://forum.crystal-lang.org/u/Exilor)\
**Post date:** [April 9, 2020, 9:34pm UTC](https://forum.crystal-lang.org/t/share-your-compile-times/1898/16 "2020-04-09T21:34:45Z")

</div>

🤔 too bad, but not entirely surprised.
