Mix v1.1.1 Mix.Tasks.Compile.Protocols
Consolidates all protocols in all paths.
This task is automatically invoked whenever the project
enables :consolidate_protocols
or :build_embedded
in
its configuration.
Consolidation
Protocol consolidation is useful in production when no dynamic code loading will happen, effectively optimizing protocol dispatches by not accounting for code loading.
This task consolidates all protocols in the code path and output the new binary files to the given directory (defaults to “_build/MIX_ENV/consolidated”).
In case you are manually compiling protocols or building releases, you need to take the generated protocols into account. This can be done with:
$ elixir -pa _build/MIX_ENV/consolidated -S mix run
You can verify a protocol is consolidated by checking its attributes:
$ iex -pa _build/MIX_ENV/consolidated -S mix run
iex> Protocol.consolidated?(Enumerable)
true