Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Instrumenting Async Runtime

mox692
December 15, 2024

Instrumenting Async Runtime

This is a presentation I gave in the Rust.Tokyo conference 2024.

mox692

December 15, 2024
Tweet

More Decks by mox692

Other Decks in Programming

Transcript

  1. • Rust Developer 🦀 • Used to use Scala •

    A organization member of tokio-rs Hi, I’m Motoyuki(@mox692) 👋 2
  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
  3. How to achieve a monitoring? • Logging (println!, log! etc…)

    • Capture a backtrace • System metrics etc … 5
  4. 11

  5. 12

  6. 13

  7. 17

  8. 18

  9. 19

  10. 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
  11. 29

  12. 30

  13. 32

  14. 33

  15. 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.
  16. 36

  17. High level archtecture 40 Gathering Runtime Event Tokio Runtime Visualize

    Log File Runtime thread Runtime thread Runtime thread
  18. 46

  19. 48

  20. 50

  21. 51

  22. 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 🔥
  23. 58

  24. 59

  25. 60

  26. 61

  27. 62

  28. 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
  29. 65

  30. 70 Trace Log • Should be optimized by e.g., ◦

    Using thread local buffer ◦ Using a dedicated trace format
  31. 71