TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

24 days of Rust – Rayon

205 pointsby zsiciarzover 8 years ago

4 comments

pcwaltonover 8 years ago
Rayon is definitely the best parallelism library I&#x27;ve ever used. We recently switched Servo over to using it for parallel restyling and layout and saw small gains in performance over our previous solution and <i>drastic</i> reduction in code complexity (and removed a whole pile of domain-specific unsafe code).<p>Being able to switch .iter() to .par_iter() and have things &quot;just work&quot; is a game changer.<p>The crucial thing about rayon is that sequential fallback is <i>really fast</i>, almost as fast as the sequential code you&#x27;d write anyway. This is important because, as paradoxical as it sounds, most CPU-bound programs work with small workloads most of the time, and so they don&#x27;t want the overhead of parallelism for those cases. (It&#x27;s the analogue of saving power by putting the CPU to sleep when it&#x27;s not in use.) The occasional big workload that comes along is what you really want parallelism for, and the big trick is to handle that case without regressing the common sequential case. Rayon&#x27;s work stealing approach based around scoped iterators is the ideal solution for this.
评论 #13099982 未加载
评论 #13099721 未加载
评论 #13097877 未加载
评论 #13098070 未加载
Animatsover 8 years ago
This is very nice. In Rust, if you accidentally share mutable data between threads, the borrow checker should catch it at compile time. Few other languages catch such errors. Go, for example, does not. This makes writing parallel code much, much safer.
lukaslalinskyover 8 years ago
I have not done any real programming in Rust, but whenever I see Rust code I&#x27;m amazed how different is it from Go, despite both having some shared use cases. Go&#x27;s main selling point beyond concurrency is simplicity. And it&#x27;s the simplicity that I like about it. On the other hand, it looks to me like Rust is turning into Scala.
评论 #13097663 未加载
评论 #13097787 未加载
评论 #13098298 未加载
评论 #13097682 未加载
评论 #13098268 未加载
评论 #13098275 未加载
评论 #13097980 未加载
评论 #13097687 未加载
评论 #13099653 未加载
评论 #13098103 未加载
ceronmanover 8 years ago
Rayon seems very similar to Java 8 Parallel Streams or C# Parallel LinQ. What are the advantages&#x2F;disadvantages of the Rust approach?
评论 #13097670 未加载
评论 #13097696 未加载