Skip to content

Commit fd3b266

Browse files
committed
docs(guide): Point out tools for reducing dependencies
This is a fairly non-invasive change people can make to speed up builds. My big motivation for writing this is I saw mention of https://crates.io/crates/cargo-unused-features and wanted this in first before calling that out.
1 parent b89128d commit fd3b266

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/doc/src/guide/build-performance.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,24 @@ Trade-offs:
8686
- ✅ Faster build times
8787
-**Requires using nightly Rust and an [unstable Rust feature][parallel-frontend-issue]**
8888

89+
## Reducing built code
90+
91+
### Removing unused dependencies
92+
93+
Recommendation: Periodically review unused dependencies for removal using third-party tools like
94+
[cargo-machete](https://crates.io/crates/cargo-machete),
95+
[cargo-udeps](https://crates.io/crates/cargo-udeps),
96+
[cargo-shear](https://crates.io/crates/cargo-shear).
97+
98+
When changing code,
99+
it can be easy to miss that a dependency is no longer used and can be removed.
100+
101+
> *Note:* native support for this in Cargo is being tracked in [#15813](https://github.com/rust-lang/cargo/issues/15813).
102+
103+
Trade-offs:
104+
- ✅ Faster full build and link times
105+
- ❌ May incorrectly flag dependencies as unused or miss some
106+
89107
[parallel-frontend-blog]: https://blog.rust-lang.org/2023/11/09/parallel-rustc/
90108
[parallel-frontend-issue]: https://github.com/rust-lang/rust/issues/113349
91109
[build.rustflags]: ../reference/config.md#buildrustflags

0 commit comments

Comments
 (0)