-
Notifications
You must be signed in to change notification settings - Fork 13.3k
derive(Debug) creates a fair bit of reduntant inlining work for the llvm optimizer #43843
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
Comments
We should just drop the |
Yup, that's a good point.
|
The inner methods aren't inlined, so this puts more pressure on LLVM for literally no benefit. Closes rust-lang#43843
Don't inline debug methods The inner methods aren't inlined, so this puts more pressure on LLVM for literally no benefit. Closes #43843
After discussing it on the forums I bit I decided to look into what the optimizer spends time on, and inlining seems to be a significant part of it. There seems to be a lot of room for improvement here.
Tested by compiling syntex in rustc-benchmarks (though the inlining time seem quite significant in other crates as well.).
I counted which functions were inlined the most, and
fmt::debug_tuple
and to a lesser extentfmt::debug_struct
, which are emitted when automatically derivingDebug
, and which simply wrap two other functions inside fmt::builder show up a lot. Maybe derive(debug) could output the wrapped functions instead, or the equivalent code, so llvm doesn't have to spend time inlining them (unless this causes problems for debug info).fmt::arguments::new_v1
is also inlined a lot, and also plays a role in derive(Debug). Maybe something could be done about that one as well, as it's simply a function that creates a struct but doesn't do anything else.Output from time-llvm-passes
Using `RUSTFLAGS="-Z time-llvm-passes" cargo +nightly build --release 2> llvm_time.txt` in the syntex-0.42.2 directory in rustc-benchmarks.It's a bit hard to say which crate is which, as the output from llvm and cargo isn't synced, though these are the bottom three (excluding the benchmark dummy) in reverse order:
Most inlined functions:
Running `RUSTFLAGS="-C remark=inline -g" cargo +nightly build --release 2> inlined.txt`, and filtering the output using this: ``` grep '.*[[:alnum:]]\{5\} inlined into' inlined.txt | sed 's/.*[0-9]: //g; s/d into.*/d into/' | sort | uniq -c | sort -gr > unique_inlines.txt ``` (Yeah it's a bit of a monstrosity, and takes a long time, maybe I could look into making some tool analyze this if it turns out to be useful.) gives:rustc --version
``` rustc 1.21.0-nightly (f774bce 2017-08-12) ```The text was updated successfully, but these errors were encountered: