Skip to content

idea for further improvement of build scheduling #5125

@matthiaskrgr

Description

@matthiaskrgr

I'm trying to understand #5100
Lets assume we have a dependency tree like this

      ROOT CRATE
    /   |   |   \
   A    B   C    D
 / |    |
E  F    G
|       | \
H       I  J
|          |
K          L
           |
           M

depth annotation would be something like this?

     1ROOT CRATE
    /   |   |   \
  2A   2B   2C  2D
 / |    |
3E 3F  3G
|       | \
4H     4I  4J
|          |
5K        5L
           |
          6M

as far as I understand, build order will be like this:

     14ROOT CRATE
    /   |   |   \
  10A  11B 12C  13D
 / |    |
7E 8F  9G
|       | \
4H     5I  6J
|          |
2K        3L
           |
          1M

It might be useful to not only take depth but also the number of child nodes (in braces) into account, like this:

         1(14)ROOT CRATE--,
        /    |     \     `\
   ,-2(5)A  2(6)B  2(1)C  2(1)D
  /      |    |
3(3)E 3(1)F  3(5)G-,
  |          |      \
4(2)H      4(1)I  4(3)J
  |                 |
5(1)K             5(2)L
                    |
                  6(1)M

If we have several crates of equal depth, we could look at the number of child nodes and prioritize the crate with the most (total) child nodes (assuming that crates with a lot of dependencies are bigger that those with only few dependencies).
New build order:

     14ROOT CRATE
    /   |   |   \
  11A  10B 12C  13D
 / |    |
8E 9F  7G
|       | \
5H     6I  4J
|          |
2K        3L
           |
          1M

Does this sound resonable?

edit: aid for debugging RUST_LOG=cargo::core::compiler::job_queue cargo check

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions