Should the order of cargo clippy and cargo t with different features and toolchains affect total time

⚓ Rust    📅 2025-09-03    👤 surdeus    👁️ 2      

surdeus

I want to run cargo clippy and cargo t for different combinations of features using both stable and some older version of cargo. Assuming Cargo.lock nor target/ exist and both toolchains are already installed, should the order of how I do this affect the overall time? If I had to guess, the following is the list of contributing factors in descending order:

  1. Toolchain
  2. Features
  3. Command

For example, the following sequence is the optimal sequence in terms of minimizing the total amount of time for the whole sequence to complete:

  1. cargo +<toolchain_1> <cmd_1> --no-default-features --features <features_1>
  2. cargo +<toolchain_1> <cmd_2> --no-default-features --features <features_1>
  3. cargo +<toolchain_1> <cmd_1> --no-default-features --features <features_2>
  4. cargo +<toolchain_1> <cmd_2> --no-default-features --features <features_2>
  5. cargo +<toolchain_2> <cmd_1> --no-default-features --features <features_1>
  6. cargo +<toolchain_2> <cmd_2> --no-default-features --features <features_1>
  7. cargo +<toolchain_2> <cmd_1> --no-default-features --features <features_2>
  8. cargo +<toolchain_2> <cmd_2> --no-default-features --features <features_2>

where toolchain_1 and toolchain_2 are toolchains with one of them being the stable toolchain and the other an older version, cmd_1 and cmd_2 are commands with one being clippy and the other being t, and features_1 and features_2 are different sequences (of possibly different lengths) of features where one doesn't imply the other.

Is my guess right? Does it matter what toolchain_1 and toolchain_2 are (i.e., replacing one with stable and the other with <older_version> should have different performance than if they were swapped)? Does it matter what cmd_1 and cmd_2 are (i.e., replacing one with clippy and the other with t should have different performance than if they were swapped)? Does it matter what features_1 and features_2 are (e.g., it's better to use fewer features sooner)?

I'm trying to optimize my CI flow on a single device and am curious if the order in which I do this matters (e.g., if cargo replaces certain caches when a different toolchain is used behooving one to focus on using one toolchain before using a different one in order to re-use the cache).

5 posts - 2 participants

Read full topic

🏷️ Rust_feed