# Very slow build speeds for hello world

**URL:** https://forum.crystal-lang.org/t/very-slow-build-speeds-for-hello-world/6881
**Category:** Help & Support
**Created:** [May 28, 2024, 7:39pm UTC](https://forum.crystal-lang.org/t/very-slow-build-speeds-for-hello-world/6881 "2024-05-28T19:39:59Z")
**Posts on this page:** 9
**Page:** 3

<div class="post-metadata">

### Author: ![kojix2](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/kojix2/32/1583_2.png) [@kojix2](https://forum.crystal-lang.org/u/kojix2)
#### Post date: [August 18, 2024, 2:10am UTC](https://forum.crystal-lang.org/t/very-slow-build-speeds-for-hello-world/6881/41 "2024-08-18T02:10:59Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![xiamu](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/xiamu/32/2568_2.png) [@xiamu](https://forum.crystal-lang.org/u/xiamu)
#### Post date: [August 18, 2024, 5:13am UTC](https://forum.crystal-lang.org/t/very-slow-build-speeds-for-hello-world/6881/42 "2024-08-18T05:13:28Z")

</div>

**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 |

---

<div class="post-metadata">

### Author: ![Bonarc](https://avatars.discourse-cdn.com/v4/letter/b/7ab992/32.png) [@Bonarc](https://forum.crystal-lang.org/u/Bonarc)
#### Post date: [August 18, 2024, 8:01pm UTC](https://forum.crystal-lang.org/t/very-slow-build-speeds-for-hello-world/6881/43 "2024-08-18T20:01:39Z")

</div>

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

---

<div class="post-metadata">

### Author: ![kojix2](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/kojix2/32/1583_2.png) [@kojix2](https://forum.crystal-lang.org/u/kojix2)
#### Post date: [December 11, 2025, 11:45pm UTC](https://forum.crystal-lang.org/t/very-slow-build-speeds-for-hello-world/6881/44 "2025-12-11T23:45:03Z")

</div>

I wrote a blog post about this benchmark on dev.to.

> **[Why Is Crystal Compilation So Slow?](https://dev.to/kojix2/why-is-crystal-compilation-so-slow-29n0)**
>
> Introduction The Crystal programming language is notorious for its slow compilation...

---

<div class="post-metadata">

### Author: ![kojix2](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/kojix2/32/1583_2.png) [@kojix2](https://forum.crystal-lang.org/u/kojix2)
#### Post date: [December 14, 2025, 2:41pm UTC](https://forum.crystal-lang.org/t/very-slow-build-speeds-for-hello-world/6881/45 "2025-12-14T14:41:18Z")

</div>

I learned that LLVM applies various passes to LLVM-IR to perform optimizations. It would be kind of interesting to visualize which passes are applied, in what order, where they are applied, and how long each one takes. That said, this is a bit beyond my capacity, since I’m just doing it as a hobby.

---

<div class="post-metadata">

### Author: ![kojix2](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/kojix2/32/1583_2.png) [@kojix2](https://forum.crystal-lang.org/u/kojix2)
#### Post date: [December 19, 2025, 2:15pm UTC](https://forum.crystal-lang.org/t/very-slow-build-speeds-for-hello-world/6881/46 "2025-12-19T14:15:32Z")

</div>

So, I gave it a quick try on Google Colab. It looks like `ModuleInlinerWrapperPass` and `DevirtSCCRepeatedPass` are the heavy ones. They disappear at `-O0`, but the pattern is similar at `-O2` (it’s just a bit faster).

```cr
require "kemal"

get "/" do
  "Hello World!"
end

Kemal.run

```

```sh
crystal build --release --emit llvm-ir server.cr

```

```sh
opt-15 -time-passes -O3 server.ll -o /dev/null 2> server.opt.txt

```

Bar chart and treemap by Google Colab’s Gemini. I did absolutely nothing🙃

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/crystal_lang/original/2X/7/7290ca3f02a83c9af708d13d5ed6827fd3ef81fe.png)  
 ![newplot](https://canada1.discourse-cdn.com/flex036/uploads/crystal_lang/original/2X/4/4c0f526fe4c9a92d3e8a5f480450cee837e09b77.png)

```sh
CRYSTAL_CACHE_DIR=/content/cache1 crystal build -O3 --verbose server.cr

```

 ![newplot(1)](https://canada1.discourse-cdn.com/flex036/uploads/crystal_lang/original/2X/c/ceeb66dcbe31e9fed73d9bebc3c23efa10a3bcad.png)

Colab Notebook Share Link

> **[Google Colab](https://colab.research.google.com/drive/1yNMfXjgAQWS6dwk3JzX366Ttp4lv28bU?usp=sharing)**

---

<div class="post-metadata">

### Author: ![kojix2](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/kojix2/32/1583_2.png) [@kojix2](https://forum.crystal-lang.org/u/kojix2)
#### Post date: [December 20, 2025, 3:38pm UTC](https://forum.crystal-lang.org/t/very-slow-build-speeds-for-hello-world/6881/47 "2025-12-20T15:38:51Z")

</div>

Those results are based on LLVM 15. The optimization pipeline and results are different on my local LLVM 20. It seems Crystal avoids premature optimization and bets on LLVM’s progress instead. The right approach, I think.

---

<div class="post-metadata">

### Author: ![ksec](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/ksec/32/861_2.png) [@ksec](https://forum.crystal-lang.org/u/ksec)
#### Post date: [December 24, 2025, 2:08pm UTC](https://forum.crystal-lang.org/t/very-slow-build-speeds-for-hello-world/6881/48 "2025-12-24T14:08:42Z")

</div>

> [@asterite](#):
>
> Sorbet

I am pretty sure it was Stripe that created Sorbet. I think Shopify uses different tools for type checking.

---

<div class="post-metadata">

### Author: ![jgaskins](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/jgaskins/32/2449_2.png) [@jgaskins](https://forum.crystal-lang.org/u/jgaskins)
#### Post date: [December 25, 2025, 11:49pm UTC](https://forum.crystal-lang.org/t/very-slow-build-speeds-for-hello-world/6881/49 "2025-12-25T23:49:14Z")

</div>

Stripe did create it, but Shopify does use it extensively. I worked there until last year, though if you’d prefer not to trust strangers on the internet (a wise choice, tbh), you can also confirm by looking through [the contributors from the last 6 months](https://github.com/sorbet/sorbet/graphs/contributors?from=6%2F21%2F2025): of the top 10, 2 are from Stripe and 5 are from Shopify. The other 3 might also be from either of those companies, but it’s not readily apparent.

[Previous page](https://forum.crystal-lang.org/t/very-slow-build-speeds-for-hello-world/6881.md?page=2)
