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

More efficient runtime code generation for debug builds #5

Open
1 of 2 tasks
repi opened this issue Apr 1, 2019 · 4 comments
Open
1 of 2 tasks

More efficient runtime code generation for debug builds #5

repi opened this issue Apr 1, 2019 · 4 comments
Labels

Comments

@repi
Copy link
Contributor

repi commented Apr 1, 2019

It is a fairly well known & common problem that the efficiency of the generated in Rust is very low.

We've run into it multiple times where runtime performance becomes impossible to achieve with certain use cases and hot code, where one could get 1/200th of the performance compared to an optimized release build.

A typical such example is cryptographic hashing. Using the sha1 crate on a 10 MB file runs at 1 MB/s in debug compared to 200 MB/s in release, making it effectively unusable for that use case.

A common workaround is to build dev/debug config with O1 instead of O0, and in this specific case it improves performance to around 1/4th of release performance, but at the cost of significantly increasing compile and iteration times instead which we don't want to do for our large project and repository at this time.

There seems to be two potential solutions here, one short term and one longer term.

Short term:

  • Stabilize and use the new Profile Overrides cargo feature. This is available on nightly and I've tested this to work well for our worst use case so one can enable O3 just on say the sha crate.
[profile.dev.overrides.sha]
opt-level = 3

Longer term:

@aclysma
Copy link

aclysma commented Aug 17, 2019

You may have interest in tracking this bug: rust-lang/rust#63484
"Using profile-overrides results in both optimized and unoptimized versions of the same crate in linked executable"

@aclysma
Copy link

aclysma commented Dec 9, 2019

Just a heads up, this is supposed to hit stable in 1.41! :)
rust-lang/cargo#7591

There is a workaround for the bug I mentioned above that prevented generic code from being optimized (this mattered quite a lot in my case using nalgebra and nphysics)

@repi
Copy link
Contributor Author

repi commented Dec 9, 2019

Fantastic, thanks for the heads up!

@repi repi removed the prio: high label Aug 11, 2022
@mickvangelderen
Copy link

mickvangelderen commented Apr 22, 2023

This issue has seen no activity for 4 years except for removing the high priority label. Is it still relevant? I'm going through these issues because I'm trying to figure out if there's anything I could help with. It seems like some of the issues could be cleaned up a bit to create focus.

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

No branches or pull requests

3 participants