Speed up recompilation time
At some point, something happened that made the entire router need to get recompiled whenever a single controller or view is edited:
➜ soapbox git:(recompilation) ✗ mix compile
➜ soapbox git:(recompilation) ✗ touch lib/pleroma/web/mastodon_api/views/instance_view.ex
➜ soapbox git:(recompilation) ✗ mix compile
Compiling 173 files (.ex)
Compiling lib/pleroma/web/router.ex (it's taking more than 10s)
When I first got into Pleroma dev I assumed this was a normal part of the language, but after coding my own stuff in Elixir I realized it wasn't. Editing a view should result in 1 file being recompiled, and it should take about 1 second. Right now it takes 30 seconds at least, sometimes more.
This makes it difficult for people to contribute to Pleroma, which could potentially stifle its growth. If fixed, it will make development easier for all of us in the long term. It's a personal priority of mine to fix because of the long-term gains.
Resources:
-
Understanding and fixing recompilation in Elixir projects — https://szajbus.dev/elixir/2020/04/14/understanding-and-fixing-recompilation-in-elixir-projects.html
-
Speeding up re-compilation of Elixir projects — https://dashbit.co/blog/speeding-up-re-compilation-of-elixir-projects
-
Elixir Forum: Modifying a controller recompiles my router and all UI layer — https://elixirforum.com/t/modifying-a-controller-recompiles-my-router-and-all-ui-layer/24105
-
ElixirConf 2018 - Understanding Elixir's Re compilation (YouTube) — https://www.youtube.com/watch?v=hqaxMZAwbBA
-
mix xref
docs — https://hexdocs.pm/mix/Mix.Tasks.Xref.html