cargo-geiger icon indicating copy to clipboard operation
cargo-geiger copied to clipboard

Optimize compile times by replacing the dependency on the cargo crate

Open anderejd opened this issue 5 years ago • 4 comments

The current compile times are a bit painful, mainly caused by cargo having a huge number dependencies. The obvious solution could be to reduce the number of dependencies of cargo.

Another very nice direction could be to use cargo as a subprocess, no building cargo at all! Can cargo output all the data needed by cargo-geiger? ~~If not, what's missing? Make this list and then open an issue in the cargo repo and ask if a PR adding that missing data export would be welcome.~~ Use cargo_metadata.

Summary

anderejd avatar Sep 19 '19 16:09 anderejd

This is probably related to #16. 🙂

jakubadamw avatar Sep 23 '19 19:09 jakubadamw

Yes, that would be an amazing optimization, simply not building cargo :)

anderejd avatar Sep 23 '19 19:09 anderejd

cargo-geiger would likely also need to inject a RUSTC_WRAPPER environment variable and call cargo check instead of implementing cargo::core::compiler::Executor, to retain the "used by build" feature.

anderejd avatar Sep 23 '19 19:09 anderejd

Following on from the comment on https://github.com/rust-secure-code/cargo-geiger/issues/16 the remaining usages of the cargo crate are

args.rs:252:    use cargo::core::Verbosity;
args.rs:3:use cargo::core::shell::ColorChoice;
args.rs:4:use cargo::{CliResult, Config};
cli.rs:13:use cargo::core::Workspace;
cli.rs:14:use cargo::util::{self, important_paths, CargoResult};
cli.rs:15:use cargo::Config;
format/print_config.rs:5:use cargo::core::shell::Verbosity;
format/print_config.rs:6:use cargo::util::errors::CliError;
graph.rs:10:use cargo::Config;
graph.rs:7:use cargo::core::Workspace;
graph.rs:8:use cargo::util::interning::InternedString;
graph.rs:9:use cargo::util::CargoResult;
main.rs:22:use cargo::core::shell::Shell;
main.rs:23:use cargo::util::important_paths;
main.rs:24:use cargo::{CliError, CliResult, Config};
mapping/metadata.rs:147:    use cargo::core::dependency::DepKind;
mapping/metadata.rs:148:    use cargo::core::registry::PackageRegistry;
mapping/metadata.rs:149:    use cargo::core::resolver::ResolveOpts;
mapping/metadata.rs:150:    use cargo::core::{Package, PackageId, PackageIdSpec, PackageSet, Resolve, Workspace};
mapping/metadata.rs:151:    use cargo::{ops, CargoResult, Config};
readme.rs:3:use cargo::{CliError, CliResult};
scan/default.rs:17:use cargo::core::compiler::CompileMode;
scan/default.rs:18:use cargo::core::Workspace;
scan/default.rs:19:use cargo::ops::CompileOptions;
scan/default.rs:20:use cargo::{CliError, Config};
scan/default/table.rs:17:use cargo::core::shell::Verbosity;
scan/default/table.rs:18:use cargo::core::Workspace;
scan/default/table.rs:19:use cargo::CliError;
scan/find.rs:11:use cargo::util::CargoResult;
scan/find.rs:12:use cargo::{CliError, Config};
scan/forbid.rs:12:use cargo::{CliError, Config};
scan/forbid/table.rs:14:use cargo::{CliError, Config};
scan.rs:19:use cargo::core::Workspace;
scan.rs:20:use cargo::{CliError, Config};
scan/rs_file/custom_executor.rs:1:use cargo::core::compiler::{CompileMode, Executor, Unit};
scan/rs_file/custom_executor.rs:2:use cargo::core::{PackageId, Target};
scan/rs_file/custom_executor.rs:3:use cargo::util::{CargoResult, ProcessBuilder};
scan/rs_file.rs:10:use cargo::util::{interning::InternedString, paths, CargoResult};
scan/rs_file.rs:11:use cargo::Config;
scan/rs_file.rs:5:use cargo::core::compiler::Executor;
scan/rs_file.rs:6:use cargo::core::manifest::TargetKind;
scan/rs_file.rs:7:use cargo::core::Workspace;
scan/rs_file.rs:8:use cargo::ops;
scan/rs_file.rs:9:use cargo::ops::{CleanOptions, CompileOptions};
tree.rs:86:    use cargo::core::shell::Verbosity;
tree/traversal/dependency_node.rs:127:    use cargo::core::Verbosity;

I have raised https://github.com/rust-secure-code/cargo-geiger/pull/165 to cleanup a trait only used in unit testing, and add a comment relating to cargo dependencies only left in for testing.

jmcconnell26 avatar Dec 17 '20 19:12 jmcconnell26