Skip to content

Run test in serial by default to not take all memory #159

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 29, 2016

Conversation

jeanphilippeD
Copy link
Contributor

When running all the test in parallel, all the memory on my laptop
is consumed by rustc processes, my machine become unusable and the
tests do not make progress.

It seems to make sense to have serial by default, as the number of
process depends on the number of test files.

To run the test in parallel:
RUN_TEST_PARALLEL=1 cargo test --feature llvm_stable

This is a first approach at this issue, I'm still really new to rust.
I was trying to run the test for an easy fix, but it was killing my machine.

Ideally it would have been nice to be able to control exactly how many
process to run in parallel, maybe using chunks somewhere. I could try
to see if I can work it out if it would be a better solution.

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.

Mostly nits, the approach looks good to me, thanks for doing this!

In the future we might have something like a variable to do them in chunks of N or similar, but I agree running all the tests in parallel isn't going to scale well long-term.

IMO, we could get rid of the parallel tests now, and just eventually (and if needed) do the "run N in parallel thing".

Feel free to get rid of that functionality (I think the code might get cleaner), though preserving the functionality after an environment variable works for me too.

// one. This runs the tests in parallel rather than serially.

let children: Vec<_> = tests.map(|entry| {
let children = tests.map(|entry| {
let child = spawn_run_bindgen(run_bindgen.clone(), bindgen.clone(), entry.path());
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: can you indent this four spaces to the left while you're here? I know it was wrong before.

.collect();
});

let child_wait = |(path, mut child): (PathBuf, process::Child)| {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you make this a proper nested function (fn child_wait((path, mut child): (PathBuf, process::Child)) -> Option<(PathBuf, process::Child)> { ... }) instead, to reflect it's not capturing any state from the environment?

if passed { None } else { Some((path, child)) }
};

let failures: Vec<_> = if env::var("RUN_TEST_PARALLEL").is_ok() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Probably better to use a less-generic environment variable, like BINDGEN_PARALLEL_TEST, or something like that?

// First spawn all child processes and collect them,
// then wait on each one.
children.collect::<Vec<_>>().into_iter()
.filter_map(child_wait)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Indent this four spaces, and the similar lines below.

When running all the test in parallel, all the memory on my laptop
is consumed by rustc processes, my machine become unusable and the
tests do not make progress.

It seems to make sense to have serial by default, as the number of
process depends on the number of test files.
@jeanphilippeD
Copy link
Contributor Author

Thanks for your comments. I did not know about proper nested function.
I took your first comment, and simplified this change to only allow serial test, i agree with you that the chunk approach would be better in the long run.

@emilio
Copy link
Contributor

emilio commented Oct 29, 2016

@bors-servo: r+

Thanks for doing this!

@bors-servo
Copy link

📌 Commit c82cb6d has been approved by emilio

@bors-servo
Copy link

⚡ Test exempted - status

@bors-servo bors-servo merged commit c82cb6d into rust-lang:master Oct 29, 2016
bors-servo pushed a commit that referenced this pull request Oct 29, 2016
Run test in serial by default to not take all memory

When running all the test in parallel, all the memory on my laptop
is consumed by rustc processes, my machine become unusable and the
tests do not make progress.

It seems to make sense to have serial by default, as the number of
process depends on the number of test files.

To run the test in parallel:
RUN_TEST_PARALLEL=1 cargo test --feature llvm_stable

This is a first approach at this issue, I'm still really new to rust.
I was trying to run the test for an easy fix, but it was killing my machine.

Ideally it would have been nice to be able to control exactly how many
process to run in parallel, maybe using chunks somewhere. I could try
to see if I can work it out if it would be a better solution.
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.

4 participants