Rust: Tracking issue for RFC 2412, "The optimize attribute"

Created on 7 Oct 2018  ยท  8Comments  ยท  Source: rust-lang/rust

This is a tracking issue for the RFC "The optimize attribute" (rust-lang/rfcs#2412).

Steps:

Unresolved questions:

  • [x] Should we also implement optimize(always)? optimize(level=x)?

    • [x] Left for future discussion, but should make sure such extension is possible.

  • [ ] Should there be any way to specify what global optimization for speed level is used in
    conjunction with the optimization for speed option (e.g. -Copt-level=s3 could be equivalent to
    -Copt-level=3 and #[optimize(size)] on the crate item);

    • [ ] This may matter for users of #[optimize(speed)].

  • [ ] Are the propagation and unused_attr approaches right?
B-RFC-approved B-RFC-implemented B-unstable C-tracking-issue T-lang

Most helpful comment

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;

  • debugging optimized builds (eg. you know which function breaks so you want to toggle some to off just to be able to debug it more easily)
  • assert handlers and other error handling things that you want to be able to quickly inspect in a debugger as a known "all the registers are sane" point in the code.

I'd love to see the optimize(none) attribute for working with large code-bases.

All 8 comments

@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;

  • debugging optimized builds (eg. you know which function breaks so you want to toggle some to off just to be able to debug it more easily)
  • assert handlers and other error handling things that you want to be able to quickly inspect in a debugger as a known "all the registers are sane" point in the code.

I'd love to see the optimize(none) attribute for working with large code-bases.

Triage: not aware of any movements here lately.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lambda-fairy picture lambda-fairy  ยท  3Comments

modsec picture modsec  ยท  3Comments

SharplEr picture SharplEr  ยท  3Comments

dnsl48 picture dnsl48  ยท  3Comments

pedrohjordao picture pedrohjordao  ยท  3Comments