marcandre
`mix` even more slugish with Elixir 1.12.1
Playing around with time mix, there are a few things that strike me as odd
-
It seems slow.
time mix compile, a second time after nothing changed, takes about 2.4s on my machine (MacPro '09 with 6 core 3.2Ghz Xeon). Elixir 1.11.4 / OTP 23. Is that expected? We have about 300*.exfiles, 50*.leex, and ourmix.lockis 100 line long. -
time mix compileis 20% slower on Elixir 1.12.1 / OTP 24: about 2.9s. Is that expected? -
The option
--no-compilesaves about 20% (0.6s). Why? There is no compilation anyways in this test as I’m not modifying any file. -
The option
--no-app-loadingsaves 25% (0.8s). Doc says “does not load applications (including from deps) before compiling”. Is there a short explanation as to what that entails / when not to use this?
Finally, is there a standard way to have mix feel less slugish?
Note: Not important whatsoever but time mix compilexxx takes an extra 15% (0.5s) to tell me that “The task “compilexxx” could not be found. Did you mean “compile”?” Seems like a lot of CPU cycles for that “did you mean …”!
Most Liked
josevalim
Sorry. I meant that you shouldn’t see a difference between mix run -e "" across Elixir versions. But I expect mix run -e "" to indeed have some additional time as it has to start all apps (and you have ~100 of them!)
I spent 15 minutes optimizing app loading and it now loads apps concurrently!
If you are willing to give it a try, you can find it in the v1.12 branch too. Since you have 6 cores, I am hoping it will at least go down to 0.2s.
So hopefully this and the upcoming phoenix change shaves ~1.1s from your times. I will keep investigating!
EDIT 1: The 15 minutes actually became 1h because it turns out the code was reaching to a central process. I was able to optimize it by adding a fast paths to apps that come from deps (which are the huge majority). In a sample project I created with 50 deps, times went from 180ms to 50ms!
EDIT 2: I got an app with 150 deps and app loading time went from 920ms to 120ms!
josevalim
Elixir v1.12.2 is out with the improvements in this thread.
josevalim
Hi @marcandre!
One of the biggest changes in Elixir v1.11 was the tracking of application calls. We will now warn if you call an application you don’t depend on. This means that the loading of applications, which was done after compilation, is now done before compilation. This is the process of parsing .app files and loading them into memory. This probably explains a chunk of your time, since disabling app loading saves 0.8s. If you disable it, they are loaded and started at once later on.
Some extra suggestions:
-
Can you please measure the times for
mix run -e ""? You are not supposed to see a large difference on those. Btw, what is the Elixir version you are measuring against? -
You can use
MIX_DEBUG=1to track the time spent on each task -
Phoenix master (upcoming v1.6) no longer requires the
:phoenixcompiler and that should save some additional time -
mix compilexxxtakes a lot of time because we need to go through all applications, load all existing mix tasks, and see if any of them may match. This is probably another action we can parallelize.
That doesn’t mean we can’t optimize things though. Application loading, for instance, is not parallel today, and we should be able to do so somewhat trivially.
As an appreciation for your work, I would be willing to jump into this codebase, if you could share it with me, or jump into a call and explore some ideas with you. Or perhaps sharing the mix.exs + mix.lock can be enough to reproduce a lot of it (you can erase lib and run again to check). Just let me know. ![]()
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance









