Skip to content

cargo diet #280

Description

@20jasper

background

60% of rust crates often do not have an explicit includes key, leading to including e2e tests, images, examples.

To fix this we can run cargo diet. I have been running cargo diet against all published crates via criner, so I have a list of common waste

how to fix

Run cargo diet -w --ignore-private to diet a workspace

To verify nothing went awry, you can package crate cargo package. There are some limitations such as runtime dependencies, which can cause false positives. For example, protoc-bin-vendored-linux-aarch_64 vendors a binary asset loaded at runtime

template

Adds explicit includes for `<crate>` to omit 37.3 kB of files (61% of total) under `/tests`, `/benches`, and `.github` from the published package. This removes extra files today, and prevents accidental inclusions later

Files removed from the package, by directory:

| Directory | Size | Files |
|---|---|---|
| `tests/**` | 16.9 kB | 1 |
| `benches/**` | 12.8 kB | 1 |
| `.github/**` | 7.4 kB | 7 |
| root config (`.clippy.toml`, `.rustfmt.toml`, `rust-toolchain.toml`, `.gitignore`) | 0.3 kB | 4 |

<ifExamples>
The examples are excluded from the published package, but they can be included if desired
</ifExamples>

Verified with package dry run and found with [cargo-diet](https://github.com/the-lean-crate/cargo-diet)

list

Top 50 repos to get started + ecosystem friends. GB/mo is uncompressed, so real bandwidth numbers will be quite a bit lower

repo GB/mo crates assignee PR
github.com/tokio-rs/tracing 391,696 (uncompressed) / ~14,760 real compressed 11 @20jasper tokio-rs/tracing#3583
github.com/mcgoo/vcpkg-rs 65,549 1
github.com/petgraph/petgraph 60,792 3
github.com/servo/rust-url 31,940 2
github.com/currysoftware/rust-stemmers 22,512 1
github.com/dtolnay/unicode-ident 11,729 1
github.com/saleemrashid/sha2-const 10,215 2
github.com/utkarshkukreti/diff.rs 9,679 1
github.com/burntsushi/fst 9,194 1
github.com/quickwit-inc/fst 7,447 1
gitlab.com/ryanobeirne/deltae 7,087 1
github.com/alacritty/alacritty 6,121 3
github.com/gresau/schemars 5,083 6
github.com/alexcrichton/xz2-rs 5,048 2
github.com/seanmonstar/httparse 4,841 1
github.com/tidwall/gjson.rs 4,427 1
github.com/blas-lapack-rs/lapack-sys 4,411 1
github.com/fede1024/rust-rdkafka 3,430 4
github.com/browserslist/browserslist-rs 3,354 1
github.com/tokio-rs/tokio 3,344 27
github.com/indexmap-rs/indexmap 2,894 2
github.com/whisperfish/rust-phonenumber 2,850 1
github.com/rust-sdl2/rust-sdl2 2,832 2
github.com/pyo3/pyo3 2,768 3
github.com/hyperium/hyper-util 2,738 4
github.com/hawkw/sharded-slab 2,593 1
github.com/10xgenomics/lz4-rs 2,536 2
github.com/glademiller/openapiv3 2,480 1
github.com/contentauth/c2pa-cbor 2,464 1
github.com/zkp-ld/rdf-canon 2,422 1
github.com/hsivonen/encoding_rs 2,247 1
github.com/eyre-rs/eyre 2,220 2
github.com/datadog/libdatadog 2,198 17
github.com/tower-rs/tower 2,198 10
github.com/tokio-rs/axum 2,122 3
github.com/rustwasm/console_error_panic_hook 2,061 1
github.com/crossbeam-rs/crossbeam 2,018 8
github.com/marwes/combine 1,993 2
github.com/theiskaa/readabilityrs 1,895 1
github.com/gz/rust-cpuid 1,857 1
github.com/davidarmstronglewis/uap-rs 1,786 2
github.com/woothee/woothee-rust 1,721 1
github.com/ua-parser/uap-rust 1,689 2
github.com/matthias247/futures-intrusive 1,688 1
github.com/madsmtm/objc2 1,605 195
github.com/nullus157/async-compression 1,560 1
github.com/succinctlabs/kzg-rs 1,505 1
github.com/chyh1990/yaml-rust 1,472 1
github.com/databendlabs/jsonb 1,455 1
github.com/materializeinc/rust-protobuf-native 1,396 3
github.com/biomejs/biome 734 17
github.com/oxc-project/unicode-id-start 304 1 @20jasper oxc-project/unicode-id-start#47
github.com/oxc-project/oxc-resolver 0* 1 @20jasper oxc-project/oxc-resolver#1325
github.com/oxc-project/schemars 6.3 1 @20jasper oxc-project/schemars#66
github.com/oxc-project/oxc-graphql-parser 0* 1 @20jasper oxc-project/oxc-graphql-parser#63
github.com/oxc-project/json-strip-comments 5.5 1 @20jasper oxc-project/json-strip-comments#209
github.com/oxc-project/oxc-toml 0.5 1 @20jasper oxc-project/oxc-toml#119
github.com/oxc-project/oxc (react-compiler) 0.06 1 @20jasper oxc-project/oxc-resolver#1325
github.com/oxc-project/oxc-zed 0* 1 @20jasper oxc-project/oxc-zed#236
github.com/oxc-project/cargo-release-oxc ~0 1 @20jasper oxc-project/cargo-release-oxc#276

*not published for a month, no download data yet

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions