Compiling my release binaries is a little slow with 0.18.4:
$ make bin
rm -f sidekiq sideweb
time crystal compile --release -o sidekiq examples/sidekiq.cr
8.80 real 8.71 user 0.15 sys
time crystal compile --release -o sideweb examples/web.cr
24.46 real 23.16 user 1.38 sys
Is there anything application developers can do to speed up compile times?
compile with -s shows most time in Codegen (bc+obj): 00:00:34.2336990, but this is only first time.
It would appear there are some serious filesystem cache effects here. A second run looks like this:
$ make bin
rm -f sidekiq sideweb
time crystal compile --release -o sidekiq examples/sidekiq.cr
0.68 real 0.65 user 0.12 sys
time crystal compile --release -o sideweb examples/web.cr
3.46 real 2.24 user 1.24 sys
There are, we avoid redoing codegen for LLVM modules if their source didn't change, so the phase @kostya mentioned is much quicker.
Crystal caches the LLVM bitcode in a separate directory.
IIRC the whole reason why instance variables now require type annotations is to enable further caching to avoid re-type-checking everything every time.
Yes, but note that running LLVM optimizations is slow and will always take a lot of time.
I'm closing this. Compiling with --release will always be slow, because LLVM is slow optimizing things. That's because we are using the equivalent of -O3. We _could_ allow other optimization levels, but when generating a release executable I think you'd normally want to optimize it as much as possible, and since releases don't happen that often one can wait a bit more for compilation to finish.
There are plenty of other situations where you'd need to compile a "scriptish" thing to run as fast as possible with the minimum investment in compile time mortgage. I'd definitely say it would be worth having "concept flags" (as opposed to -O3 style)
Most helpful comment
There are plenty of other situations where you'd need to compile a "scriptish" thing to run as fast as possible with the minimum investment in compile time mortgage. I'd definitely say it would be worth having "concept flags" (as opposed to -O3 style)