From 9b49d97af1c38374fbb1a568e7890a1eaec5ce98 Mon Sep 17 00:00:00 2001 From: Josh Triplett Date: Sun, 13 Jul 2025 00:41:30 -0700 Subject: [PATCH 1/2] Use new `hints.mostly-unused` Most users of the `rustix` crate will use a fraction of its API surface area. Nightly rustc provides an option `-Zhint-mostly-unused` to tell it to defer as much compilation as possible, which provides a substantial performance improvement if most of that compilation doesn't end up happening. Cargo plumbs this option through using the new `[hints]` table. This will cause users of the `rustix` crate to default to setting `hint-mostly-unused`. (Top-level crates can override this if they wish, using a new profile option.) Note that setting this hint does not increase the MSRV of the rustix crate, as old versions of Cargo will ignore it. New versions of Cargo will respect it automatically (and, until we stabilize it, Cargo will do nothing unless you pass `-Zprofile-hint-mostly-unused` to cargo). Some sample performance numbers: this takes `rustix` compilation time with `all-apis` enabled from 5.9s to 4.3s (a 27% improvement). --- Cargo.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index 8ed7f0265..ba4f3f223 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,6 +15,9 @@ categories = ["os::unix-apis", "date-and-time", "filesystem", "network-programmi include = ["src", "build.rs", "Cargo.toml", "COPYRIGHT", "LICENSE*", "/*.md", "benches"] rust-version = "1.63" +[hints] +mostly-unused = true + [dependencies] bitflags = { version = "2.4.0", default-features = false } From 0a14d08dccb67660e3b4f14e67ecc9b656366766 Mon Sep 17 00:00:00 2001 From: Josh Triplett Date: Sun, 13 Jul 2025 12:05:23 -0700 Subject: [PATCH 2/2] Add comment to the mostly-unused hint --- Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/Cargo.toml b/Cargo.toml index ba4f3f223..85f9360e7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,6 +16,7 @@ include = ["src", "build.rs", "Cargo.toml", "COPYRIGHT", "LICENSE*", "/*.md", "b rust-version = "1.63" [hints] +# Most users use a fraction of the rustix API surface area, so this reduces compilation times mostly-unused = true [dependencies]