#future #spawn #diagnostics #wraps #logs #task #lots

futures-diagnose

Wraps around a Spawn and provides lots of diagnostics

3 releases (stable)

1.0.1 Feb 5, 2020
1.0.0 Jan 22, 2020
0.1.0 Jan 22, 2020

#984 in Asynchronous

Download history 623/week @ 2024-07-28 429/week @ 2024-08-04 1309/week @ 2024-08-11 682/week @ 2024-08-18 863/week @ 2024-08-25 724/week @ 2024-09-01 565/week @ 2024-09-08 625/week @ 2024-09-15 973/week @ 2024-09-22 567/week @ 2024-09-29 74/week @ 2024-10-06 488/week @ 2024-10-13 420/week @ 2024-10-20 612/week @ 2024-10-27 529/week @ 2024-11-03 108/week @ 2024-11-10

1,700 downloads per month
Used in 40 crates (via tc-transaction-pool)

MIT license

22KB
361 lines

This crate allows one to generate logs about how tasks are scheduled, in order to generate a profile of the CPU usage of the binary.

This crate leverages https://github.com/catapult-project/catapult/tree/11513e359cd60e369bbbd1f4f2ef648c1bccabd0/tracing

Usage

First, import the traits:

use futures_diagnose_exec::{FutureExt as _, Future01Ext as _};

Then whenever you create a Future, append .with_diagnostics("name"). For example:

async_std::spawn(future.with_diagnostics("my-task-name"))

Set the environment variable PROFILE_DIR to a directory of your choice (e.g. profile) and then, run your code. Files named profile.<pid>.<num>.json will be generated in the directory set beforehand.

Then, open Chrome and go to the URL chrome://tracing, and load the profile.json.

FAQ

  • Chrome tells me chrome://tracing "can't be reached".

    Chromium shipped with recent Debian versions has the tracing feature disabled. See the Debian bug report for details.

Dependencies

~2–3.5MB
~67K SLoC