Skip to content

ash: Enable mostly-unused hint to speed up compilation #1004

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 10, 2025

Conversation

MarijnS95
Copy link
Collaborator

@MarijnS95 MarijnS95 commented Aug 10, 2025

Rust recently introduced the mostly-unused hint to speed up compilation of large crates where a significant portion of the contents are unlikely to be used concurrently. ash is such a crate, which takes quite long to compile relative to the amount and kind of abstraction it provides, simply caused by the vastness of the Vulkan API (and possible remaining inefficiencies in our generated code). This hint helps the compiler defer code generation until it knows it is definitely referenced and used, much like generics and #[inline] (the latter is already used consistently across this crate). All in all this new hint reduces compile time of the ash crate by about 8%.

It however requires the use of a nightly compiler and passing of the -Zprofile-hint-mostly-unused flag. The newly introduced [hints] table is not a syntax or parsing error on older compilers, but does issue a matching unused manifest key: hints warning. We should decide whether to merge this flag now and ignore that warning while developing, allowing users to automatically take advantage of this annotation when future Rust versions enable it automatically. Consumer crates can also configure it directly in their [profile] table however.

https://blog.rust-lang.org/inside-rust/2025/07/15/call-for-testing-hint-mostly-unused/

Rust recently introduced the `mostly-unused` hint to speed up
compilation of large crates where a significant portion of the
contents are unlikely to be used concurrently.  `ash` is such a crate,
which takes quite long to compile relative to the amount and kind of
abstraction it provides, simply caused by the vastness of the Vulkan
API (and possible remaining inefficiencies in our generated code).  This
hint helps the compiler defer code generation until it knows it is
definitely referenced and used, much like generics and `#[inline]` (the
latter is already used consistently across this crate).  All in all this
new hint reduces compile time of the `ash` crate by about 8%.

It however requires the use of a `nightly` compiler and passing of the
`-Zprofile-hint-mostly-unused` flag.  The newly introduced `[hints]`
table is not a syntax or parsing error on older compilers, but does
issue a matching `unused manifest key: hints` warning.

https://blog.rust-lang.org/inside-rust/2025/07/15/call-for-testing-hint-mostly-unused/
@MarijnS95 MarijnS95 added this to the Ash 0.39 with Vulkan 1.4 milestone Aug 10, 2025
Copy link
Collaborator

@Ralith Ralith left a comment

Choose a reason for hiding this comment

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

I'm in favor of getting ahead of this.

@MarijnS95 MarijnS95 marked this pull request as ready for review August 10, 2025 21:55
@MarijnS95 MarijnS95 merged commit de803ef into master Aug 10, 2025
20 checks passed
@MarijnS95 MarijnS95 deleted the hint-mostly-unused branch August 10, 2025 21:55
@MarijnS95
Copy link
Collaborator Author

And when stabilized, we might even consider removing all #[inline] again very far in the future when MSRV catches up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants