Skip to content
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

Add --partition M/N to distribute builds #253

Merged
merged 6 commits into from
Aug 8, 2024
Merged

Conversation

ryoqun
Copy link
Contributor

@ryoqun ryoqun commented Jul 16, 2024

if there are many workspace members, it takes very long to execute all runs. So, introduce --partition M/N to distribute runs across machines.

This pr is in draft still. If this addition of new flag sounds acceptable, I'll finish up it (maybe, writing tests and improve cli handling (edit: DONE), update docs?)

demo: https://buildkite.com/anza/agave/builds/7618#0190b45e-b9e3-4b64-a172-4d9fc6b52e0f

related: #180, #248 (... in the sense this is about accelerating the whole step of cargo hack in CIs)

the exact behavior is moderately mirrored from the counted partitioning of nextest: https://nexte.st/docs/ci-features/partitioning/#counted-partitioning

context: rust-lang/cargo#10958 (comment) and rust-lang/cargo#8379 (comment)

progress.count = new_count;
if skip {
return Ok(());
}

if cx.clean_per_run {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(unrelated to this pr: i don't think cargo_clean(...) is needed if cx.print_command_list == true..right?)

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. Well, both are optional and I don't know what the use case of using --clean-per-run together with -pr-int-command-list in the first place, though...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for quick reply. I'll create a small pr after this pr to fix this.

src/main.rs Outdated
Comment on lines 680 to 702
let mut msg = String::new();
if term::verbose() {
write!(msg, "skipping {line}").unwrap();
} else {
write!(msg, "skipping {line} on {}", cx.packages(id).name).unwrap();
}
write!(msg, " ({}/{})", new_count, progress.total).unwrap();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this may be subjective, but i liked explicitly printing messages about being skipped.

src/main.rs Outdated
let new_count = progress.count + 1;
let mut skip = false;
if let Some(partition) = &cx.partition {
if progress.count % partition.count != partition.index - 1 {
Copy link
Contributor Author

@ryoqun ryoqun Jul 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this again subjective as well. but it's more intuitive not to see adjusted progress (i.e. {X/N}/{Y/N}) after partitioning while showing the skip messages.

@ryoqun ryoqun force-pushed the partition branch 4 times, most recently from fa2214e to 64b44ff Compare July 16, 2024 05:16
@ryoqun
Copy link
Contributor Author

ryoqun commented Jul 18, 2024

@taiki-e hey, me again at different places. :) Could you review this in your free time?

Copy link
Owner

@taiki-e taiki-e left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! This seems to be an easy to use version of --print-command-list (#175) and would be a reasonable addition.

That said, it is usually always hard to review a PR that has no tests to indicate how it works...

src/main.rs Outdated
Comment on lines 695 to 696
if progress.count % partition.count != partition.index - 1 {
let mut msg = String::new();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIUC this would be something like:

1/4 run
2/4 skipped
3/4 run
4/4 skipped

I think this is fine for the nextest use, I guess it maybe a bit inefficient for cargo-hack use, since the feature combinations that would reduce the amount of recompilation are often before or after the current combination.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for nice suggestion. I've switched from interleaved partitioning to chunked partitioning. and seems our ci got quicker to finish: https://buildkite.com/anza/agave/builds/7952#0190d3f9-52af-4b75-9e69-e408f4a1a57e

@ryoqun ryoqun requested a review from taiki-e July 21, 2024 07:05
@ryoqun
Copy link
Contributor Author

ryoqun commented Jul 21, 2024

Hey, sorry for delayed reply... I got some time to work on this.

Thanks for the PR! This seems to be an easy to use version of --print-command-list (#175) and would be a reasonable addition.

really thanks. :)

That said, it is usually always hard to review a PR that has no tests to indicate how it works...

sorry about that. I added tests.

@ryoqun ryoqun marked this pull request as ready for review July 21, 2024 07:10
@ryoqun
Copy link
Contributor Author

ryoqun commented Jul 23, 2024

@taiki-e hi, friendly ping. :)

@ryoqun
Copy link
Contributor Author

ryoqun commented Aug 8, 2024

@taiki-e i guess, maybe this pr can't be merged soon? this pr is blocking our ci fix: anza-xyz/agave#2127, it seems that we have to install cargo-hack via our patched git repo...

Copy link
Owner

@taiki-e taiki-e left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@taiki-e taiki-e merged commit 5ba6fbc into taiki-e:main Aug 8, 2024
28 checks passed
@ryoqun
Copy link
Contributor Author

ryoqun commented Aug 8, 2024

@taiki-e just saw cargo-hack is released with this pr. now --partition is working at our ci like this: https://buildkite.com/anza/agave/builds/9044#01913215-4f43-4414-a2ae-5da9f173d9fa/170.

thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants