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
Instrumenting Async Runtime
Search
mox692
December 15, 2024
Programming
0
79
Instrumenting Async Runtime
This is a presentation I gave in the Rust.Tokyo conference 2024.
mox692
December 15, 2024
Tweet
Share
More Decks by mox692
See All by mox692
Implementing Async MPMC Channel in Rust
kimuramotoyuki
0
16
Bug-Free Concurrency in Rust
kimuramotoyuki
0
16
Other Decks in Programming
See All in Programming
What's new in AppKit on macOS 26
1024jp
0
150
Quand Symfony, ApiPlatform, OpenAI et LangChain s'allient pour exploiter vos PDF : de la théorie à la production…
ahmedbhs123
0
220
React は次の10年を生き残れるか:3つのトレンドから考える
oukayuka
7
2.4k
Python型ヒント完全ガイド 初心者でも分かる、現代的で実践的な使い方
mickey_kubo
1
240
AIと”コードの評価関数”を共有する / Share the "code evaluation function" with AI
euglena1215
1
180
코딩 에이전트 체크리스트: Claude Code ver.
nacyot
0
930
PHPでWebSocketサーバーを実装しよう2025
kubotak
0
320
AI コーディングエージェントの時代へ:JetBrains が描く開発の未来
masaruhr
1
200
Model Pollution
hschwentner
1
160
Claude Code派?Gemini CLI派? みんなで比較LT会!_20250716
junholee
1
530
テストから始めるAgentic Coding 〜Claude Codeと共に行うTDD〜 / Agentic Coding starts with testing
rkaga
15
5.6k
MDN Web Docs に日本語翻訳でコントリビュートしたくなる
ohmori_yusuke
1
130
Featured
See All Featured
Bootstrapping a Software Product
garrettdimon
PRO
307
110k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
251
21k
Intergalactic Javascript Robots from Outer Space
tanoku
271
27k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
656
60k
Build your cross-platform service in a week with App Engine
jlugia
231
18k
How GitHub (no longer) Works
holman
314
140k
Gamification - CAS2011
davidbonilla
81
5.4k
RailsConf 2023
tenderlove
30
1.1k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
126
53k
Facilitating Awesome Meetings
lara
54
6.5k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
108
19k
The World Runs on Bad Software
bkeepers
PRO
70
11k
Transcript
Instrumenting Async Runtime Rust.Tokyo 2024 Motoyuki Kimura 1
• Rust Developer 🦀 • Used to use Scala •
A organization member of tokio-rs Hi, I’m Motoyuki(@mox692) 👋 2
Agenda • Share my attempt for async runtime tracing ◦
Recap monitoring ecosystem in Async Rust ◦ What is runtime tracing? ◦ How does it works? ◦ Lessons, challenges 3
Monitoring is important 4
How to achieve a monitoring? • Logging (println!, log! etc…)
• Capture a backtrace • System metrics etc … 5
What about async Rust? 6
… Sometimes, a bit tricky 7
8 Async Task Task1 Task2 Execution
9 Async Task Task1 Task2 Execution .await .await .await
10 Async Task Task1 Task2 .await .await .await Task1 Task1
Task2 Task2
11
12
13
Are there any async-aware tools available today? 14
• Metrics • Tokio-console • Taskdump 15
16 Runtime Metrics
17
18
19
20 Task dump
21 Task dump
Would this be enough? 22
23 Case1: Tasks are not distributed Thread Core
24 Case2: Long running tasks
25 Case2: Long running tasks
26 Case3: Not sure what happens behind the scene 😇
27 • Async runtime tend to be a blackbox •
It would be cool if we have a tool that focuses on the event occurred in the runtime
Prior Art? 28
29
30
31 Goroutine Backtrace
32
33
34 It is integrated into the Java Virtual Machine (JVM)
and causes almost no performance overhead, so it can be used even in heavily loaded production environments.
Can we do something similar with Rust? 35
36
Let’s do a demo to see how it goes 37
Demo time 38
How does it work? 39
High level archtecture 40 Gathering Runtime Event Tokio Runtime Visualize
Log File Runtime thread Runtime thread Runtime thread
41 Runtime Event
42 Runtime Event Runtime Parking Run Task
43 Runtime Event Backtrace Task Name Duration
Visualize 44
Visualize 45
46
Tracing × Perfetto 47
48
49 Hacking Runtime Internal !
50
51
52 Trace Store backtrace
Challenges 53
Backtrace 54
55 Invoked for every task run!!
56 Backtrace • It is crucial to be able to
get backtraces efficiently, • Because the locations where traces are obtained are often hot paths in the runtime 🔥
57 🤔
58
59
60
61
62
Other Subtleties • Symbolize • When to capture a backtrace?
◦ For now, capture backtraces when a future returns Pending ◦ … but this means that we cannot capture a backtrace if that future complete at first poll 63
Trace Log 64
65
66 Trace related stuff
Can we do better? 67
68 Continuous Monitoring with JDK Flight Recorder (JFR)
69 Execution tracer overhaul
70 Trace Log • Should be optimized by e.g., ◦
Using thread local buffer ◦ Using a dedicated trace format
71
72 worker-trace.md
73 Thank you!