Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Implementing Async MPMC Channel in Rust
Search
mox692
February 13, 2025
Programming
64
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Implementing Async MPMC Channel in Rust
mox692
February 13, 2025
More Decks by mox692
See All by mox692
Bug-Free Concurrency in Rust
kimuramotoyuki
0
44
Instrumenting Async Runtime
kimuramotoyuki
0
160
Other Decks in Programming
See All in Programming
Vue Fes Japan の “作る側”に関わってみて
naokihaba
0
160
sbt 2.0: takeoff
eed3si9n
0
160
re:Inventに行く前に知っておきたい現地参加のノウハウ
nokomoro3
0
430
Domain-Driven Transformation
hschwentner
2
2.3k
外から家のPCの電源入れたい!をPHPで解決する
kawashimo0
1
130
Railsのためのパスキー実践入門 〜マルチテナントSaaSでの意思決定〜
utakaha
2
570
現場と育てるRailsモデリング 〜Spreadsheetから始めたモデル設計〜
siroemk
2
600
ハーネス設計入門 〜 基礎知識の整理から実務へのステップアップ 〜
kinopeee
28
32k
月間100万人のサービス刷新で、 技術選定をHonoに振り切った話
yutobara
8
6.6k
當我們開始不讀 Code - AI Agent 時代,Code Review 與 Clean Code 還剩下什麼?
jame2408
1
230
Simple Storage Service(S3) is not simple
iwatsukayura
0
290
Agents on Rails - Rails at Scale 2026
irinanazarova
0
560
Featured
See All Featured
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.6k
[SF Ruby Conf 2025] Rails X
palkan
3
1.5k
Utilizing Notion as your number one productivity tool
mfonobong
4
620
SEO for Brand Visibility & Recognition
aleyda
0
4.8k
The #1 spot is gone: here's how to win anyway
tamaranovitovic
4
1.2k
Measuring & Analyzing Core Web Vitals
bluesmoon
9
1k
Ecommerce SEO: The Keys for Success Now & Beyond - #SERPConf2024
aleyda
1
2.2k
Product Roadmaps are Hard
iamctodd
55
13k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
35
2.9k
How to make the Groovebox
asonas
2
2.5k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
How Software Deployment tools have changed in the past 20 years
geshan
2
35k
Transcript
Implementing Async MPMC Channel in Rust Motoyuki Kimura 1
MPMC Channel? • Multi Producer Multi Consumer Channel • i.e.
have multiple senders and multiple receivers 2 Sender Sender Sender Receiver Receiver
Channel Types • Bounded / Unbounded • Async / Sync
• SPSC, MPSC, MPMC 3
Prior Art 4 kind bounded / unbounded sync / async
std::mpmc mpmc, mpsc, etc both sync crossbeam mpmc, mpsc, etc both sync async_channel mpmc both async kanal mpmc both sync/async Go channel mpmc both async
How do channels work? 5
• Allocate a fixed length area Bounded 6 Sender Receiver
Bounded 7 AAA BBB CCC Sender Receiver sender.send(CCC)
Bounded 8 BBB CCC Sender AAA Receiver
Bounded 9 HHH DDD EEE FFF GGG Sender CCC Receiver
Bounded 10 Sender Receiver • If there is no available
data, reader would block Block!
Bounded 11 HHH III CCC DDD EEE FFF GGG Sender
Receiver • If receiver is too slow, sender would block Block!
Bounded 12 HHH DDD EEE FFF GGG Sender Sender Sender
Receiver Receiver • Actually, multiple senders and receivers work concurrently
Implementation Details 13
How to achieve block/unblock? 14
Block / Unblock 15 • Sync channel ◦ thread api
(park, unpark) • Async channel ◦ waker api
Block / Unblock 16 Sender Receiver Block!
Block / Unblock 17 Sender Receiver Waker Waker list •
When block happens, store waker somewhere
Block / Unblock 18 CCC Sender Receiver Waker1 Waker list
• When block happens, store waker somewhere Pop from list
Depth of Wakerlist … 🚀 19 • For wakerlist, intrusive
linked list would be much performant ◦ What are intrusive linked lists? ◦ new internal semaphore based on intrusive lists
How to test concurrent code base? 20
How to test concurrent code base? 21 • Multi threaded
• Complex synchronization • Atomic Operations
How to test concurrent code base? 22
How to test concurrent code base? 23 Detect Deadlocks! 🙌
About Loom internals … 24 Video 🎥: https://youtu.be/-MRCgyiCxWU?si=a4NNwSxVgke6AFwZ Slide 📝:
https://speakerdeck.com/kimuramotoyuki/bug-free-concurrency-in-rust
25 https://crates.io/crates/chunnel
Thank you! 26