View Source mix compile.protocols (Mix v1.13.4)

Consolidates all protocols in all paths.

This task is automatically invoked unless the project disables the :consolidate_protocols option in their 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 outputs the new binary files to the given directory. Defaults to "_build/MIX_ENV/lib/YOUR_APP/consolidated" for regular apps and "_build/MIX_ENV/consolidated" in umbrella projects.

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/lib/YOUR_APP/consolidated -S mix run

Or in umbrellas:

$ elixir -pa _build/MIX_ENV/consolidated -S mix run

You can verify a protocol is consolidated by checking its attributes:

iex> Protocol.consolidated?(Enumerable)
true

Link to this section Summary

Functions

Returns if protocols have been consolidated at least once.

Link to this section Functions

Returns if protocols have been consolidated at least once.