From 0d36e88c7cdb9a37d7aeac56c8c4a58e9944c171 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Tue, 5 Mar 2024 20:58:25 -0600 Subject: [PATCH] fix(cli): Add traces to clarify where time is going In looking at the traces, I had a couple of questions of where the time is going, like - Why does writing a package file take so long - How much of manifest parsing is TOML parsing vs target discovery vs other stuff This adds traces to help answer those. --- src/cargo/core/resolver/encode.rs | 1 + src/cargo/core/summary.rs | 1 + src/cargo/ops/lockfile.rs | 2 ++ src/cargo/util/toml/mod.rs | 3 +++ src/cargo/util/toml/targets.rs | 1 + 5 files changed, 8 insertions(+) diff --git a/src/cargo/core/resolver/encode.rs b/src/cargo/core/resolver/encode.rs index 44a817916e6..2b4c3008236 100644 --- a/src/cargo/core/resolver/encode.rs +++ b/src/cargo/core/resolver/encode.rs @@ -637,6 +637,7 @@ impl<'de> de::Deserialize<'de> for EncodablePackageId { } impl ser::Serialize for Resolve { + #[tracing::instrument(skip_all)] fn serialize(&self, s: S) -> Result where S: ser::Serializer, diff --git a/src/cargo/core/summary.rs b/src/cargo/core/summary.rs index 5f73362cf33..ec0197cf40d 100644 --- a/src/cargo/core/summary.rs +++ b/src/cargo/core/summary.rs @@ -31,6 +31,7 @@ struct Inner { } impl Summary { + #[tracing::instrument(skip_all)] pub fn new( pkg_id: PackageId, dependencies: Vec, diff --git a/src/cargo/ops/lockfile.rs b/src/cargo/ops/lockfile.rs index 8b7569be7be..22942eb8cd0 100644 --- a/src/cargo/ops/lockfile.rs +++ b/src/cargo/ops/lockfile.rs @@ -112,6 +112,7 @@ fn resolve_to_string_orig( (orig.ok(), out, lock_root) } +#[tracing::instrument(skip_all)] fn serialize_resolve(resolve: &Resolve, orig: Option<&str>) -> String { let toml = toml::Table::try_from(resolve).unwrap(); @@ -194,6 +195,7 @@ fn serialize_resolve(resolve: &Resolve, orig: Option<&str>) -> String { out } +#[tracing::instrument(skip_all)] fn are_equal_lockfiles(orig: &str, current: &str, ws: &Workspace<'_>) -> bool { // If we want to try and avoid updating the lock file, parse both and // compare them; since this is somewhat expensive, don't do it in the diff --git a/src/cargo/util/toml/mod.rs b/src/cargo/util/toml/mod.rs index b78bce8f546..5044f5a0a9b 100644 --- a/src/cargo/util/toml/mod.rs +++ b/src/cargo/util/toml/mod.rs @@ -424,6 +424,7 @@ pub fn prepare_for_publish( } } +#[tracing::instrument(skip_all)] pub fn to_real_manifest( me: manifest::TomlManifest, embedded: bool, @@ -723,6 +724,7 @@ pub fn to_real_manifest( root: package_root, }; + #[tracing::instrument(skip(manifest_ctx, new_deps, workspace_config, inherit_cell))] fn process_dependencies( manifest_ctx: &mut ManifestContext<'_, '_>, new_deps: Option<&BTreeMap>, @@ -1531,6 +1533,7 @@ fn default_readme_from_package_root(package_root: &Path) -> Option { /// Checks a list of build targets, and ensures the target names are unique within a vector. /// If not, the name of the offending build target is returned. +#[tracing::instrument(skip_all)] fn unique_build_targets( targets: &[Target], package_root: &Path, diff --git a/src/cargo/util/toml/targets.rs b/src/cargo/util/toml/targets.rs index 357a1f7661a..03750657270 100644 --- a/src/cargo/util/toml/targets.rs +++ b/src/cargo/util/toml/targets.rs @@ -32,6 +32,7 @@ const DEFAULT_BENCH_DIR_NAME: &'static str = "benches"; const DEFAULT_EXAMPLE_DIR_NAME: &'static str = "examples"; const DEFAULT_BIN_DIR_NAME: &'static str = "bin"; +#[tracing::instrument(skip_all)] pub(super) fn targets( features: &Features, manifest: &TomlManifest,