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

8
Cargo.lock generated
View file

@ -3628,9 +3628,9 @@ dependencies = [
[[package]] [[package]]
name = "svg" name = "svg"
version = "0.14.0" version = "0.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0d703a3635418d4e4d0e410009ddbfb65047ef9468b1d29afd3b057a5bc4c217" checksum = "2198f991cd549041203080de947415bae45220eab7253c220b87e3188d19f21a"
[[package]] [[package]]
name = "syn" name = "syn"
@ -4064,9 +4064,9 @@ dependencies = [
[[package]] [[package]]
name = "tracing-durations-export" name = "tracing-durations-export"
version = "0.1.2" version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a81cbe37a5217ac622312780d49061da017602b295ada333a16a507065ec633b" checksum = "35b910b25a6c8e0fefcfff912bad6c4f4849d37e5945c3861d15e550d819da53"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"fs-err", "fs-err",

View file

@ -95,7 +95,7 @@ tokio-util = { version = "0.7.10", features = ["compat"] }
toml = { version = "0.8.8" } toml = { version = "0.8.8" }
toml_edit = { version = "0.21.0" } toml_edit = { version = "0.21.0" }
tracing = { version = "0.1.40" } tracing = { version = "0.1.40" }
tracing-durations-export = { version = "0.1.0", features = ["plot"] } tracing-durations-export = { version = "0.2.0", features = ["plot"] }
tracing-indicatif = { version = "0.3.6" } tracing-indicatif = { version = "0.3.6" }
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] } tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
tracing-tree = { version = "0.3.0" } tracing-tree = { version = "0.3.0" }

View file

@ -50,7 +50,7 @@ rustc-hash = { workspace = true }
tempfile = { workspace = true } tempfile = { workspace = true }
tokio = { workspace = true } tokio = { workspace = true }
tracing = { 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-indicatif = { workspace = true }
tracing-subscriber = { workspace = true } tracing-subscriber = { workspace = true }
url = { workspace = true } url = { workspace = true }

View file

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

View file

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

View file

@ -0,0 +1,300 @@
# This file was autogenerated by Puffin v0.0.3 via the following command:
# puffin pip compile scripts/requirements/jupyter.in
anyio==4.2.0
# via jupyter-server
argon2-cffi==23.1.0
# via jupyter-server
argon2-cffi-bindings==21.2.0
# via argon2-cffi
arrow==1.3.0
# via isoduration
asttokens==2.4.1
# via stack-data
async-lru==2.0.4
# via jupyterlab
attrs==23.2.0
# via
# jsonschema
# referencing
babel==2.14.0
# via jupyterlab-server
beautifulsoup4==4.12.3
# via nbconvert
bleach==6.1.0
# via nbconvert
certifi==2023.11.17
# via requests
cffi==1.16.0
# via argon2-cffi-bindings
charset-normalizer==3.3.2
# via requests
comm==0.2.1
# via
# ipykernel
# ipywidgets
debugpy==1.8.0
# via ipykernel
decorator==5.1.1
# via ipython
defusedxml==0.7.1
# via nbconvert
executing==2.0.1
# via stack-data
fastjsonschema==2.19.1
# via nbformat
fqdn==1.5.1
# via jsonschema
idna==3.6
# via
# anyio
# jsonschema
# requests
ipykernel==6.29.0
# via
# jupyter
# jupyter-console
# jupyterlab
# qtconsole
ipython==8.20.0
# via
# ipykernel
# ipywidgets
# jupyter-console
ipywidgets==8.1.1
# via jupyter
isoduration==20.11.0
# via jsonschema
jedi==0.19.1
# via ipython
jinja2==3.1.3
# via
# jupyter-server
# jupyterlab
# jupyterlab-server
# nbconvert
json5==0.9.14
# via jupyterlab-server
jsonpointer==2.4
# via jsonschema
jsonschema==4.21.1
# via
# jupyter-events
# jupyterlab-server
# nbformat
jsonschema-specifications==2023.12.1
# via jsonschema
jupyter==1.0.0
jupyter-client==8.6.0
# via
# ipykernel
# jupyter-console
# jupyter-server
# nbclient
# qtconsole
jupyter-console==6.6.3
# via jupyter
jupyter-core==5.7.1
# via
# ipykernel
# jupyter-client
# jupyter-console
# jupyter-server
# jupyterlab
# nbclient
# nbconvert
# nbformat
# qtconsole
jupyter-events==0.9.0
# via jupyter-server
jupyter-lsp==2.2.2
# via jupyterlab
jupyter-server==2.12.5
# via
# jupyter-lsp
# jupyterlab
# jupyterlab-server
# notebook
# notebook-shim
jupyter-server-terminals==0.5.2
# via jupyter-server
jupyterlab==4.0.11
# via notebook
jupyterlab-pygments==0.3.0
# via nbconvert
jupyterlab-server==2.25.2
# via
# jupyterlab
# notebook
jupyterlab-widgets==3.0.9
# via ipywidgets
markupsafe==2.1.4
# via
# jinja2
# nbconvert
matplotlib-inline==0.1.6
# via
# ipykernel
# ipython
mistune==3.0.2
# via nbconvert
nbclient==0.9.0
# via nbconvert
nbconvert==7.14.2
# via
# jupyter
# jupyter-server
nbformat==5.9.2
# via
# jupyter-server
# nbclient
# nbconvert
nest-asyncio==1.6.0
# via ipykernel
notebook==7.0.7
# via jupyter
notebook-shim==0.2.3
# via
# jupyterlab
# notebook
overrides==7.7.0
# via jupyter-server
packaging==23.2
# via
# ipykernel
# jupyter-server
# jupyterlab
# jupyterlab-server
# nbconvert
# qtconsole
# qtpy
pandocfilters==1.5.1
# via nbconvert
parso==0.8.3
# via jedi
pexpect==4.9.0
# via ipython
platformdirs==4.1.0
# via jupyter-core
prometheus-client==0.19.0
# via jupyter-server
prompt-toolkit==3.0.43
# via
# ipython
# jupyter-console
psutil==5.9.8
# via ipykernel
ptyprocess==0.7.0
# via
# pexpect
# terminado
pure-eval==0.2.2
# via stack-data
pycparser==2.21
# via cffi
pygments==2.17.2
# via
# ipython
# jupyter-console
# nbconvert
# qtconsole
python-dateutil==2.8.2
# via
# arrow
# jupyter-client
python-json-logger==2.0.7
# via jupyter-events
pyyaml==6.0.1
# via jupyter-events
pyzmq==25.1.2
# via
# ipykernel
# jupyter-client
# jupyter-console
# jupyter-server
# qtconsole
qtconsole==5.5.1
# via jupyter
qtpy==2.4.1
# via qtconsole
referencing==0.33.0
# via
# jsonschema
# jsonschema-specifications
# jupyter-events
requests==2.31.0
# via jupyterlab-server
rfc3339-validator==0.1.4
# via
# jsonschema
# jupyter-events
rfc3986-validator==0.1.1
# via
# jsonschema
# jupyter-events
rpds-py==0.17.1
# via
# jsonschema
# referencing
send2trash==1.8.2
# via jupyter-server
six==1.16.0
# via
# asttokens
# bleach
# python-dateutil
# rfc3339-validator
sniffio==1.3.0
# via anyio
soupsieve==2.5
# via beautifulsoup4
stack-data==0.6.3
# via ipython
terminado==0.18.0
# via
# jupyter-server
# jupyter-server-terminals
tinycss2==1.2.1
# via nbconvert
tornado==6.4
# via
# ipykernel
# jupyter-client
# jupyter-server
# jupyterlab
# notebook
# terminado
traitlets==5.14.1
# via
# comm
# ipykernel
# ipython
# ipywidgets
# jupyter-client
# jupyter-console
# jupyter-core
# jupyter-events
# jupyter-server
# jupyterlab
# matplotlib-inline
# nbclient
# nbconvert
# nbformat
# qtconsole
types-python-dateutil==2.8.19.20240106
# via arrow
uri-template==1.3.0
# via jsonschema
urllib3==2.1.0
# via requests
wcwidth==0.2.13
# via prompt-toolkit
webcolors==1.13
# via jsonschema
webencodings==0.5.1
# via
# bleach
# tinycss2
websocket-client==1.7.0
# via jupyter-server
widgetsnbextension==4.0.9
# via ipywidgets

View file

@ -0,0 +1 @@
jupyter