Will Rayon's into_par_iter() create a system threads for each iterm?

I have found that into_par_iter() creates far more system threads than rayon's global thread pool's size which I set explictly by:

 ThreadPoolBuilder::new().num_threads(num).build_global().unwrap();

If this is true, is there any way to limit the threads created by into_par_inter() to the size of the thread pool?

You must be doing something else wrong (e.g., calling build_global() after you have already used some other functionality that required configuring the global thread pool), since the documentation explicitly states that num_threads will be respected:

If you specify a non-zero number of threads using this function, then the resulting thread-pools are guaranteed to start at most this number of threads.

2 Likes

into_par_iter doesn't create threads, it uses those of the pool in the current scope (or the global one, if you're not inside any scope).

3 Likes