# Why is the first execution of a binary slow?

**URL:** <https://forum.crystal-lang.org/t/why-is-the-first-execution-of-a-binary-slow/1479>\
**Category:** Help & Support\
**Created:** [December 12, 2019, 6:20pm UTC](https://forum.crystal-lang.org/t/why-is-the-first-execution-of-a-binary-slow/1479 "2019-12-12T18:20:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![fxn](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/fxn/32/1128_2.png) [@fxn](https://forum.crystal-lang.org/u/fxn)\
**Post date:** [December 12, 2019, 6:20pm UTC](https://forum.crystal-lang.org/t/why-is-the-first-execution-of-a-binary-slow/1479/1 "2019-12-12T18:20:11Z")

</div>

The first execution of binaries is noticeably slow, at least in my computer, [see video](https://www.dropbox.com/s/xy72mjm6llcvajj/first_execution_crystal.mov?dl=0). Why is that?

---

<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:** [December 12, 2019, 6:26pm UTC](https://forum.crystal-lang.org/t/why-is-the-first-execution-of-a-binary-slow/1479/2 "2019-12-12T18:26:57Z")

</div>

Unless your mass storage is made from [core memory](https://en.wikipedia.org/wiki/Magnetic-core_memory) this is too slow for mere harddisk caching influence.  
Maybe your operating system does weird things when executing files?  
Maybe its dynamic library lookup?

---

<div class="post-metadata">

**Author:** ![fxn](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/fxn/32/1128_2.png) [@fxn](https://forum.crystal-lang.org/u/fxn)\
**Post date:** [December 12, 2019, 7:02pm UTC](https://forum.crystal-lang.org/t/why-is-the-first-execution-of-a-binary-slow/1479/3 "2019-12-12T19:02:15Z")

</div>

Seems unrelated to Crystal, I have been able to reproduce with a C Hello World. The delay is smaller, but the binary is also way smaller.

Guess it is related to macOS Catalina somehow, `docker-compose` has had issues related to OS security scans or something to the point that `docker-compose --version` can take up to 14 seconds here (always, not only in the first run, fixed in the current RC if installed as tarball).
