Use [profile.release.build-override] to optimize build dependencies. #437
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Based on these parts of the Cargo docs on Profiles:
I'm pretty sure that adding this to the workspace
Cargo.toml
will cause[build-dependencies]
(and build scripts and proc macros) to be compiled the same way as regular dependencies, but only when building with--release
(so debug mode isn't affected):Sadly, everyone using Rust-GPU would need to replicate this, so we might want to document this somewhere.
(We should probably also document that passing
--release
makes building the shaders themselves faster)In our case, the relevant "build dependencies" are
rustc_codegen_spirv
and its dependencies (e.g.rspirv
), where having them optimized makes some linker passes up to 20x faster (including the new one in #414, which is why I looked into this).The overall results from this are also pretty compelling:
Assuming
sky-shader
takes somewhere betweensimplest-shader
andmouse-shader
, we can see that the speedup for the final shader crate (i.e. when a lot of SPIR-V codegen and linking is involved) is around 10x, whereascore
itself doesn't get a big speedup (as most of the work is inrustc
itself, which is optimized either way).