Questions tagged [rayon]

A Rust data-parallelism library that makes it easy to convert sequential computations into parallel Rayon is lightweight and convenient for introducing parallelism into existing code. It guarantees data-race free executions and takes advantage of parallelism when sensible, based on work-load at runtime.

See the official documentation for more information.

123 questions
1
vote
1 answer

Why is rust's rayon taking longer with Arc>>?

I am trying to parallelize my codes using the crate rayon. The process is to read a file, process it and output the processed file. I want to take note of the result of the processing of each file such that I have an…
Jim
  • 450
  • 2
  • 10
1
vote
2 answers

Multithreaded algorithm where worker threads can schedule work

I'm trying to implement a parallel algorithm in Rust using Rayon. It seems to work fine if you can divide up the work ahead of time and assign it to threads. The problem is that I want the worker threads themselves to be able to schedule work and…
pnadeau
  • 427
  • 5
  • 8
1
vote
1 answer

Is rayon's parallelism limited to the cores of the machine?

I have the following toy Rust program: use rayon::prelude::*; use std::{env, thread, time}; /// Sleeps 1 second n times fn seq_sleep(n: usize) { for _ in 0..n { thread::sleep(time::Duration::from_millis(1000)); } } /// Launches n…
Román Cárdenas
  • 492
  • 5
  • 15
1
vote
1 answer

Which Rust RNG should be used for multithreaded sampling?

I am trying to create a function in Rust which will sample from M normal distributions N times. I have the sequential version below, which runs fine. I am trying to parallelize it using Rayon, but am encountering the…
Jage
  • 453
  • 2
  • 9
1
vote
1 answer

Rust: Is it possible to update a shared array with Rayon?

I've got an array of u8 which I will be partitioning in a complicated way. Is it possible to update it from multiple rayon tasks? Sort of like this: let mut pixels = vec![0; w * h]; rayon::scope(|s| { s.spawn(move |_s| { …
pnadeau
  • 427
  • 5
  • 8
1
vote
0 answers

Rayon: why do the two ways of sum give different results?

Here I use Rust rayon crate to compute the definite integral (left Riemann sum) of a function in parallel: use rayon::prelude::*; use rayon::ThreadPoolBuilder; use std::f64::consts::PI; fn integral_rayon_test(segments: u32, x0: f64, xn: f64,…
bczhc
  • 21
  • 1
  • 3
1
vote
1 answer

Intersecting Rayon Threadpools cause performance Overhead

I got a larger program that I can summarize like: SequentialPart ThreadPoolParallelized SequentialPart ParallelPartInQuestion SequentialPart This code gets called in sequence many times. I'm using Rayon threads to parallelize the second part such…
raycons
  • 735
  • 12
  • 26
1
vote
2 answers

Rust string comparison same speed as Python . Want to parallelize the program

I am new to rust. I want to write a function which later can be imported into Python as a module using the pyo3 crate. Below is the Python implementation of the function I want to implement in Rust: def pcompare(a, b): letters = [] for i,…
1
vote
1 answer

Use par_split on a String, process using rayon and collect result in a Vector

I am trying to read a file into a string messages defined on line #14. The file contains several blocks where each block starts with a number. After I read the file contents into the string messahes, each block is separated by newline and each line…
1
vote
1 answer

How to convert a MongoDB RawDocumentBuf to a Rust struct?

I am trying to use MongoDB rust driver with Rayon to make it faster. I know how to convert a RawDocumentBuf into a Document like this, which works really fast. let docs: Vec = coll.find(None,…
Takash Futada
  • 686
  • 6
  • 17
1
vote
1 answer

Rust rayon crate par_iter().map() "stalls" when saving images

I'm trying to learn Rust from an example on data-parallelism in this linked rust-cookbook example. However, when I run the code (with what I believe are the correct dependencies), the parallel iterator functions do not complete. This is the exact…
Jacob Goodwin
  • 354
  • 3
  • 7
1
vote
1 answer

Why does Condvar thread never wake up?

This code runs to completion and prints out the values of my_data if I uncomment the sleep line in the do_work function. If I leave it commented out, my executable hangs every time. Why does a Condvar not wake the last thread? mentions collecting…
1
vote
2 answers

Nested loops with a Rust `Sender` and the Rayon's `for_each_with()`

I have some multithreaded code that involves using a nested loop, where the inner one is run in parallel. "Shared" across each thread is a Sender that will return results. Notably Sender implements Send so there should be no problem cloning it and…
Migwell
  • 18,631
  • 21
  • 91
  • 160
1
vote
0 answers

Why isn't parallelization providing a larger speedup?

I'm trying to make a variation of a HashMap that can be extended very quickly using multithreading. I'm partitioning the data using remainders. It is working, but the speedup compared to my sequential version is surprisingly small. Here's my…
Daniel Giger
  • 2,023
  • 21
  • 20
1
vote
1 answer

What is interaction between paralel iterators from Rayon and blocking HTTP from ureq in Rust?

If I have a vec of 100 urls and make paralel iterator which makes 100 blocking HTTP requests, is the first request blocking the rest of them or can the all be made before some of them finish?
ditoslav
  • 4,563
  • 10
  • 47
  • 79
1 2 3
8 9