Faster `--release` compile times but slightly worse performance?

Okay, here’s an example.

We’ll use this program, which is a mandelbrot benchmark: crystal-benchmarks-game/mandelbrot.cr at master · kostya/crystal-benchmarks-game · GitHub (run it with 10000)

  • Without --release
    • Time to compile: 1.35s
    • Time to execute: 15s
  • With the old --release mode
    • Time to compile: 7.75s
    • Time to execute: 7.32s
  • With the new --release mode
    • Time to compile: 3.14s
    • Time to execute: 8.53s

You can already see that the new --release mode is closer to “without --release” when it comes to how long it takes to compile the program, and closer to “with the old --release” when it comes to executing the program

Next, havlak: crystal/havlak.cr at master · crystal-lang/crystal · GitHub

  • Without --release
    • Time to compile: 1.5s
    • Time to execute: 35.56s
  • With the old --release mode
    • Time to compile: 8.71s
    • Time to execute: 9.42s
  • With the new --release mode
    • Time to compile: 3.27s
    • Time to execute: 15.29s

Actually, it seems that this new --release mode is right in between the two modes. So these could be similar to -O1, -O2 and -O3 from other build systems… maybe?

Finally, let’s take a big program: the compiler.

Compiling the compiler in release mode goes from about 5 minutes to 1.5 minutes. Then, compiling that havlak program above in non-release mode goes from 1.72s to 2.24s. To compile the compiler in non-release mode again, it goes from 33.35s to 38.98s.

(this last part was a bit confusing, but it shows that with this new approach, we’ll have to wait 1.5 minutes to compile the compiler in release mode instead of 5 minutes, but then compiling the compiler with this new compiler takes 38.98s instead of 33.35s, because it’s slightly slower)

6 Likes