Why is the first execution of a binary slow?

The first execution of binaries is noticeably slow, at least in my computer, see video. Why is that?

Unless your mass storage is made from 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?

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).

1 Like