I have a function search_core(start, end) which returns a Result<Vec<SearchResult>, SearchError>, I wanna spawn multiple search_core() with different start, end inputs, so I can perform concurrent search and combine all the Vec<SearchResult> into one and return to user.
I'm new to Rust and new to rayon, anyone can help with this?
Or, is there any better way to improve the overall performance?
We don't know what search_core() does.
Also, does the par_iter() seem to have no fine-grained thread pool control instead of installing a global thread pool beforehand?
Yes. It seems so. For fine grained solution you'd probably need some other crate (tokio has such functionality, FuturesUnordered) or roll your own executor.
Check out ThreadPool::install (the name is imo misleading, as it allows you to use a local ThreadPool temporarily, without "installing" anything globally).
Yeah, although I don't see how's that a problem? You want to put your iterator chain inside it (.install(|| ... .collect())), and collect is already blocking.