Skip to content

Commit a616cc4

Browse files
committed
Docs
1 parent 0d7b673 commit a616cc4

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

lib/mix/lib/mix/tasks/deps.compile.ex

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,24 @@ defmodule Mix.Tasks.Deps.Compile do
3535
recompiled without propagating those changes upstream. To ensure
3636
`b` is included in the compilation step, pass `--include-children`.
3737
38+
## Compiling dependencies across multiple OSes processes
39+
40+
If you set the environment variable `MIX_OS_DEPS_COMPILE_PARTITION_COUNT`
41+
to a number greater than 1, Mix will start multiple operating system
42+
processes to compile your dependencies concurrently.
43+
44+
While Mix and Rebar will compile all files in a given project in parallel,
45+
enabling this environment variable can still yield useful gains in several
46+
cases, such as when compiling dependencies with native code, dependencies
47+
that must download assets, or dependencies where the compilation time is not
48+
evenly distributed (for example, one file takes much longer to compile than
49+
all others).
50+
51+
While most configuration in Mix is done via command line flags, this particular
52+
environment variable exists because the best number will vary per machine
53+
(and often per project too). The environment variable also makes it more accessible
54+
to enable concurrent compilation in CI and also during `Mix.install/2` commands.
55+
3856
## Command line options
3957
4058
* `--force` - force compilation of deps
@@ -57,7 +75,6 @@ defmodule Mix.Tasks.Deps.Compile do
5775
end
5876

5977
Mix.Project.get!()
60-
6178
config = Mix.Project.config()
6279

6380
Mix.Project.with_build_lock(config, fn ->
@@ -86,7 +103,7 @@ defmodule Mix.Tasks.Deps.Compile do
86103
count = System.get_env("MIX_OS_DEPS_COMPILE_PARTITION_COUNT", "0") |> String.to_integer()
87104

88105
compiled? =
89-
if count > 1 and length(deps) > count do
106+
if count > 1 and length(deps) > 1 do
90107
Mix.shell().info("mix deps.compile running across #{count} OS processes")
91108
Mix.Tasks.Deps.Partition.server(deps, count, force?)
92109
else

0 commit comments

Comments
 (0)