Skip to content

Philamentous/cargo-why-slow

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Disclaimer: If you didn't see my profile description. I am a biologist. I have some computer science background, but not coding. I am publishing some cargo crates and other little repos to (hopefully) meaningfully contribute to open-source projects (tactfully, I hope) and rust in general with any extra claude credits I have available. I am trying to ensure that any contributions I make are actually helpful so any criticism or feedback of my approach would be greatly appreciated.

cargo-why-slow

A cargo subcommand that answers "why is my build slow?" by running cargo build with timing data and presenting results in plain English with actionable recommendations.

Features

  • Runs cargo build --message-format=json to collect per-crate build durations
  • Ranks dependencies by compile time and shows the top N slowest
  • Identifies proc-macro crates (which can't be parallelized well)
  • Analyzes your Cargo.toml feature flags for known heavy crates
  • Generates plain-English recommendations to speed up your build
  • Color-coded terminal output for quick visual scanning

Installation

cargo install --path .

Usage

# In your project directory:
cargo why-slow

# Show top 20 slowest crates:
cargo why-slow -n 20

# Analyze a release build:
cargo why-slow --release

# Analyze a project in a different directory:
cargo why-slow --path /path/to/project

How It Works

  1. Runs cargo build --message-format=json to get structured build output
  2. Parses compiler-artifact JSON messages to extract crate names and compile durations
  3. Identifies proc-macro crates by naming convention (_derive, _macros suffixes)
  4. Reads your Cargo.toml to check for known heavy feature combinations (e.g., tokio with full, syn with full)
  5. Generates a sorted report with color-coded durations and actionable recommendations

Tips

  • Run cargo clean before cargo why-slow to get accurate timings (cached builds show 0s)
  • Proc-macro crates compile serially and often dominate build times
  • Consider replacing heavy dependencies with lighter alternatives
  • Use only the features you need (e.g., tokio = { features = ["rt", "net"] } instead of features = ["full"])

License

Licensed under either of:

at your option.

About

A cargo subcommand that answers why your build is slow

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages