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
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
mox692
February 13, 2025
Programming
58
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
41
Instrumenting Async Runtime
kimuramotoyuki
0
160
Other Decks in Programming
See All in Programming
「AI時代、配布するPythonコードをどう守るか: 難読化の実験と判断軸」 #PyconJP2026
pkshadeck
PRO
2
190
ソフトウェアラスタライザ
fadis
1
800
Webの地図
yosuke_furukawa
PRO
6
3.9k
自分的「カンファレンスの楽しみ方」
syumai
0
200
アクセシビリティから考える情報設計
high_g_engineer
0
350
ALB ログから Trace を気合で繋げる技術
fohte
7
880
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
180
go-spidermonkeyでAIエージェントのCode Modeを実装する
syumai
3
1.5k
AIの中の人になってみる
htkym
0
170
Can LLMs Replicate 4 Years of Compose Migration? Exploring the boundaries of automation with 279 XML files from a real product
makun
0
130
AIエージェント時代のコードレビューを設計する
nogu66
6
2.6k
信頼性の目標を誰も求めてない
shubox
0
500
Featured
See All Featured
Building Applications with DynamoDB
mza
96
7.2k
Introduction to Domain-Driven Design and Collaborative software design
baasie
1
980
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
280
Build The Right Thing And Hit Your Dates
maggiecrowley
39
3.4k
Done Done
chrislema
186
16k
The Power of CSS Pseudo Elements
geoffreycrofte
82
6.6k
Speed Design
sergeychernyshev
33
2.1k
Large-scale JavaScript Application Architecture
addyosmani
515
110k
The AI Search Optimization Roadmap by Aleyda Solis
aleyda
1
6.2k
Color Theory Basics | Prateek | Gurzu
gurzu
0
460
Claude Code どこまでも/ Claude Code Everywhere
nwiizo
67
58k
sira's awesome portfolio website redesign presentation
elsirapls
0
410
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