Skip to content

Add project goal for reducing target directory size - #805

Open
jyn514 wants to merge 15 commits into
rust-lang:mainfrom
jyn514:target-dir
Open

jyn514 wants to merge 15 commits into
rust-lang:mainfrom
jyn514:target-dir

Conversation

@jyn514

@jyn514 jyn514 commented Oct 1, 2026 •

Copy link
Copy Markdown
Member

@jyn514

jyn514 commented Oct 1, 2026

Copy link
Copy Markdown
Member Author

cc @Kobzol @Zeklandia

@nxsaken nxsaken added the C-goal-proposal This is a goal proposal label Oct 1, 2026
@rustbot

rustbot commented Oct 1, 2026

Copy link
Copy Markdown
Collaborator

A #goals/proposed topic was opened to discuss this issue.

Comment thread src/2026/target-dir-size.md Outdated
jyn514 and others added 2 commits October 1, 2026 19:39
Co-authored-by: Nurzhan Saken <nurzhan.sakenov@gmail.com>
Comment thread src/2026/target-dir-size.md Outdated

@Kobzol Kobzol left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This looks awesome! I can feel the energy you put into this from the document :)

View changes since this review

## Summary

Investigate, triage, and decrease the size of intermediate compilation directories (e.g. `target/`).
With a funded team of 3-5 engineers, we aim over the next year to decrease the size of the directory by 60% or more for fresh builds and by 80% or more for repeated builds across version branches.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is very ambitious :) That being said, -Zembed-metadata should already reduce the size in some cases by up to 35%, so that should be a good headstart 😆

Comment thread src/2026/target-dir-size.md Outdated
| Create a prototype PoC that breaks down `.rmeta` files and `incremental/` directories by size and query across multiple build invocations | @jyn514 | |
| Extend the PoC to a maintainable tool that can be used outside the project goal team | ? | Likely implemented as a `rustc_driver` or `-Z` flag |
| Add support for running that tool to `rustc-perf` benchmarks | ? | Subgoal id A2 |
| Add a graph of artifact sizes over time to the `rustc-perf` site | ? | |

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

rustc-perf can already graph the history of any metric, so if we add new metrics, that should work out of the box.

(btw I'm happy to help with any rustc-perf changes)

Comment thread src/2026/target-dir-size.md Outdated
|Task |Experience level |Time investment |
|-------------------------------------------------|----------------------------------------------------------------------|-----------------------------------------------------------------|
|Create a maintainable benchmarking tool |Medium Rust experience, compiler experience preferable |1-3 weeks full-time |
|Extend rustc-perf suite to measure artifact sizes|Medium Rust experience, compiler experience not necessary |2-4 weeks full-time |

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is more of a compiler work, than rustc-perf work, IMO.

[cargo#17512]: https://github.com/rust-lang/cargo/pull/17512
[brlo]: https://blog.rust-lang.org/inside-rust/2026/08/18/reducing-target-dir-size-on-nightly/

Kobzol has been responsible for implementing and stabilizing `-Z embed-metadata=no`, and is a current member of the Council.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The Council note felt a bit out of nowhere 😆 But I guess street credit helps? 😆

Comment thread src/2026/target-dir-size.md Outdated
Comment thread src/2026/target-dir-size.md Outdated
Co-authored-by: Makai <m4kai410@gmail.com>


Suggested reviewers:
- cargo: Ed Page, Ross Sullivan

@weihanglo weihanglo Oct 4, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I would love offering some review capacity (and anyway as a t-cargo member I have to review the design). However, this is also kinda fund-needed. At least I'll need to convince my employer to put me on it.

View changes since the review

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Let me know if I or others can help with convincing your employer. The target directory size and churn is arguably the number 1 most-complained-about issue in all of Rust, so I think a very strong case can be made.

@kamulos

kamulos commented Oct 4, 2026

Copy link
Copy Markdown

Maybe one more area of research, that strikes me as disproportionate:

I have a workspace with 25 crates. When I run cargo test it produces 25 binaries, most of which are 100-200 MB in size. Even crates without a test create a 7 MB binary.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C-goal-proposal This is a goal proposal

Projects

Status: To Do

Development

Successfully merging this pull request may close these issues.

10 participants