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
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
mox692
February 13, 2025
Programming
0
46
Implementing Async MPMC Channel in Rust
mox692
February 13, 2025
Tweet
Share
More Decks by mox692
See All by mox692
Bug-Free Concurrency in Rust
kimuramotoyuki
0
22
Instrumenting Async Runtime
kimuramotoyuki
0
130
Other Decks in Programming
See All in Programming
PHP 7.4でもOpenTelemetryゼロコード計装がしたい! / PHPerKaigi 2026
arthur1
1
420
GC言語のWasm化とComponent Modelサポートの実践と課題 - Scalaの場合
tanishiking
0
130
2026-03-27 #terminalnight 変数展開とコマンド展開でターミナル作業をスマートにする方法
masasuzu
0
190
「接続」—パフォーマンスチューニングの最後の一手 〜点と点を結ぶ、その一瞬のために〜
kentaroutakeda
4
2k
Reactive ❤️ Loom: A Forbidden Love Story
franz1981
2
170
AWS×クラウドネイティブソフトウェア設計 / AWS x Cloud-Native Software Design
nrslib
16
3.4k
今からFlash開発できるわけないじゃん、ムリムリ! (※ムリじゃなかった!?)
arkw
0
150
今年もTECHSCOREブログを書き続けます!
hiraoku101
0
160
Smarter Angular mit Transformers.js & Prompt API
christianliebel
PRO
1
100
守る「だけ」の優しいEMを抜けて、 事業とチームを両方見る視点を身につけた話
maroon8021
3
1.4k
AI時代の脳疲弊と向き合う ~言語学としてのPHP~
sakuraikotone
1
1.6k
Claude Codeログ基盤の構築
giginet
PRO
7
3.7k
Featured
See All Featured
SERP Conf. Vienna - Web Accessibility: Optimizing for Inclusivity and SEO
sarafernandez
1
1.4k
Designing Powerful Visuals for Engaging Learning
tmiket
0
300
What does AI have to do with Human Rights?
axbom
PRO
1
2.1k
Navigating Algorithm Shifts & AI Overviews - #SMXNext
aleyda
1
1.2k
Ethics towards AI in product and experience design
skipperchong
2
240
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs
inesmontani
PRO
3
3.2k
Introduction to Domain-Driven Design and Collaborative software design
baasie
1
660
Imperfection Machines: The Place of Print at Facebook
scottboms
269
14k
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
2
250
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3.1k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
26
3.4k
GitHub's CSS Performance
jonrohan
1032
470k
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