Skip to content

Commit

Permalink
fix(cli): Remove bespoke profiling
Browse files Browse the repository at this point in the history
  • Loading branch information
epage committed Mar 5, 2024
1 parent b9a939a commit caf4c30
Show file tree
Hide file tree
Showing 12 changed files with 7 additions and 47 deletions.
3 changes: 0 additions & 3 deletions src/cargo/core/compiler/build_runner/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ use crate::core::compiler::{self, artifact, Unit};
use crate::core::PackageId;
use crate::util::cache_lock::CacheLockMode;
use crate::util::errors::CargoResult;
use crate::util::profile;
use anyhow::{bail, Context as _};
use filetime::FileTime;
use itertools::Itertools;
Expand Down Expand Up @@ -353,8 +352,6 @@ impl<'a, 'gctx> BuildRunner<'a, 'gctx> {
/// place.
#[tracing::instrument(skip_all)]
pub fn prepare(&mut self) -> CargoResult<()> {
let _p = profile::start("preparing layout");

self.files
.as_mut()
.unwrap()
Expand Down
8 changes: 1 addition & 7 deletions src/cargo/core/compiler/custom_build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ use crate::core::compiler::fingerprint::DirtyReason;
use crate::core::compiler::job_queue::JobState;
use crate::core::{profiles::ProfileRoot, PackageId, Target};
use crate::util::errors::CargoResult;
use crate::util::internal;
use crate::util::machine_message::{self, Message};
use crate::util::{internal, profile};
use anyhow::{bail, Context as _};
use cargo_platform::Cfg;
use cargo_util::paths;
Expand Down Expand Up @@ -196,12 +196,6 @@ impl LinkArgTarget {
/// Prepares a `Work` that executes the target as a custom build script.
#[tracing::instrument(skip_all)]
pub fn prepare(build_runner: &mut BuildRunner<'_, '_>, unit: &Unit) -> CargoResult<Job> {
let _p = profile::start(format!(
"build script prepare: {}/{}",
unit.pkg,
unit.target.name()
));

let metadata = build_runner.get_run_build_script_metadata(unit);
if build_runner
.build_script_outputs
Expand Down
7 changes: 1 addition & 6 deletions src/cargo/core/compiler/fingerprint/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ use crate::core::Package;
use crate::util::errors::CargoResult;
use crate::util::interning::InternedString;
use crate::util::{self, try_canonicalize};
use crate::util::{internal, path_args, profile, StableHasher};
use crate::util::{internal, path_args, StableHasher};
use crate::{GlobalContext, CARGO_ENV};

use super::custom_build::BuildDeps;
Expand Down Expand Up @@ -405,11 +405,6 @@ pub fn prepare_target(
unit: &Unit,
force: bool,
) -> CargoResult<Job> {
let _p = profile::start(format!(
"fingerprint: {} / {}",
unit.pkg.package_id(),
unit.target.name()
));
let bcx = build_runner.bcx;
let loc = build_runner.files().fingerprint_file_path(unit, "");

Expand Down
3 changes: 1 addition & 2 deletions src/cargo/core/compiler/job_queue/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ use crate::util::diagnostic_server::{self, DiagnosticPrinter};
use crate::util::errors::AlreadyPrintedError;
use crate::util::machine_message::{self, Message as _};
use crate::util::CargoResult;
use crate::util::{self, internal, profile};
use crate::util::{self, internal};
use crate::util::{DependencyQueue, GlobalContext, Progress, ProgressStyle, Queue};

/// This structure is backed by the `DependencyQueue` type and manages the
Expand Down Expand Up @@ -473,7 +473,6 @@ impl<'gctx> JobQueue<'gctx> {
build_runner: &mut BuildRunner<'_, '_>,
plan: &mut BuildPlan,
) -> CargoResult<()> {
let _p = profile::start("executing the job graph");
self.queue.queue_finished();

let progress =
Expand Down
4 changes: 1 addition & 3 deletions src/cargo/core/compiler/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ use crate::core::{Feature, PackageId, Target, Verbosity};
use crate::util::errors::{CargoResult, VerboseError};
use crate::util::interning::InternedString;
use crate::util::machine_message::{self, Message};
use crate::util::{add_path_args, internal, profile};
use crate::util::{add_path_args, internal};
use cargo_util::{paths, ProcessBuilder, ProcessError};
use cargo_util_schemas::manifest::TomlDebugInfo;
use cargo_util_schemas::manifest::TomlTrimPaths;
Expand Down Expand Up @@ -175,7 +175,6 @@ fn compile<'gctx>(

// Build up the work to be done to compile this unit, enqueuing it once
// we've got everything constructed.
let p = profile::start(format!("preparing: {}/{}", unit.pkg, unit.target.name()));
fingerprint::prepare_init(build_runner, unit)?;

let job = if unit.mode.is_run_custom_build() {
Expand Down Expand Up @@ -216,7 +215,6 @@ fn compile<'gctx>(
job
};
jobs.enqueue(build_runner, unit, job)?;
drop(p);

// Be sure to compile all dependencies of this target as well.
let deps = Vec::from(build_runner.unit_deps(unit)); // Create vec due to mutable borrow.
Expand Down
13 changes: 0 additions & 13 deletions src/cargo/core/global_cache_tracker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,6 @@ impl GlobalCacheTracker {
clean_ctx: &mut CleanContext<'_>,
gc_opts: &GcOpts,
) -> CargoResult<()> {
let _p = crate::util::profile::start("cleaning global cache files");
let gctx = clean_ctx.gctx;
let base = BasePaths {
index: gctx.registry_index_path().into_path_unlocked(),
Expand Down Expand Up @@ -706,7 +705,6 @@ impl GlobalCacheTracker {
sync_size: bool,
delete_paths: &mut Vec<PathBuf>,
) -> CargoResult<()> {
let _p = crate::util::profile::start("global cache db sync");
debug!(target: "gc", "starting db sync");
// For registry_index and git_db, add anything that is missing in the db.
Self::update_parent_for_missing_from_db(conn, now, REGISTRY_INDEX_TABLE, &base.index)?;
Expand Down Expand Up @@ -804,9 +802,6 @@ impl GlobalCacheTracker {
parent_table_name: &str,
base_path: &Path,
) -> CargoResult<()> {
let _p = crate::util::profile::start(format!(
"update parent db for missing from db {parent_table_name}"
));
trace!(target: "gc", "checking for untracked parent to add to {parent_table_name}");
let names = Self::names_from(base_path)?;

Expand All @@ -833,7 +828,6 @@ impl GlobalCacheTracker {
table_name: &str,
base_path: &Path,
) -> CargoResult<()> {
let _p = crate::util::profile::start(format!("update db for removed {table_name}"));
trace!(target: "gc", "checking for db entries to remove from {table_name}");
let mut select_stmt = conn.prepare_cached(&format!(
"SELECT {table_name}.rowid, {parent_table_name}.name, {table_name}.name
Expand Down Expand Up @@ -863,9 +857,6 @@ impl GlobalCacheTracker {
child_base_paths: &[&Path],
delete_paths: &mut Vec<PathBuf>,
) -> CargoResult<()> {
let _p = crate::util::profile::start(format!(
"update db parent for removed from disk {parent_table_name}"
));
trace!(target: "gc", "checking for db entries to remove from {parent_table_name}");
let mut select_stmt =
conn.prepare_cached(&format!("SELECT rowid, name FROM {parent_table_name}"))?;
Expand Down Expand Up @@ -899,7 +890,6 @@ impl GlobalCacheTracker {
now: Timestamp,
base_path: &Path,
) -> CargoResult<()> {
let _p = crate::util::profile::start("populate untracked crate");
trace!(target: "gc", "populating untracked crate files");
let mut insert_stmt = conn.prepare_cached(
"INSERT INTO registry_crate (registry_id, name, size, timestamp)
Expand Down Expand Up @@ -939,7 +929,6 @@ impl GlobalCacheTracker {
base_path: &Path,
populate_size: bool,
) -> CargoResult<()> {
let _p = crate::util::profile::start(format!("populate untracked {table_name}"));
trace!(target: "gc", "populating untracked files for {table_name}");
// Gather names (and make sure they are in the database).
let id_names = Self::names_from(&base_path)?;
Expand Down Expand Up @@ -1003,7 +992,6 @@ impl GlobalCacheTracker {
table_name: &str,
base_path: &Path,
) -> CargoResult<()> {
let _p = crate::util::profile::start(format!("update NULL sizes {table_name}"));
trace!(target: "gc", "updating NULL size information in {table_name}");
let mut null_stmt = conn.prepare_cached(&format!(
"SELECT {table_name}.rowid, {table_name}.name, {parent_table_name}.name
Expand Down Expand Up @@ -1570,7 +1558,6 @@ impl DeferredGlobalLastUse {
/// This will also clear the state of `self`.
#[tracing::instrument(skip_all)]
pub fn save(&mut self, tracker: &mut GlobalCacheTracker) -> CargoResult<()> {
let _p = crate::util::profile::start("saving last-use data");
trace!(target: "gc", "saving last-use data");
if self.is_empty() {
return Ok(());
Expand Down
2 changes: 0 additions & 2 deletions src/cargo/core/resolver/features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -455,8 +455,6 @@ impl<'a, 'gctx> FeatureResolver<'a, 'gctx> {
requested_targets: &[CompileKind],
opts: FeatureOpts,
) -> CargoResult<ResolvedFeatures> {
use crate::util::profile;
let _p = profile::start("resolve features");
let track_for_host = opts.decouple_host_deps || opts.ignore_inactive_targets;
let mut r = FeatureResolver {
ws,
Expand Down
2 changes: 0 additions & 2 deletions src/cargo/core/resolver/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ use crate::core::{Dependency, PackageId, Registry, Summary};
use crate::util::context::GlobalContext;
use crate::util::errors::CargoResult;
use crate::util::network::PollExt;
use crate::util::profile;

use self::context::ResolverContext;
use self::dep_cache::RegistryQueryer;
Expand Down Expand Up @@ -131,7 +130,6 @@ pub fn resolve(
resolve_version: ResolveVersion,
gctx: Option<&GlobalContext>,
) -> CargoResult<Resolve> {
let _p = profile::start("resolving");
let first_version = match gctx {
Some(config) if config.cli_unstable().direct_minimal_versions => {
Some(VersionOrdering::MinimumVersionsFirst)
Expand Down
3 changes: 1 addition & 2 deletions src/cargo/ops/cargo_compile/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ use crate::ops;
use crate::ops::resolve::WorkspaceResolve;
use crate::util::context::GlobalContext;
use crate::util::interning::InternedString;
use crate::util::{profile, CargoResult, StableHasher};
use crate::util::{CargoResult, StableHasher};

mod compile_filter;
pub use compile_filter::{CompileFilter, FilterRule, LibRule};
Expand Down Expand Up @@ -155,7 +155,6 @@ pub fn compile_ws<'a>(
return Compilation::new(&bcx);
}
crate::core::gc::auto_gc(bcx.gctx);
let _p = profile::start("compiling");
let build_runner = BuildRunner::new(&bcx)?;
build_runner.compile(exec)
}
Expand Down
4 changes: 1 addition & 3 deletions src/cargo/ops/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ use crate::ops;
use crate::sources::PathSource;
use crate::util::cache_lock::CacheLockMode;
use crate::util::errors::CargoResult;
use crate::util::{profile, CanonicalUrl};
use crate::util::CanonicalUrl;
use anyhow::Context as _;
use std::collections::{HashMap, HashSet};
use tracing::{debug, trace};
Expand Down Expand Up @@ -147,8 +147,6 @@ pub fn resolve_ws_with_opts<'gctx>(
// Second, resolve with precisely what we're doing. Filter out
// transitive dependencies if necessary, specify features, handle
// overrides, etc.
let _p = profile::start("resolving with overrides...");

add_overrides(&mut registry, ws)?;

for (replace_spec, dep) in ws.root_replace() {
Expand Down
1 change: 0 additions & 1 deletion src/cargo/util/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ pub mod job;
mod lockserver;
pub mod machine_message;
pub mod network;
pub mod profile;
mod progress;
mod queue;
pub mod restricted_names;
Expand Down
4 changes: 1 addition & 3 deletions src/cargo/util/rustc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use serde::{Deserialize, Serialize};
use tracing::{debug, info, warn};

use crate::util::interning::InternedString;
use crate::util::{profile, CargoResult, GlobalContext, StableHasher};
use crate::util::{CargoResult, GlobalContext, StableHasher};

/// Information on the `rustc` executable
#[derive(Debug)]
Expand Down Expand Up @@ -48,8 +48,6 @@ impl Rustc {
cache_location: Option<PathBuf>,
gctx: &GlobalContext,
) -> CargoResult<Rustc> {
let _p = profile::start("Rustc::new");

let mut cache = Cache::load(
wrapper.as_deref(),
workspace_wrapper.as_deref(),
Expand Down

0 comments on commit caf4c30

Please sign in to comment.