Skip to content
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

Test opt-level not behaving as expected #106

Closed
giarc3 opened this issue Jan 13, 2020 · 1 comment
Closed

Test opt-level not behaving as expected #106

giarc3 opened this issue Jan 13, 2020 · 1 comment

Comments

@giarc3
Copy link
Member

giarc3 commented Jan 13, 2020

In ironoxide, we currently have 3 profile sections: [profile.dev], [profile.test], and [profile.release]. We have changed the default opt-level for dev and test to be 2.
I would advocate for setting dev back to 0 in order to allow for fast compilation by RLS while writing new code.

The problem with this is that I believe that [profile.test] is not working as documented. It appears that tests takes the optimization from [profile.dev] instead.

Running time cargo t after already compiling with cargo t --no-run, I get the following:

dev opt-level test opt-level test time
2 2 25s
0 2 90s

This suggests that test's opt-level is not respected.

I have seen threads (from years ago) where people suggest that [profile.test] and [profile.bench] be deprecated, as they argue that it should simply inherit from [profile.dev] and [profile.release], respectively, but I haven't seen mention of that happening, and the current docs still mention those sections.

In spite of all this, I would suggest the following:

  • Set dev's opt-level to its default (0)
  • Remove the [profile.test] section as I find it misleading
  • Use cargo t for general testing, and cargo t --release when speed is a factor
@giarc3 giarc3 changed the title Opt-level not behaving as expected Test opt-level not behaving as expected Jan 13, 2020
@giarc3
Copy link
Member Author

giarc3 commented Jan 14, 2020

I found some additional information regarding profile optimizations: rust-lang/cargo#7591 (comment)

In particular:

There is some possibly confusing interaction with the test/bench profile. Because dependencies are always built with the dev/release profiles, overridding test/bench usually does not have an effect (unless specifying a workspace member that is being tested/benched). Overriding test/bench was previously prohibited, but was relaxed when named profiles were added.

Stabilizing in Rust 1.41, we will be able to add a section to our Cargo.toml that looks like:

# Set the default for dependencies
[profile.dev.package."*"]
opt-level = 3

which should allow us to optimize our dependencies while lowering the opt-level for dev.

@giarc3 giarc3 closed this as completed Aug 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant