Has anyone else noticed a sharp drop in Elixir performance on MacOS over the past couple of years? The problem really seems to be in startup time rather than actual execution time. I don’t remember the Elixir version or the MacOS version where it started, but I kept expecting the next update of one or the other to fix it, but it hasn’t. I’m now on MacOS Catalina and Elixir 1.9.2.
Here are some comparison startup times:
larry@habu ~ % time erl -noshell -eval 'erlang:display(erlang:system_info(system_version))' -eval 'init:stop()'"Erlang/OTP 22 [erts-10.5.2] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1] [hipe] [dtrace]\n"
erl -noshell -eval 'erlang:display(erlang:system_info(system_version))' -eval 0.20s user 0.07s system 8% cpu 3.045 total
larry@habu ~ % time perl --version This is perl 5, version 18, subversion 4 (v5.18.4) built for darwin-thread-multi-2level
(with 2 registered patches, see perl -V for more detail)
Copyright 1987-2013, Larry Wall
Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.
Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl". If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.
perl --version 0.00s user 0.00s system 56% cpu 0.012 total
larry@habu ~ % time ruby --version
ruby 2.6.3p62 (2019-04-16 revision 67580) [universal.x86_64-darwin19]
ruby --version 0.01s user 0.01s system 74% cpu 0.019 total
larry@habu ~ % time python --version
Python 3.5.1
python --version 0.01s user 0.01s system 66% cpu 0.024 total
larry@habu ~ % time ghc --version
The Glorious Glasgow Haskell Compilation System, version 8.6.3
ghc --version 0.03s user 0.03s system 65% cpu 0.097 total
larry@habu ~ % time elixir --version
Erlang/OTP 22 [erts-10.5.2] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1] [hipe] [dtrace]
Elixir 1.9.2 (compiled with Erlang/OTP 22)
elixir --version 0.18s user 0.10s system 4% cpu 6.180 total
larry@habu ~ % time erl -noshell -eval 'erlang:display(erlang:system_info(system_version))' -eval 'init:stop()'
"Erlang/OTP 22 [erts-10.5.2] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1] [hipe] [dtrace]\n"
erl -noshell -eval 'erlang:display(erlang:system_info(system_version))' -eval 0.19s user 0.06s system 9% cpu 2.723 total
Anecdotally, I haven’t noticed this over the years. There is a whole VM and OTP application tree being booted, so some of these comparisons aren’t the best. Booting Clojure on the Java VM might be a more equitable comparison, but I don’t have an install handy to test. If memory serves, it takes a little over half a second.
I actively use macOS for little more than a year now and got through 2 major macOS updates but no, I definitely haven’t noticed any startup performance degradation at all.
FWIW, the behavior is the same on three different iMacs in the house. Although my home directory files are similar on all three, the startup time for Elixir is also the same for a “test” user who has essentially nothing in the way of configuration files:
larry@habu ~ % su - test
Password:
The default interactive shell is now zsh.
To update your account to use zsh, please run chsh -s /bin/zsh.
For more details, please visit https://support.apple.com/kb/HT208050.
habu:~ test$ ls -a
. .firefoxcatche Downloads Pictures
… .ssh Library Public
.CFUserTextEncoding Desktop Movies dir.dir
.bash_history Documents Music
habu:~ test$ time elixir --version
Erlang/OTP 22 [erts-10.5.2] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1] [hipe] [dtrace]
Elixir 1.9.2 (compiled with Erlang/OTP 22)
real 0m4.670s
user 0m0.159s
sys 0m0.086s
habu:~ test$
It’s been happening through several MacOS upgrades, and through several Elixir upgrades/reinstalls as well. I don’t remember exactly when it started but it was more than a year ago and less than three years ago.
Two of the iMacs have fusion drives, one is hard disk based. Don’t seem to have IO problems with any of the other langs.
My current installation is with “brew”. I had an older installation with “port” but had some issues with it and have been on the brew install since before the problem started. I’m in the process of doing a port install to see if that makes any difference. If that’s the same I’ll try an installation from source.
Actually, I was able to narrow down the time the problem started. It started after August 2017, and before September 2018. Don’t remember the current versions of MacOS or Elixir at that time.
Works well for me on 10.14, so it looks like it’s an issue on your installation:
➜ ~ time elixir --version
Erlang/OTP 22 [erts-10.4.4] [source] [64-bit] [smp:12:12] [ds:12:12:10] [async-threads:1] [hipe]
Elixir 1.9.1 (compiled with Erlang/OTP 20)
elixir --version 0.42s user 0.29s system 164% cpu 0.431 total
That’s kind of what I thought, but I can’t figure out what it might be. As I said, I have the same problem on three different computers, and with a bare-bones test user on one of them.
One other oddity… Very rarely, I’ll notice normal performance for a few hours. Very rarely, as in once or twice a year. That said, because of the issue I haven’t been using Elixir very much.
I would try installing Erlang and Elixir using asdf as a previous commenter said. By doing that you could install older versions of Erlang and Elixir and switch between them to compare and see any differences.
I’ve noticed compile performance has improved in recent versions.
Performance is good on Mojave 10.14 with a slightly older Erlang (22.0.7) than you are using:
➜ ~ time elixir --version
Erlang/OTP 22 [erts-10.4.4] [source] [64-bit] [smp:12:12] [ds:12:12:10] [async-threads:1] [hipe]
Elixir 1.9.2 (compiled with Erlang/OTP 22)
elixir --version 0.46s user 0.31s system 147% cpu 0.516 total
Another possibility that comes to mind is if you have some odd filesystem. If you really want to dig into what’s happening you could look into DTrace. Although if I recall correctly you may need to disable SIP (which is a pain).