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
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
mox692
December 15, 2024
Programming
150
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Instrumenting Async Runtime
This is a presentation I gave in the Rust.Tokyo conference 2024.
mox692
December 15, 2024
More Decks by mox692
See All by mox692
Implementing Async MPMC Channel in Rust
kimuramotoyuki
0
55
Bug-Free Concurrency in Rust
kimuramotoyuki
0
32
Other Decks in Programming
See All in Programming
改善しないと、タスクが回らない。 “てんこ盛りポジション” を引き継いだ情シスの、入社3ヶ月の業務改善録
krm963
0
110
吝嗇家のためのAI活用 / AI development for miser - ChatGPT + Issue Driven Development
tooppoo
0
190
アルゴリズムは何を圧縮しているのか ─ Haskell から育った「圧縮代数」というメンタルモデル
naoya
16
3.6k
はてなアカウント基盤 State of the Union
cockscomb
1
1.3k
人間の目はかわらない、だからJPEGは30年もつ
yuzneri
1
420
PHP Application における Kubernetes 内 gRPC 通信
ganchiku
0
530
共通化で考えるべきは、実装より公開する型だった
codeegg
0
270
Hatena Engineer Seminar #37「言語モデルの活用に関する研究」
slashnephy
0
540
2年かけて Deno に DOMMatrix を実装した話 / How I implemented DOMMatrix in Deno over two years
petamoriken
0
110
AI がコードを書く時代における新卒エンジニアの仕事風景 (2026) / New Graduate Engineers in the Era of AI Coding (2026)
sushichan044
0
230
What's New in Android 2026
veronikapj
0
140
AI駆動開発を妨げる技術的負債の解消アプローチ / ai-refactoring-approach
minodriven
17
9.3k
Featured
See All Featured
How Software Deployment tools have changed in the past 20 years
geshan
0
34k
Tell your own story through comics
letsgokoyo
1
1k
Designing for Timeless Needs
cassininazir
1
400
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3.3k
Self-Hosted WebAssembly Runtime for Runtime-Neutral Checkpoint/Restore in Edge–Cloud Continuum
chikuwait
0
660
Building a A Zero-Code AI SEO Workflow
portentint
PRO
0
640
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
133
19k
It's Worth the Effort
3n
188
29k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
360
30k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
16
2k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
Claude Code のすすめ
schroneko
67
230k
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!