@killercup I think you have better opinions on this than I. I would just like to express my experiences integrating rayon directly into ergo_sync and see whether it is actually a dependency we want/need. @llogiq you might be interested too.
First off, rayon is a fantastic library. ergo_sync mentions it as a crate you probably want to use for parallel processing at the top of its docs.
However, I am still unclear what the cost of rayon is. A couple of questions I would like answered before we assume rayon should be included:
- What are the runtime costs of including rayon if rayon is never used? It has a zero-configuration global thread pool -- does that always exist, or is it only created when needed?
- What are the actual use cases of rayon? It seems that "trivially parallel processing of collections" is the only answer. It is generally not considered best practice to use rayon for:
- "normal" thread pool that might be IO bound -- rayon is for performing real work, not as a general thread pool.
- message passing / channels, as rayon does not guarantee more than one thread is running at a time (which could cause deadlock)
- What is the story of TLS (i.e. thread local variables) with rayon? I swear I found a doc saying their use was "undefined behavior" but I cannot find it again.
When I tried to use rayon for the examples in ergo_sync I found that I couldn't because of the above issues, which concerned me when including it as a core part of the parallel processing story. I found that spawn with channels accomplished pretty much everything needed, and did it very expressively with few surprises and probably very performantly as well. The way I see it, the main use of rayon is to do parking_lots of data that can be split into chunks and processed in paralel.
I would like to include rayon because it really is useful for parallel processing. Honestly par_sort() alone probably makes it a worthwhile library. However I would like to understand the pros/cons/usecases before we include it.
@killercup I think you have better opinions on this than I. I would just like to express my experiences integrating rayon directly into
ergo_syncand see whether it is actually a dependency we want/need. @llogiq you might be interested too.First off, rayon is a fantastic library.
ergo_syncmentions it as a crate you probably want to use for parallel processing at the top of its docs.However, I am still unclear what the cost of rayon is. A couple of questions I would like answered before we assume rayon should be included:
When I tried to use
rayonfor the examples inergo_syncI found that I couldn't because of the above issues, which concerned me when including it as a core part of the parallel processing story. I found thatspawnwith channels accomplished pretty much everything needed, and did it very expressively with few surprises and probably very performantly as well. The way I see it, the main use of rayon is to doparking_lotsof data that can be split into chunks and processed in paralel.I would like to include rayon because it really is useful for parallel processing. Honestly
par_sort()alone probably makes it a worthwhile library. However I would like to understand the pros/cons/usecases before we include it.