Skip to content

Run test in parallel batches #167

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

Merged
merged 1 commit into from
Oct 30, 2016

Conversation

jeanphilippeD
Copy link
Contributor

No description provided.

@jeanphilippeD
Copy link
Contributor Author

I was having a try at implementing this, most of this code is new to me
so i don't know if there are better way to achieve the same result.

Follow review suggestion to use chunks to run test in parallel.
Set default to 16 which works well even on my limited laptop,
and which should benefit better machine.

To run with a different batch size:
BINDGEN_TEST_BATCH_SIZE=32 cargo test

On my machine:
1 parallel test takes 3'53
2 parallel test takes 2'10
8 parallel test takes 2'08
32 parallel test takes 2'07

Copy link
Contributor

@emilio emilio left a comment

Choose a reason for hiding this comment

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

r=me with that, thanks so much for doing this!


let batch_size = env::var("BINDGEN_TEST_BATCH_SIZE")
.ok()
.map(|x| x.parse::<usize>().ok())
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: use and_then here and you'll save the following unwrap_or(None).

.ok()
.map(|x| x.parse::<usize>().ok())
.unwrap_or(None)
.unwrap_or(16);
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you move this number to a constant at the top of the file?

let passed = child.wait()
.expect("Should wait on child process")
.success();

if passed { None } else { Some((path, child)) }
})
.collect();
})
.flat_map(|x| x )
Copy link
Contributor

Choose a reason for hiding this comment

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

use flat_map above (children.flat_map(), and you can remove this line.

Follow review suggestion to use chunks to run test in parallel.
Set default to 16 which works well even on my limited laptop,
and which should benefit better machine.

To run with a different batch size:
BINDGEN_TEST_BATCH_SIZE=32 cargo test

On my machine:
1 parallel test takes 3'53
2 parallel test takes 2'10
8 parallel test takes 2'08
32 parallel test takes 2'07
@jeanphilippeD
Copy link
Contributor Author

Thank you very much for your comments, they were very helpful.

@KiChjang
Copy link
Member

@bors-servo r=emilio

@bors-servo
Copy link

📌 Commit 0762243 has been approved by emilio

@bors-servo
Copy link

⌛ Testing commit 0762243 with merge 3d87789...

bors-servo pushed a commit that referenced this pull request Oct 30, 2016
@bors-servo
Copy link

☀️ Test successful - status-travis

@bors-servo bors-servo merged commit 0762243 into rust-lang:master Oct 30, 2016
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.

5 participants