Skip to content
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

_with_resetted methods #574

Open
garro95 opened this issue May 27, 2018 · 1 comment
Open

_with_resetted methods #574

garro95 opened this issue May 27, 2018 · 1 comment

Comments

@garro95
Copy link

garro95 commented May 27, 2018

My idea is that, if I need to use some complex dynamic data structure in the computation, it would be better to create one of them for each thread and then clean and reuse the same structures for each item instead of cloning the structure each time.

@cuviper
Copy link
Member

cuviper commented May 29, 2018

The current _with methods don't clone for every item, only at the granularity of jobs (a split/group of items) that may be sent/stolen between threads. You can of course reset that structure for each item if you like.

We don't do this specifically per-thread, because we don't even know which thread a job is going to run on until it actually starts. We clone _with values each time we split the items, so they may be stolen to another thread. The thread pool in rayon-core doesn't actually know anything about parallel iterators, let alone these _with values.

There are some ideas for actual thread-local values in #569 though.

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

No branches or pull requests

2 participants