Slow Compile After Switching Git Branches

I’ve noticed a pattern that when I switch branches on a Phoenix project, compilation slows significantly and CPU usage skyrockets. Mix prints several alerts that my files are taking longer than 15s.

Initially I thought it was a problem with the Elixir LS extension for VS Code, but I have the .elixir_ls folder ignored. I then thought that the deps or node_modules directories might be the problem, but wiping them out and re-downloading deps did not fix the issue. The only way I have found to get a snappy compile again was to delete the project directory and clone from Github again.

I’m not sure where to look next for troubleshooting. Does anyone have any suggestions?

That does not mean anything. ElixirLS might still recompile everything if dependencies between your branches differ.

Does this directory need to be deleted after switching branches?

Elixir LS runs dialyzer in the background, so it may be that…

1 Like

How are you compiling the project? Directly with mix compile (or phx.server), phoenix_live_reload (by refreshing a browser bage), something else?

Elixir LS runs dialyzer in the background, so it may be that…

I have Elixir LS Dialyzer disabled in VS Code.

@axelson Typically I’m running mix phx.server, and the compiler runs slow in both Mac Terminal and VS Code.