Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Implementing Async MPMC Channel in Rust
Search
mox692
February 13, 2025
Programming
53
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
29
Instrumenting Async Runtime
kimuramotoyuki
0
140
Other Decks in Programming
See All in Programming
1B+ /day規模のログを管理する技術
broadleaf
0
110
Agentic UI
manfredsteyer
PRO
0
190
コンテキストの使い捨てをやめる — ビジネスルール駆動開発と miko —
ioki
0
220
AIだと陥りがちなJakarta EE最新技術への移行時の落とし穴と解決策
tnagao7
0
120
エージェンティックRAGにAWSで入門しよう!
har1101
9
1.7k
AIを活用したE2Eテスト実装効率化のあゆみ / ebisu-mobile-14-kotetu
kotetuco
0
130
Vue × Nuxt × Oxc どこまで使える?実運用の現在地
andpad
0
290
なぜ型を書くのか? TSKaigi2026で改めて考える #tskaigi_smarthr
kajitack
0
140
Contextとはなにか
chiroruxx
1
360
Claspは野良GASの夢をみるか
takter00
0
210
過去最大のMCPアップデート! 2026-07-28 RC版の謎に迫る
licux
6
390
Vite+ Unified Toolchain for the Web
naokihaba
0
330
Featured
See All Featured
Learning to Love Humans: Emotional Interface Design
aarron
275
41k
Kristin Tynski - Automating Marketing Tasks With AI
techseoconnect
PRO
0
270
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
170
A Modern Web Designer's Workflow
chriscoyier
698
190k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
16k
How to build a perfect <img>
jonoalderson
1
5.7k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.7k
The Curse of the Amulet
leimatthew05
2
13k
Typedesign – Prime Four
hannesfritz
42
3.1k
Claude Code のすすめ
schroneko
67
230k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
YesSQL, Process and Tooling at Scale
rocio
174
15k
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