Skip to content

Downstream dependencies of a crate are rebuilt despite the changes not being public-facing #14604

Open

Description

Problem

Over at Zed we've noticed that even seemingly innocent changes to the crate that has many dependents causes us to rebuild (almost) the whole world. Adding a dbg! statement to the body of non-inlineable function, formatting code, updating a dependency to a new minor version and such still forces us to rebuild all dependants of an affected crate.
Our build graph could probably be improved by splitting out crates into smaller units, but the underlying issue is that we're rebuilding the world even when the public API of a crate did not change.
Attached is our timing file for making non-public-facing change to one of the core crates of Zed: timings.zip
What could take about 9 seconds (rebuilding project + relinking zed) takes 18 seconds instead.

Proposed Solution

There are efforts in flight to make Cargo rely less on mtime as a trigger for rebuilding the crate, but we are interested in an even stronger form of this PR where only a change to the public API of a crate should trigger a rebuild of the downstream dependants.

Notes

We have an internal prototype for one potential solution that relies on rustc emitting a hash of the public API of a crate as a part of it's "Metadata Finished" notification (Zulip Thread, rustc and cargo).

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

Metadata

Assignees

No one assigned

    Labels

    A-build-executionArea: anything dealing with executing the compilerArea: anything dealing with executing the compilerA-rebuild-detectionArea: rebuild detection and fingerprintingArea: rebuild detection and fingerprintingC-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`Command-buildS-blocked-externalStatus: ❌ blocked on something out of the direct control of the Cargo project, e.g., upstream fixStatus: ❌ blocked on something out of the direct control of the Cargo project, e.g., upstream fix

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions