-
Notifications
You must be signed in to change notification settings - Fork 24
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
[Environment] little Runner refactorings #31
Conversation
This will be merged in PR #30 when approved |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good.
I just realized that fn run_with(…)
does in fact not make any sense. It used to, when Configuration
was still passed to it instead of fn new(…)
. Mea culpa. 😇
src/runner/mod.rs
Outdated
})); | ||
let threads = if self.configuration.parallel { 0 } else { 1 }; // 0 is rayon default | ||
let rayon_config = rayon::Configuration::new().num_threads(threads); | ||
let _ = rayon::initialize(rayon_config); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might want to only call rayon::initialize(…)
if threads
is 1
, if it is we might want to check for the function's result and log an error message if appropriate?
/// If you do not call this function, the thread pool
/// will be automatically initialized with the default
/// configuration.
/// Initialization of the global thread pool happens exactly
/// once. Once started, the configuration cannot be
/// changed. Therefore, if you call `initialize` a second time, it
/// will return an error. An `Ok` result indicates that this
/// is the first initialization of the thread pool.
(Source)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reasoning being that more than a single runner can be created via rspec, each calling into rayon::initialize(…)
. 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Frankly, I didn't touched it because I don't want to break anything, but I'd much rather don't call rayon at all when parallelism is disabled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By moving the block within par_iter()
into a dedicated method we should be able to simply use an if self.configuration.parallel { … } else { … }
. 🤔
0dc2019
to
c324419
Compare
Commit c324419 removes the need for |
33cb3f7
to
cc6d121
Compare
cc6d121
to
8980978
Compare
_with
variants in the Runner