Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upTests output to global stdout #597
Comments
This comment has been minimized.
This comment has been minimized.
Also note the reason given on that unstable feature: "this function may disappear completely or be replaced with a more general mechanism", with no tracking issue. Even with that, it's complicated. We would have to update this every time we steal a job, including when a job is pulled from the global injector queue (coming from outside the threadpool). Save the old value, clone the remote value (how?) to set locally, then restore the saved value on return. Writes would have to be synchronized too, because the handle as-is only requires |
cuviper
added
the
enhancement
label
Sep 17, 2018
This comment has been minimized.
This comment has been minimized.
|
Within a rayon::scope(|_| { some_vec.par_iter().for_each(|i| i.method();) }) |
This comment has been minimized.
This comment has been minimized.
|
A scope does not imply a separate threadpool. Calling |
This comment has been minimized.
This comment has been minimized.
|
For reference, there's also rust-lang/rust#42474. But as you noted there, they probably couldn't deal with a threadpool like Rayon automatically. |
This comment has been minimized.
This comment has been minimized.
|
I guess an example would be best. Basically, it'd be nice to be able to do: #[test]
fn my_test() {
// This API doesn't exist either.
// This code could be wrapped up in a `test_pool()` utility function though.
let output = std::stdio::get_stdio();
let pool = rayon::ThreadPoolBuilder::new().with_output(&output).build();
pool.install(|| my_rayon_using_fn());
}Would that |
This comment has been minimized.
This comment has been minimized.
|
With some appropriate get/set methods from |
This comment has been minimized.
This comment has been minimized.
|
I think a start handler could also set the output, without any changes required in Rayon. |
mathstuf commentedSep 17, 2018
When running a test with
cargo testwhich usesrayon, workers which useprint!(e.g., from a stub logging implementation) skip the test-local output and don't get buffered/hidden/etc.Is there some way using the
scopeAPI to set the output handler for the thread pool in use? I'm guessing something new would need to be added. Note that it would seem to require theset_stdiounstable feature, but I'm interested in having some way inrayonavailable once it is stable.