Skip to content

Start long dependency chains first in deps.partition - #16193

Closed
pmargreff wants to merge 1 commit into
elixir-lang:mainfrom
pmargreff:deps-partition-chain-length
Closed

pmargreff wants to merge 1 commit into
elixir-lang:mainfrom
pmargreff:deps-partition-chain-length

Conversation

@pmargreff

Copy link
Copy Markdown
Contributor

With MIX_OS_DEPS_COMPILE_PARTITION_COUNT, each free partition gets the first dependency, in converger order, whose children have compiled. The converger order says nothing about how much work comes after each dependency, so the start of a long chain can wait behind small dependencies that nothing depends on. Near the end of the build, the other partitions then have nothing to compile while that chain compiles on one of them, and the CPU sits idle.

This PR sorts the dependencies by the length of their longest chain of dependents, so the start of a long chain is sent first.

It replaces #16171, which sorted by source size, following the discussion there: chain length is as fast and simpler. Across nine projects at 2 to 12 partitions, builds take 4.0% less time than main (1.0% less than with source size). The full results, charts and the comparison with the other orders are in this comment, and the benchmark script, data and notebooks in https://github.com/pmargreff/mix-deps-partition-benchmark.

build-time-intervals
CPU idle (chart) idle-cpu

AI disclosure

I used Claude Code (Claude Opus 5.5) to write the change and its tests and to run the benchmarks. I reviewed and validated the code and the results myself.

Each free partition gets the first dependency whose children have
compiled. Sort the dependencies once by the length of their longest
chain of dependents, so the start of a long chain does not wait behind
dependencies nothing depends on. Ties keep the topological order.

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Pablo Margreff <pmargreff@gmail.com>
@josevalim

Copy link
Copy Markdown
Member

Merged locally, pushing soon, thank you!!!

@josevalim josevalim closed this Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants