#futures #spawn #profile #cpu #diagnostics #binary #scheduled

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
Download history 3810/week @ 2020-10-31 3526/week @ 2020-11-07 4098/week @ 2020-11-14 4322/week @ 2020-11-21 5245/week @ 2020-11-28 4487/week @ 2020-12-05 4804/week @ 2020-12-12 2953/week @ 2020-12-19 2670/week @ 2020-12-26 5777/week @ 2021-01-02 5708/week @ 2021-01-09 6051/week @ 2021-01-16 5956/week @ 2021-01-23 5990/week @ 2021-01-30 5681/week @ 2021-02-06 5891/week @ 2021-02-13

17,192 downloads per month
Used in 10 crates (via sc-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.2–3MB
~66K SLoC