Very slow build speeds for hello world

I didn’t use the -s option much before, but when I tried it, I was impressed by the nice output.

However, the -s option doesn’t show that most of the time is spent on two specific LLVM functions. These functions are each called only once. Most of the Crystal compilation time is spent on LLVM, and Crystal itself does very little.

This means speeding up the Crystal compiler might not reduce build time much. To improve build time, we might need to make LLVM faster or change how Crystal outputs LLVM-IR. For example, we could split it into parts for parallel compilation. But I’ve heard that splitting Crystal might cause type inconsistencies because the type number for each class changes with each compilation.

If you have been using Crystal for a long time, you probably know this. But newcomers often wonder why builds are so slow. Understanding that most of the time is spent on LLVM, not Crystal, will help them understand and feel comfortable.

2 Likes

AMD Athlon™ X4 840 Quad Core Processor 3.10 GHz 8G windows 11

test!

Command Mean [s] Min [s] Max [s] Relative
crystal run ./hello_word.cr 3.647 ± 0.397 3.152 4.278 1.00

You might want force a full rebuild if you’re doing it multiple times. Otherwise it should be mostly incremental.

1 Like