This is a tracking issue for the RFC "The optimize attribute" (rust-lang/rfcs#2412).
Steps:
Unresolved questions:
optimize(always)
? optimize(level=x)
?-Copt-level=s3
could be equivalent to-Copt-level=3
and #[optimize(size)]
on the crate item);#[optimize(speed)]
.unused_attr
approaches right?@nagisa I've added all unresolved questions from the RFC for completeness; the first 2 may already be resolved, if you feel that's the case; tick the boxes.
- Should we also implement optimize(always)? optimize(level=x)?
- Left for future discussion, but should make sure such extension is possible.
Marking as resolved just because these never came up during the RFC discussion, especially since the attribute design does not prohibit adding these as a feature later on.
Iโm assigning myself for now as I intend to implement this. Failing to dedicate time for this within two or so weeks I pledge to write up some instructions.
Iโve implementation for optimize(size)
now and am looking into ways to implement the harder side โ optimize(speed)
. I might end up splitting the work into two PRs depending on how things go.
Would this allow a crate (proptest
, quickcheck
) that is performance sensitive, but often used in debug builds, to specify that it should always be built with release?
The implementation for optimize(size)
and optimize(speed)
has now landed. Currently RFC is not fully implemented as the attribute propagation mechanic specified in the RFC is missing from the implementation. Nevertheless the actual functionality is present and can be toyed with.
Another thing that Iโve realised just now is that I never tested and is implemented incorrectly currently is "unused_attribute". The lint does not fire for the attribute applied to non-function items. This should also be fixed before any sort of stabilisation can proceed.
My recent observation is that optimize(none)
is fairly often used by people to debug functions in an otherwise optimized build. It may be sensible to add it as well at some point.
@nagisa Any updates re. the remaining work?
My recent observation is that optimize(none) is fairly often used by people to debug functions in an otherwise optimized build. It may be sensible to add it as well at some point.
+1 For this, in C++ code bases I've worked on this was very useful in a few cases;
I'd love to see the optimize(none)
attribute for working with large code-bases.
Triage: not aware of any movements here lately.
Most helpful comment
+1 For this, in C++ code bases I've worked on this was very useful in a few cases;
I'd love to see the
optimize(none)
attribute for working with large code-bases.