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 upIntroduce `join_context` which tells whether jobs were stolen #354
Conversation
This comment has been minimized.
This comment has been minimized.
|
Should the name be changed considering that |
This comment has been minimized.
This comment has been minimized.
|
I think the places you'd use this are distinct enough from futures, but I'm open to other names. |
This comment has been minimized.
This comment has been minimized.
|
I wonder if we should design this API in a more open-ended way. That is, right now it supplies a simple |
This comment has been minimized.
This comment has been minimized.
|
As an example, I think it'd potentially be useful to tell closure B whether it was stolen or not (irrespective of whether we wound up jumping into the Rayon thread-pool). Right now, closure B can't tell the difference between the two. |
This comment has been minimized.
This comment has been minimized.
|
Apart from that nit, though, I think this looks pretty nice, and I'm inclined to say I like it better than the current hack of testing which thread you are on. It feels cleaner to me to be told, particularly since it doesn't require a lot of work on our part to track that information. |
cuviper
force-pushed the
cuviper:join_notify
branch
from
2088fe5
to
c829f21
Jun 24, 2017
This comment has been minimized.
This comment has been minimized.
|
Rebased and renamed to I think that looks ok? Some gains, some losses -- seem like noise. |
nikomatsakis
reviewed
Jul 7, 2017
| /// outside the thread pool to begin with. | ||
| pub fn join_context<A, B, RA, RB>(oper_a: A, oper_b: B) -> (RA, RB) | ||
| where A: FnOnce(FnContext) -> RA + Send, | ||
| B: FnOnce(FnContext) -> RB + Send, |
This comment has been minimized.
This comment has been minimized.
nikomatsakis
Jul 7, 2017
•
Member
Hmm, I think I expected &FnContext, but I guess there's not a ton of reason for that. If we wanted to maximally future-proof, I think we would pass a FnContext<'a>, where 'a is (for the moment) just a phantom-lifetime. This would give us the ability to have FnContext grow some amount of by-reference data later.
e.g.
struct FnContext<'a> {
migrated: bool,
dummy: PhantomData<&'a ()>,
}
This comment has been minimized.
This comment has been minimized.
cuviper
Jul 7, 2017
Author
Member
Then its Default seems weird to me, which is used by the bridge functions in their starting state. Should we allow arbitrary FnContext<'a> in that case, or just FnContext<'static>?
Perhaps we should also force this !Send and !Sync if we think it might reference local state.
This comment has been minimized.
This comment has been minimized.
nikomatsakis
Jul 11, 2017
Member
Hmm I think I didn't notice that it supports Default. Maybe it's overkill to worry about this stuff anyway.
cuviper
force-pushed the
cuviper:join_notify
branch
from
d6b30b5
to
c6d3367
Sep 17, 2017
This comment has been minimized.
This comment has been minimized.
|
Rebased. |
nikomatsakis
reviewed
Sep 22, 2017
| _marker: PhantomData<*mut ()>, | ||
| } | ||
|
|
||
| impl Default for FnContext { |
This comment has been minimized.
This comment has been minimized.
nikomatsakis
Sep 22, 2017
Member
Do we really want this to support default? That means anybody can make one...?
This comment has been minimized.
This comment has been minimized.
cuviper
Sep 23, 2017
Author
Member
I thought I needed a way for the iterator bridge functions to create one -- which is as good as "anybody" as far as crate privacy goes -- but I just modified those to extract the migrated bool to pass around instead.
cuviper
force-pushed the
cuviper:join_notify
branch
from
863bc12
to
b6d4e2e
Sep 23, 2017
cuviper
referenced this pull request
Oct 5, 2017
Closed
replace the thread-id hack with `thread-id` crate #335
cuviper
force-pushed the
cuviper:join_notify
branch
from
b6d4e2e
to
acf4aad
Oct 6, 2017
cuviper
changed the title
Introduce `join_notify` which tells whether jobs were stolen
Introduce `join_context` which tells whether jobs were stolen
Oct 6, 2017
cuviper
added some commits
Jun 1, 2017
cuviper
force-pushed the
cuviper:join_notify
branch
from
acf4aad
to
a466f66
Oct 7, 2017
nikomatsakis
approved these changes
Oct 10, 2017
This comment has been minimized.
This comment has been minimized.
|
bors r+ |


cuviper commentedJun 1, 2017
•
edited
This removes the need for tracking thread-id or hacky TLS variables in
the adaptive splitter. Instead, with
join_contextthe paralleliterator internals are directly informed whether a job is executing on
its original thread or stolen elsewhere.
Note that this is insta-stable since we want to use it ourselves. We
could hide docs and/or mark it deprecated to approach stability a little
differently than the usual "unstable" feature.