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

[WIP] Add a way to create scopes with a single lifetime #1

Closed
wants to merge 13 commits into from

Conversation

Zoxc
Copy link

@Zoxc Zoxc commented Mar 24, 2019

@cuviper
Copy link
Member

cuviper commented Mar 25, 2019

I don't understand what you would use this for.

@Zoxc
Copy link
Author

Zoxc commented Mar 25, 2019

This avoids the need to use 2 lifetimes in order to use Rayon scopes. You just need one.

@cuviper
Copy link
Member

cuviper commented Mar 25, 2019

Oh, like you're storing the &Scope somewhere, so you don't want the extra & lifetime?

@Zoxc
Copy link
Author

Zoxc commented Mar 25, 2019

Yeah.

@Zoxc Zoxc force-pushed the alt_scope branch 2 times, most recently from 8f501ba to 929579c Compare April 13, 2019 09:31
@Zoxc Zoxc changed the title Add a way to create scopes with a single lifetime [WIP] Add a way to create scopes with a single lifetime Apr 22, 2019
@Zoxc Zoxc force-pushed the rustc branch 2 times, most recently from da4fbb8 to 4b574ba Compare April 25, 2019 20:46
nikomatsakis pushed a commit that referenced this pull request Oct 7, 2019
615: Implement RFC #1: FIFO spawns r=nikomatsakis a=cuviper

This implements rayon-rs/rfcs#1, adding `spawn_fifo`, `scope_fifo`, and `ScopeFifo`, and deprecating the `breadth_first` flag.

Fixes rayon-rs#590.
Closes rayon-rs#601.

Co-authored-by: Josh Stone <cuviper@gmail.com>
nikomatsakis pushed a commit that referenced this pull request Oct 7, 2019
These adaptors consume may many elements before deferring to a base
folder's fullness checks, and so they need to be performed
manually. For the `filter`s, there's no way to do it manually (rayon-rs#632),
so the specialisations just have to be removed. For `fold` and
`find_any` this can be done with a `take_while`.

This extends the octillion tests to confirm this behaviour.

This makes a program like the following slightly slower compared to
the direct `consume_iter` without a check, but it's still faster than
the non-specialized form.

```
extern crate test;
extern crate rayon;
use rayon::prelude::*;

fn main() {
    let count = (0..std::u32::MAX)
        .into_par_iter()
        .map(test::black_box)
        .find_any(|_| test::black_box(false));
    println!("{:?}", count);
}
```

```
$ hyperfine ./find-original ./find-no-check ./find-check
Benchmark #1: ./find-original
  Time (mean ± σ):     627.6 ms ±  25.7 ms    [User: 7.130 s, System: 0.014 s]
  Range (min … max):   588.4 ms … 656.4 ms    10 runs

Benchmark #2: ./find-no-check
  Time (mean ± σ):     481.5 ms ±  10.8 ms    [User: 5.415 s, System: 0.013 s]
  Range (min … max):   468.9 ms … 498.2 ms    10 runs

Benchmark #3: ./find-check
  Time (mean ± σ):     562.3 ms ±  11.8 ms    [User: 6.363 s, System: 0.013 s]
  Range (min … max):   542.5 ms … 578.2 ms    10 runs
```

(find-original = without specialization, find-no-check = custom
`consume_iter` without `take_while`, find-check = this commit)
@Zoxc Zoxc mentioned this pull request Jan 6, 2020
@Zoxc Zoxc closed this Jan 6, 2020
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

Successfully merging this pull request may close these issues.

2 participants