-
Notifications
You must be signed in to change notification settings - Fork 501
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
Replace weights with split length control #260
Conversation
src/iter/internal.rs
Outdated
min: cmp::max(min, 1), | ||
}; | ||
|
||
let max_splits = len / cmp::max(max, 1); |
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.
I feel this logic merits a comment =)
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.
Ideally, with a few examples that show how different min/max/len combinations work out
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.
I'm a bit confused by the max_splits
computation here, actually. So in particular if the default is that max
is usize::MAX
, then wouldn't max_splits
almost always be 0
? I guess tomorrow I'll have to trace this out in more detail.
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.
Perhaps it's poorly named - it represents the number of splits derived from the max, and just below it's only used if it's more than the normal splitter would have used.
I'll fill in a comment later. Thanks for looking it over!
OK, added some comments, and flipped the name of that variable. Hope it makes sense now! :) I still need to address the TODOs, but I threw in some quick additions to the join benchmarks.
At least |
src/iter/internal.rs
Outdated
@@ -133,7 +133,14 @@ pub trait UnindexedProducer: Send + Sized { | |||
/// job is actually stolen into a different thread. | |||
#[derive(Clone, Copy)] | |||
struct Splitter { | |||
|
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.
Nit: extra newline? Is this what rustfmt produces?
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.
Nah, that's my doing. I go back and forth on preferring a blank line before doc comments, but I'll remove it if you find this nit-worthy. :)
src/iter/internal.rs
Outdated
let max_splits = len / cmp::max(max, 1); | ||
if max_splits > splitter.inner.splits { | ||
splitter.inner.splits = max_splits; | ||
// Divide the given length by the max working lenght to get the minimum |
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.
Nit: "lenght"
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.
ack
This all seems quite good. I do have one bikeshed-y question: the name I can't really find a comparable thing in the existing iterator API to guide the naming here. |
With respect to this question:
Probably that would be the nice thing to do, but we should be sure to file an issue to remove them before we release the real 1.0. |
I added some tests, and renamed to Incidentally, I tried |
I'm inclined to merge this at this point. Not sure if you had plans to add a "representative benchmark"? |
The benchmark todo comes from your emphasized requirement in #111. If you're satisfied as-is, so am I. 😀 |
@cuviper heh, fair. Well, I'm not sure what such a benchmark would be just now, but at least we have an unrepresentative one. =) Actually, I think that the "do a lot of tiny tiny work" isn't such a bad thing to measure, I guess. |
I struck out the benchmark TODO, as I think we agreed on gitter that we don't really need to worry about that. Ready to merge? |
@cuviper yep -- my only concern was the "merge from master" commit, did you want to rebase instead? |
Merge commits don't bother me, but I can rebase later today if you prefer. |
Rebased. |
This adds
with_min_len
andwith_max_len
onIndexedParallelIterator
to control the length of the splits that will be used in each thread. Rayon will try to split iterators to lengths within this range, without making guarantees about where in the range it will fall. If the min and max are at odds, the min wins.(e.g. with any
2 * min > max
, say min=10 and max=15, we can't split length=16 further.)Fixes #111?
TODO:
Add "representative" benchmarks