marcandre

marcandre

Elixir 1.19 compilation performance - have you noticed a difference?

Compilation time for our project degraded from ~26 seconds to ~32 seconds (~23% slower) :disappointed_face:.

Did anyone else compare compilation performance on their project?

$ time mix compile --force && elixir -v
Compiling 1397 files (.ex)
Generating Enaia.Cldr for 2 locales named [:en, :und] with a default locale named :en
Generated enaia app

real	0m25.922s
user	1m59.042s
sys	0m16.722s
Erlang/OTP 27 [erts-15.2.7.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [jit]

Elixir 1.18.4 (compiled with Erlang/OTP 27)

time mix compile --force && elixir -v
Compiling 1397 files (.ex)
Generating Enaia.Cldr for 2 locales named [:en, :und] with a default locale named :en
Generated enaia app

real	0m32.299s
user	2m48.014s
sys	0m20.359s
Erlang/OTP 28 [erts-16.1.1] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [jit]

Elixir 1.19.1 (compiled with Erlang/OTP 28)

Most Liked

vanderhoop

vanderhoop

Also, you’re the freedom_formatter guy! Thanks for the trailing commas :heart:!

marcandre

marcandre

Thanks @josevalim!

Findings:

  • 1.19 slowdown confirmed to be in “after compile callback”.
  • 1.20 introduces additional slowdown in “group pass check” (1.4 → 6.4 seconds)
  • OTP version not relevant.

Details:
I re-ran it in 1.18 just to confirm that the protocol consolidation / file writing was faster in 1.18:

[profile] Finished compilation cycle of 1648 modules in 20759ms
# About 3 seconds in 1.18, which matches the overall time
[profile] Finished group pass check of 1648 modules in 1069ms
<- Ran mix compile.elixir in 23795ms

I can also confirm that OTP has no impact (i.e. 1.19 with older OTP version is also slow)

Compiling with the latest changes gives the following output:

[profile] Finished cycle resolution in 0ms
[profile] Finished compilation cycle of 1648 modules in 21185ms
[profile] Finished writing modules to disk in 284ms
[profile] Finished after compile callback in 8216ms
[profile] Finished group pass check of 1648 modules in 6402ms
<- Ran mix compile.elixir in 36360ms

So “after compile callback” is indeed slow, but strangely “group pass check” is also slower in 1.20.

So I started from 1.19.1’s source and just added the “after compile callback” output and got back the quicker “group pass check”:

[profile] Finished cycle resolution in 0ms
[profile] Finished compilation cycle of 1648 modules in 21974ms
[profile] Finished after compile callback in 9124ms
[profile] Finished group pass check of 1648 modules in 1398ms
<- Ran mix compile.elixir in 34360ms
vanderhoop

vanderhoop

The compiler is definitely doing more work overall in 1.19.X, so make sure you’re leveraging the MIX_OS_DEPS_COMPILE_PARTITION_COUNT env var, described here: elixir/CHANGELOG.md at v1.19 · elixir-lang/elixir · GitHub

If the compilation is still longer overall after setting that value to around half your cores, I’d open a bug, as I don’t think that’s expected.

josevalim

josevalim

Creator of Elixir

This is very weird indeed, because extract_protocols did not change at all! I can only think that somehow :beam_lib.chunks is way more expensive now? Do you see a large difference in .beam file sizes?

PS: I pushed a new commit to the v1.19 branch if you want to validate this theory.

josevalim

josevalim

Creator of Elixir

No. I have a hunch this is protocol consolidation. If you open up mix/compilers/elixir.ex, you will see each_cycle and after_compile callbacks, measure those!

Where Next?

Popular in Discussions Top

bartblast
With the core component system and HTTP/WebSocket infrastructure solid, it’s time to tackle Pub/Sub support. What We Have vs What’s Miss...
New
artimath
I think I’ve tried 5 different graph database libraries in the last two days and not a single one has been able to connect to a remote/lo...
New
rump13
Hi everyone, I’ve been following Elixir since around 2016 and tinkering with it on and off, but I haven’t had the opportunity to use it ...
New
lud
Hello, I just extracted the boilerplate management code that I used to work with in previous years: It is yet another generic input d...
New
AstonJ
@Garrison’s comment in another thread reminded me of this post by Joe: With the big five exerting more control than ever, new (AI) play...
New
billylanchantin
If you’re not familiar with this fun bit of math lore, Paul Erdős, the famously eccentric, peripatetic and prolific 20th-century mathem...
New
rhcarvalho
Very interesting value proposition! Having watched some interviews with Elm’s creator recently, I wanted to ask where you stand in terms...
New
bartblast
This thread is dedicated to announcing updates to the Hologram documentation, as well as discussing any ideas for improvements and sugges...
New
AstonJ
There seems to be a lot of buzz around DeepSeek at the moment, with some saying it’s a ChatGPT killer. The most remarkable thing (if they...
New
ScriptyScott
Hey Folks, I just spent the last couple of days doing a deep dive into using Swoosh with Amazon’s simple email service, check out this t...
New

Other popular topics Top

yurko
Here are few pieces of (common) Linux knowledge that we use for reasonably small one server apps. We use Ubuntu but this should work for ...
New
ycv005
I have followed this StackOverflow post to install the specific version of Erlang. And When I am running mix ecto.setup then getting fol...
New
malloryerik
Hi, this is for people who, like me, have had some friction using .html.heex templates in VSCode. The solution seems to be, in a hyphena...
New
KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 35421 110
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list....
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? https://hexdocs.pm/ecto/Ecto.Repo.h...
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
aesmail
Hello guys, I have finally made it. I created an admin interface for a framework. It’s been on my todo list for years and with the curre...
New

We're in Beta

About us Mission Statement