marcandre

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

  1. 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 *.ex files, 50 *.leex, and our mix.lock is 100 line long.

  2. time mix compile is 20% slower on Elixir 1.12.1 / OTP 24: about 2.9s. Is that expected?

  3. The option --no-compile saves about 20% (0.6s). Why? There is no compilation anyways in this test as I’m not modifying any file.

  4. The option --no-app-loading saves 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

josevalim

Creator of Elixir

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! :smiley: 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!

31
Post #4
josevalim

josevalim

Creator of Elixir

Elixir v1.12.2 is out with the improvements in this thread.

17
Post #8
josevalim

josevalim

Creator of Elixir

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:

  1. 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?

  2. You can use MIX_DEBUG=1 to track the time spent on each task

  3. Phoenix master (upcoming v1.6) no longer requires the :phoenix compiler and that should save some additional time

  4. mix compilexxx takes 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. :slight_smile:

11
Post #2

Where Next?

Popular in Questions Top

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
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
Lily
In templates/appointment/index.html.eex: <%= for appointment <- @appointments do %> <tr> <td><%= appoi...
New
itssasanka
Hi all, Trying to get some more clarity over utc_datetime and naive_datetime for Ecto: The documentation above suggests that while ...
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
svb
Hi! Currently I want to submit a form by pressing the Enter key. However, since my input field is of type “textarea” this is just adds a...
New

Other popular topics Top

aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New
Emily
I have VueJS GUIs with the project generated using Webpack. I have Elixir modules that will need to be used by the VueJS GUIs. I forese...
New
grych
Hi folks, Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
639 52673 488
New
saif
Hello everyone, Long time lurker first time poster here. I’ve recently begun working on Elixir full-time again! :raised_hands: It’s been...
New
AstonJ
Seen any cool LiveView demos, sample apps or examples? Please post them here! :003:
New

Latest on Elixir Forum

Elixir Forum

We're in Beta

About us Mission Statement