Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/doc/src/guide/build-performance.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,24 @@ Trade-offs:
- ✅ Faster build times
- ❌ **Requires using nightly Rust and an [unstable Rust feature][parallel-frontend-issue]**

## Reducing built code

### Removing unused dependencies

Recommendation: Periodically review unused dependencies for removal using third-party tools like
[cargo-machete](https://crates.io/crates/cargo-machete),
[cargo-udeps](https://crates.io/crates/cargo-udeps),
[cargo-shear](https://crates.io/crates/cargo-shear).

When changing code,
it can be easy to miss that a dependency is no longer used and can be removed.

> *Note:* native support for this in Cargo is being tracked in [#15813](https://github.com/rust-lang/cargo/issues/15813).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: We normally use bold for note


Trade-offs:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure how much the trade-offs section makes sense here, as it's not a config that you would apply and it then affects your crate, but rather you just use a tool that might have false negatives/positives, and that's about it. But I also don't think it's super important.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It provided a nice place to

  • Call out the benefits
  • Call out false positives and false negatives

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, fair enough :)

- ✅ Faster full build and link times
- ❌ May incorrectly flag dependencies as unused or miss some

[parallel-frontend-blog]: https://blog.rust-lang.org/2023/11/09/parallel-rustc/
[parallel-frontend-issue]: https://github.com/rust-lang/rust/issues/113349
[build.rustflags]: ../reference/config.md#buildrustflags