Skip to content

asrlabncku/Rust-Async-Context-Tracer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rust-Async-Context-Tracer

  • Understand the behavior of your asynchronous tasks and futures.
    ▶️New branch for tokio-runtime is working in progress

Prerequisite:

  • Please install and build uftrace first
  • Build your executable in debug mode

What is a tracing tool for asynchronous rust?

  • With this tool, we can:
    • Understand the behavior of rust asynchronous tasks, including the polling time of the futures and the waiting time of the futures
    • Find out some abnormal execution patterns (long polling time may cause blocking)
  • e.g. Here is a simple rust asynchronous program:
use async_std::task;
use std::time::Duration;

async fn my_test()
{
   task::sleep(Duration::from_millis(100)).await;
}
#[async_std::main]
async fn main(){
     my_test().await;
     task::sleep(Duration::from_millis(150)).await;
}

And We can have a visualization for our rust asynchronous program:
image

Usage

  • Clone the repository (No building needed)
  • Move the profile directory into your target directory
profile
├── parser_nu.py
├── parser.py
└── profile.sh
  • Run the profiler script:
    For tracing all futures:
    . profile.sh $EXECUTABLE_NAME $OUTPUT_FILE_NAME
    Tracing the compiler generated futures only:
    . profile.sh $EXECUTABLE_NAME $OUTPUT_FILE_NAME --generated-future
    ⚠️ The function location of futures are not provided by default, you can pass argument --get-location to get locations. Note that if enable it, the progress will become very slow, see issue #2.
  • After executing the script, we get a json file in the profile directory
profile
├── parser_nu.py
├── parser.py
├── profile.sh
└── $OUTPUT_FILE_NAME.json
  • Then we can use the trace-viewer to visualize the result:
    • Open the chrome browser
    • Type chrome://tracing/ on your chrome browser
    • Load the json file generated by profiler
  • Result example:
    image

TODO:

  • Different task(future) instances should be recognized
  • Combinators(e.g. join!, select!) issues
  • Speed up for parsing and recording are neeeded
  • Annotate different tasks with different colors
  • Tracing progress should be done correctly in release mode
  • Some locations information are wrong because of the same demangled symbol

Acknowledgement:

This work was sponsored by the internship of ADLINK during 2021-2022.

License:

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published