Instrument the main function and add jupyter.in (#1186)

Instrument the main function as anchor span for checking overhead and
update tracing-durations-export to 0.2.0 for differentiating
blocking/non-blocking tasks.

Add a `jupyter.in` requirement since `pip install jupyter` is a common
operation. I tried `jupyterlab` too but there is no difference in
performance (1.00 ± 0.07).
This commit is contained in:
konsti 2024-01-30 12:03:24 +01:00 committed by GitHub
parent a6c4cbfe55
commit ab27913f68
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 314 additions and 10 deletions

View file

@ -50,7 +50,7 @@ rustc-hash = { workspace = true }
tempfile = { workspace = true }
tokio = { workspace = true }
tracing = { workspace = true }
tracing-durations-export = { version = "0.1.0", features = ["plot"] }
tracing-durations-export = { workspace = true, features = ["plot"] }
tracing-indicatif = { workspace = true }
tracing-subscriber = { workspace = true }
url = { workspace = true }

View file

@ -10,7 +10,7 @@ use anstream::eprintln;
use anyhow::Result;
use clap::Parser;
use owo_colors::OwoColorize;
use tracing::debug;
use tracing::{debug, instrument};
use tracing_durations_export::plot::PlotConfig;
use tracing_durations_export::DurationsLayerBuilder;
use tracing_indicatif::IndicatifLayer;
@ -68,6 +68,7 @@ enum Cli {
WheelMetadata(WheelMetadataArgs),
}
#[instrument] // Anchor span to check for overhead
async fn run() -> Result<()> {
let cli = Cli::parse();
match cli {

View file

@ -8,6 +8,7 @@ use anyhow::Result;
use chrono::{DateTime, Days, NaiveDate, NaiveTime, Utc};
use clap::{Args, Parser, Subcommand};
use owo_colors::OwoColorize;
use tracing::instrument;
use distribution_types::{FlatIndexLocation, IndexLocations, IndexUrl};
use puffin_cache::{Cache, CacheArgs, Refresh};
@ -605,7 +606,8 @@ struct RemoveArgs {
name: PackageName,
}
async fn inner() -> Result<ExitStatus> {
#[instrument] // Anchor span to check for overhead
async fn run() -> Result<ExitStatus> {
let cli = Cli::parse();
// Configure the `tracing` crate, which controls internal logging.
@ -865,7 +867,7 @@ fn main() -> ExitCode {
.thread_stack_size(stack_size)
.build()
.expect("Failed building the Runtime")
.block_on(inner())
.block_on(run())
};
std::thread::Builder::new()
.stack_size(stack_size)
@ -878,7 +880,7 @@ fn main() -> ExitCode {
.enable_all()
.build()
.expect("Failed building the Runtime")
.block_on(inner())
.block_on(run())
};
match result {