Parallel problems to showcase Rust features

Hey.

For a project I'm writing a comparative study of parallel programming languages (e.g. Chapel, Julia) and I'm thinking about throwing Rust into the mix.

I'm having some trouble coming up with good problems to solve and I'm reluctant to just do matrix multiplication/physics problems (because where is the fun in that :slight_smile:) . I've already implemented parallel k-means and Dijkstra algorithms and so I'm looking for some similar problems to solve.

So I decided to reach out to the community to get some feedback on what kind of parallel algorithms/problems would be interesting to solve and would showcase Rust fearless concurrency.

Thank you for your help!

3 Likes

Parallel recursive directory traversal.

4 Likes

Ooh, from your own experience on ripgrep, isn't that frought with edge-cases? (Because filesystem..)

I am unsure if that is good or bad for such a language comparison.


To also add a suggestion: some simple for of map-reduce, applying a trivial formula (e.g. squaring) to a big list of numbers.
This can show how verbose the "boilerplate" needs to be in each language.
Feel free to copy my Rust-by-Example version of summing as an example.

1 Like

I can't provide any code, but parallel microsimulation is a pretty nice fit.

... 60x faster than the original code, too (on one particular data set on one particular machine, results may vary, please consult your doctor if you experience repeated unnatural benchmark numbers).

The "fearless" part becomes most useful in the larger, messier projects, which almost by definition aren't good to demonstrate in a study/blog post.

For example, I was generating sub pages for crates.rs website. That process gathers and processes lots of data from multiple sources, using many libraries. To make it parallel I've merely changed iter() into par_iter() (thanks Rayon!) and Rust warned me that a library I used for getting info from GitHub uses another library, which is not thread-safe. I would have never suspected it myself, and probably I wouldn't know until I got garbage data once in a while and spent a day in debugger digging into multiple layers of depdendencies.

10 Likes

Rust helps the long-term maintenance of parallel code too. You might start with clean code that's obviously safe for parallelism, but over time it might get messier. Rust will still stop you if you try to make a change that would break thread safety! Fearless concurrency includes fearless refactoring.

4 Likes