Where to read about Rust's threading advantages?

Hi all,

I'm in a HPC (high performance computing) course and having heard about Rust's safe threading everywhere ([1], [2]) I've convinced my teacher to let me make a presentation on how Rust can help shape the future of HPC. I, however, am not versed in Rust :sweat_smile: and thus I've been looking for more information.

I've read parts of the book (TRPL), but it's quite large, and I don't know if it will have enough formal explanations about the thread safety of the language.

Therefore, I ask: where can I find formal explanations about the thread safety of Rust? Specifically, I'm looking for a demonstration on how data races are impossible. That's a big topic in and of itself, so that leaves me more than happy. Should I finish reading the book? Or should I look elsewhere?

Thank you,
-- FΓ©lix

2 Likes

You might want to check out https://github.com/ctjhoa/rust-learning#ownership--concurrency and the rest of that list.

2 Likes

A good search phrase is "rust fearless concurrency". Here are a few good links that I saw from a quick glance:

4 Likes

I wrote this blog post comparing how data races are possible in concurrent Ruby code and what happens if you try to do the same thing in Rust. Note that I wrote the Rust code before Rust 1.0; updating it to modern Rust is left as an exercise for the reader :wink:

4 Likes

Awesome! More HPC'ers knowing about rust can only be a good thing!

While not about your specific topic of threading, I hope you can maybe find a few useful tidbits in these "general" threads about presenting Rust, to get a feel for how others did it before you.

Specifically valuable from there, for sheer advertising success:

Ashley Williams - How I Convinced the World's Largest Package Manager to Use Rust, and So Can You!

2 Likes

Thanks, y'all! I've read some of your links and they're pretty great :slightly_smiling_face:

This Thursday I'm making the presentation. Wish me luck! :crossed_fingers:

(PS: I'll upload it afterwards. It'll most likely be in Spanish (I live in Chile), but nevertheless! You've helped me, so I'll share it :blush: )

2 Likes

Everyone: it went really well!

Here are the slides: Pitch - Google Slides

The objective was to convince them that Rust is a well-thought idea that can (and probably will) help shape the future of systems and high performance computing. I didn't go into the nitty-gritty details of ownership/borrowing/(threading primitives) or anything like that, because I only had 15 minutes.

I did convince them that Rust interops really well with C and C++ and can be used to extend the existing codebases without affecting performance. And I also convinced them that Rust has no data races :tada: . I also showed how easy it is to have undefined behavior in C++, and how the compiler in Rust will see that instead and help you avoid it.

At least 3 or 4 people asked questions, which in a course of 10 is not bad :slight_smile: I think one or two might actually check out Rust.

For the two Demo sections (Demo 0&1 and then Demo 2), I used these:

  • Demo 0: I showed the C main with malloc but w/o free v/s the same in Rust (which of course, frees the memory), from A new introduction to Rust | Next.js Blog Example with Markdown
  • Demo 1: from the same post, I showed the C++ main that crashed after trying to read from an invalidated pointer, v/s the same in Rust which triggers a compile-time error.
  • Demo 2: I prepared the Rayon demos, but I was just short in time. Still, I managed to explain how Rayon allows Data Parallelism v/s how OpenMP does it, and I was pretty satisfied :slight_smile:

Thanks, y'all. I had a great time, and I learned a lot.

PS: fwiw, rustup was ridiculously easy to set up and use. I'm so grateful for good tools :relieved:. I think it's the easiest language I've ever tried to set up in my machine!

PPS: the slides ended up being in spanglish :sweat_smile: I guess that's how I can better express myself. I think half of the time in English.

6 Likes

Nice going! Thanks for sharing back!

I browsed through them, and even though I don't speak Spanish, I could follow enough to recognise the build-up of your argument.
Nicely done! I especially appreciate your argument on slide 9 that we shouldn't throw away the thousands of hours invested in C/C++ infrastructure. Great examples! The Rust Evangelism Strike Force will certainly appreciate that! (No sarcasm, they advocate only well-considered "rewrite-it-in-Rust")

1 Like