Skip to content

Commit

Permalink
Auto merge of #13545 - epage:trace, r=weihanglo
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
bors committed Mar 6, 2024
2 parents c3c417b + 0d36e88 commit b1b52aa
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/cargo/core/resolver/encode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,7 @@ impl<'de> de::Deserialize<'de> for EncodablePackageId {
}

impl ser::Serialize for Resolve {
#[tracing::instrument(skip_all)]
fn serialize<S>(&self, s: S) -> Result<S::Ok, S::Error>
where
S: ser::Serializer,
Expand Down
1 change: 1 addition & 0 deletions src/cargo/core/summary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ struct Inner {
}

impl Summary {
#[tracing::instrument(skip_all)]
pub fn new(
pkg_id: PackageId,
dependencies: Vec<Dependency>,
Expand Down
2 changes: 2 additions & 0 deletions src/cargo/ops/lockfile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions src/cargo/util/toml/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,7 @@ pub fn prepare_for_publish(
}
}

#[tracing::instrument(skip_all)]
pub fn to_real_manifest(
me: manifest::TomlManifest,
embedded: bool,
Expand Down Expand Up @@ -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<manifest::PackageName, manifest::InheritableDependency>>,
Expand Down Expand Up @@ -1531,6 +1533,7 @@ fn default_readme_from_package_root(package_root: &Path) -> Option<String> {

/// 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,
Expand Down
1 change: 1 addition & 0 deletions src/cargo/util/toml/targets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit b1b52aa

Please sign in to comment.