-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
achive better parallelism when building deps #5014
Comments
Indeed! Right now there's no heuristics for "what crate to schedule next", and this sounds like an excellent heuristic to me. The logic would go around here |
We can do that using Hu's scheduling algorithm. This assumes that all packages take an equal amount of time to compile; that is never true, yet the best bet we can make. We'd be required to compute the path length from the top package to the ready-to-be-scheduled packages, which in turn we can do using a simple topological sort (the I'm wondering if the added complexity in |
@lukaslueg sounds plausible to me! We could actually estimate the cost of a crate via the size of all its input files probably as well if we wanted to go a bit further. In any case the And yeah AFAIK there are no cycles there. |
Historically Cargo has been pretty naive about scheduling builds, basically just greedily scheduling as much work as possible. As pointed out in rust-lang#5014, however, this isn't guaranteed to always have the best results. If we've got a very deep dependency tree that would otherwise fill up our CPUs Cargo should ideally schedule these dependencies first. That way when we reach higher up in the dependency tree we should have more work available to fill in the cracks if there's spare cpus. Closes rust-lang#5014
Improve Cargo's scheduling of builds Historically Cargo has been pretty naive about scheduling builds, basically just greedily scheduling as much work as possible. As pointed out in #5014, however, this isn't guaranteed to always have the best results. If we've got a very deep dependency tree that would otherwise fill up our CPUs Cargo should ideally schedule these dependencies first. That way when we reach higher up in the dependency tree we should have more work available to fill in the cracks if there's spare cpus. Closes #5014
Note: this is an oversimplified example.
Lets say my crate dependencies are like this:
I noticed that cargo would build C and D or E in parallel and then build B in the end and then A.
It would be smarter to realize that we can build D and E in parallel and then B and C in parallel.
before:
suggested:
The current behaviour also happens when forcing code gen units to 1.
The text was updated successfully, but these errors were encountered: