erl_tar:extract
performance is about 10-30x slower on Apple computers using the new M1 chip compared to Intel machines. This issue has been confirmed by multiple people in the community and seems to be affecting M1 Max/Pro chips more than the original M1 chips.
The issue can be circumvented by excluding the extraction directory from Spotlight indexing.
Given that the issue only happens on M1 chips and can be worked around by disabling Spotlight indexing it seems to be an Apple issue but I haven’t been able to reproduce the issue in other languages or by using GNU tar.
The issue is affecting the community because running tools such as mix deps.get
can take up to 2 minutes even when packages are cached and Hex only has to extract the packages to the project directory. I haven’t tested if it also affects rebar3 but it should since it is also using erl_tar
.
To reproduce the issue I have created a shell script to download some Hex package tarballs and an Erlang script that will extract them to show the performance issue:
packages=(
bamboo-2.2.0.tar
bamboo_phoenix-1.0.0.tar
bcrypt_elixir-2.3.0.tar
certifi-2.8.0.tar
comeonin-5.3.2.tar
connection-1.1.0.tar
corsica-1.1.3.tar
cowboy-2.9.0.tar
cowboy_telemetry-0.4.0.tar
cowlib-2.11.0.tar
db_connection-2.4.1.tar
decimal-2.0.0.tar
earmark-1.4.18.tar
earmark_parser-1.4.17.tar
ecto-3.7.1.tar
ecto_sql-3.7.1.tar
elixir_make-0.6.3.tar
eqrcode-0.1.10.tar
ex_aws-2.2.7.tar
ex_aws_s3-2.3.1.tar
ex_aws_ses-2.3.0.tar
ex_machina-2.7.0.tar
file_system-0.2.10.tar
goth-1.3.0-rc.3.tar
hackney-1.18.0.tar
hex_core-0.8.2.tar
idna-6.1.1.tar
jason-1.2.2.tar
jose-1.11.2.tar
libcluster-3.3.0.tar
logster-1.0.2.tar
metrics-1.0.1.tar
mime-1.6.0.tar
mimerl-1.2.0.tar
mox-1.0.1.tar
parse_trans-3.3.1.tar
phoenix-1.6.2.tar
phoenix_ecto-4.4.0.tar
phoenix_html-3.1.0.tar
phoenix_live_dashboard-0.6.1.tar
phoenix_live_reload-1.3.3.tar
phoenix_live_view-0.17.3.tar
phoenix_pubsub-2.0.0.tar
phoenix_view-1.0.0.tar
plug-1.12.1.tar
plug_attack-0.4.3.tar
plug_cowboy-2.5.2.tar
plug_crypto-1.2.2.tar
postgrex-0.15.13.tar
pot-1.0.2.tar
ranch-1.8.0.tar
rollbax-0.11.0.tar
ssl_verify_fun-1.1.6.tar
sweet_xml-0.7.1.tar
telemetry-1.0.0.tar
telemetry_metrics-0.6.1.tar
telemetry_poller-1.0.0.tar
unicode_util_compat-0.7.0.tar
)
for package in $packages; do
wget "https://repo.hex.pm/tarballs/${package}.tar"
done
lists:foreach(fun(Path) ->
erl_tar:extract(
Path, [
{cwd, filename:basename(Path, ".tar")},
{files, ["contents.tar.gz"]}
])
end, filelib:wildcard("*.tar")).
%% Running this will show the slow performance
lists:foreach(fun(Path) ->
erl_tar:extract(
Path, [
compressed,
{cwd, filename:rootname(Path, ".tar.gz")}
]
)
end, filelib:wildcard("*/contents.tar.gz")).
I am not sure how to continue investigating this issue so any help would be appreciated.