-
Notifications
You must be signed in to change notification settings - Fork 151
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
Remove #[inline(always)] #129
Comments
I'd rather have a guarantee that compiler will always optimize bit access. Maybe there is some way to disable this diagnostic in clippy? |
Well, I was looking for a way but it seems that can only be done by config gating in the source (== Meh) or when integrating clippy into the crate itself (== Double Meh); part of the beauty of clippy is that one can simply run "[c|x]argo clippy" and receive some interesting insight into the code, sometimes even with nice optimisation suggestions, without any non-trivial setup... The guarantee that you're mentioning does not exist anyways, it's just a compiler hint so the compiler might decide to ignore it anyway. And as you might know: premature optimisation is the root of all evil... |
Is that from running clippy on the device crate or on a crate that depends on the device crate? If the later, why is clippy analyzing a dependency? That seems odd.
Just want to point out that the unmangled "main" symbol is not your program main but a rustc generated stub with no source code information. That stub will eventually call your program main (I think it may go through the start lang item first) but you still have to step through some assembly before you get there.
Which way is that? Removing
Having a Cargo feature for optimizing dependencies even when compiling with just I don't recall if Just pointing out that unoptimized register access when using |
I'm compiling examples in the device crate.
It makes the debugging info larger by about 20%, mostly due to more included detail. I didn't note any changes to the executed code at all.
No, unfortunately it does not, but it also doesn't make it worse. However the amount of debug info created by rustc is absolutely horrific. I've had cases where applications even failed to compile in dev mode because:
There're only two options to tackle this in my opinion:
|
So I was just revisiting this again and did a more thorough test of the 3 different options:
I was specifically looking at generated code size and size of auxiliary files, and here are the results in order for debug:
So in a nutshell, [#inline] creates identical release binaries to [#inline(always)] and slightly better than without while still retaining the ability to run For debug [#inline] creates the smallest binaries and the least metadata (it also compiles way faster than without inlining. Edit: [1] The results are actually not quite as bad but one example fails to compile leaving a 23MB temporary file around. |
Funny, someone else(tm) had the same idea for std recently: rust-lang/rust#43367 ;) |
Done in #141 |
Since I absolutely love clippy, I also wanted to run it on my embedded experiments but essentially failed to do so because I ran into tons of:
warnings and so I decided to look into whether that provides any benefit to the generated code at all and surprise it does not provide any benefit at all:
When compiling in release mode (with lto on) the only difference is that
main
is not inlined intoreset_handler
which is actually a positive since it makes debugging a whole lot easier if you have a trivially named main function you can put your breakpoint on.In debug mode it has a slightly larger impact of around 20% but that seems to be mostly coming other skipped inlining opportunities rather any of the functions marked als always inline not being inline anymore which can probably offset by adjusting the inlining target, if necessary.
But most importantly to me, this allows me to run clippy just fine:
Woohoo!
The text was updated successfully, but these errors were encountered: