Skip to content

Commit 0d36e88

Browse files
committed
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.
1 parent 00b9882 commit 0d36e88

File tree

5 files changed

+8
-0
lines changed

5 files changed

+8
-0
lines changed

src/cargo/core/resolver/encode.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -637,6 +637,7 @@ impl<'de> de::Deserialize<'de> for EncodablePackageId {
637637
}
638638

639639
impl ser::Serialize for Resolve {
640+
#[tracing::instrument(skip_all)]
640641
fn serialize<S>(&self, s: S) -> Result<S::Ok, S::Error>
641642
where
642643
S: ser::Serializer,

src/cargo/core/summary.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ struct Inner {
3131
}
3232

3333
impl Summary {
34+
#[tracing::instrument(skip_all)]
3435
pub fn new(
3536
pkg_id: PackageId,
3637
dependencies: Vec<Dependency>,

src/cargo/ops/lockfile.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ fn resolve_to_string_orig(
112112
(orig.ok(), out, lock_root)
113113
}
114114

115+
#[tracing::instrument(skip_all)]
115116
fn serialize_resolve(resolve: &Resolve, orig: Option<&str>) -> String {
116117
let toml = toml::Table::try_from(resolve).unwrap();
117118

@@ -194,6 +195,7 @@ fn serialize_resolve(resolve: &Resolve, orig: Option<&str>) -> String {
194195
out
195196
}
196197

198+
#[tracing::instrument(skip_all)]
197199
fn are_equal_lockfiles(orig: &str, current: &str, ws: &Workspace<'_>) -> bool {
198200
// If we want to try and avoid updating the lock file, parse both and
199201
// compare them; since this is somewhat expensive, don't do it in the

src/cargo/util/toml/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,7 @@ pub fn prepare_for_publish(
424424
}
425425
}
426426

427+
#[tracing::instrument(skip_all)]
427428
pub fn to_real_manifest(
428429
me: manifest::TomlManifest,
429430
embedded: bool,
@@ -723,6 +724,7 @@ pub fn to_real_manifest(
723724
root: package_root,
724725
};
725726

727+
#[tracing::instrument(skip(manifest_ctx, new_deps, workspace_config, inherit_cell))]
726728
fn process_dependencies(
727729
manifest_ctx: &mut ManifestContext<'_, '_>,
728730
new_deps: Option<&BTreeMap<manifest::PackageName, manifest::InheritableDependency>>,
@@ -1531,6 +1533,7 @@ fn default_readme_from_package_root(package_root: &Path) -> Option<String> {
15311533

15321534
/// Checks a list of build targets, and ensures the target names are unique within a vector.
15331535
/// If not, the name of the offending build target is returned.
1536+
#[tracing::instrument(skip_all)]
15341537
fn unique_build_targets(
15351538
targets: &[Target],
15361539
package_root: &Path,

src/cargo/util/toml/targets.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ const DEFAULT_BENCH_DIR_NAME: &'static str = "benches";
3232
const DEFAULT_EXAMPLE_DIR_NAME: &'static str = "examples";
3333
const DEFAULT_BIN_DIR_NAME: &'static str = "bin";
3434

35+
#[tracing::instrument(skip_all)]
3536
pub(super) fn targets(
3637
features: &Features,
3738
manifest: &TomlManifest,

0 commit comments

Comments
 (0)