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

always try inlining functions which do not call other functions #77307

Closed
wants to merge 7 commits into from

Conversation

lcnr
Copy link
Contributor

@lcnr lcnr commented Sep 28, 2020

a bit broken, I accidentally rebased #75495 while it was still closed

r? @wesleywiser like before, not yet ready for merge

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 28, 2020
@lcnr
Copy link
Contributor Author

lcnr commented Sep 28, 2020

rebased on top of #77306 meaning that all inlining ICE I know of are fixed

let's try to get a perf run here

@bors try @rust-timer queue

@rust-timer
Copy link
Collaborator

Awaiting bors try build completion

@bors
Copy link
Contributor

bors commented Sep 28, 2020

⌛ Trying commit d91b7490909d1aff17c37fbbe3d51a8823e59431 with merge b07bb178f07169aa2e38cad62befd47aecc28342...

@bors
Copy link
Contributor

bors commented Sep 28, 2020

☀️ Try build successful - checks-actions, checks-azure
Build commit: b07bb178f07169aa2e38cad62befd47aecc28342 (b07bb178f07169aa2e38cad62befd47aecc28342)

@rust-timer
Copy link
Collaborator

Queued b07bb178f07169aa2e38cad62befd47aecc28342 with parent d62d3f7, future comparison URL.

@rust-timer
Copy link
Collaborator

Finished benchmarking try commit (b07bb178f07169aa2e38cad62befd47aecc28342): comparison url.

Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. Please note that if the perf results are neutral, you should likely undo the rollup=never given below by specifying rollup- to bors.

Importantly, though, if the results of this run are non-neutral do not roll this PR up -- it will mask other regressions or improvements in the roll up.

@bors rollup=never

@wesleywiser
Copy link
Member

Really interesting results!

Incremental shows lots of regressions (although some wins too) which I think actually makes sense. Inlining makes our functions bigger which means changes to them take longer and also makes it more prone that a change to one function will cause other calling functions to also need to be re-compiled.

Putting aside the incremental tests, there's a lot of green down the results! Check builds are regressed nearly universally so we should probably disable inlining when in check only mode. Debug and opt builds look really good though! There's some nice wins on real world crates: 7% on clap-rs-opt, 5.1% on webrender-debug, 5% on hyper-2-opt, 4.5% on ripgrep-debug and 4.1% on ripgrep-opt. The rustc bootstrap results are also impressive: nearly 9% wallclock time improvement on rustc-middle!

@Mark-Simulacrum
Copy link
Member

I would ignore rustc bootstrap timing for now, I'm still experimenting with variance reduction strategies. 9% might not be representative.

@jyn514 jyn514 added I-slow Issue: Problems and improvements with respect to performance of generated code. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Sep 29, 2020
@lcnr
Copy link
Contributor Author

lcnr commented Sep 30, 2020

pushed some changes which might reduce the negative perf impact here

@bors try @rust-timer queue

@rust-timer
Copy link
Collaborator

Awaiting bors try build completion

@bors
Copy link
Contributor

bors commented Sep 30, 2020

⌛ Trying commit 9c25e949a8bf81185042f39e57604e44df7ab6a9 with merge 61b181866f0ce12555c356bf46da832c9a45a22e...

@bors
Copy link
Contributor

bors commented Sep 30, 2020

☀️ Try build successful - checks-actions, checks-azure
Build commit: 61b181866f0ce12555c356bf46da832c9a45a22e (61b181866f0ce12555c356bf46da832c9a45a22e)

@rust-timer
Copy link
Collaborator

Queued 61b181866f0ce12555c356bf46da832c9a45a22e with parent 6ac6c67, future comparison URL.

@rust-timer
Copy link
Collaborator

Finished benchmarking try commit (61b181866f0ce12555c356bf46da832c9a45a22e): comparison url.

Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. Please note that if the perf results are neutral, you should likely undo the rollup=never given below by specifying rollup- to bors.

Importantly, though, if the results of this run are non-neutral do not roll this PR up -- it will mask other regressions or improvements in the roll up.

@bors rollup=never

@lcnr
Copy link
Contributor Author

lcnr commented Sep 30, 2020

@lcnr
Copy link
Contributor Author

lcnr commented Sep 30, 2020

let's try again 😅

@bors try @rust-timer queue

@rust-timer
Copy link
Collaborator

Awaiting bors try build completion

@bors
Copy link
Contributor

bors commented Sep 30, 2020

⌛ Trying commit bd954f9012e18717651abd20aa754cf4fd57bdfa with merge 5c1c73fd351cfb72d9ec163bc1f61db9e9bf2b63...

@bors
Copy link
Contributor

bors commented Sep 30, 2020

☀️ Try build successful - checks-actions, checks-azure
Build commit: 5c1c73fd351cfb72d9ec163bc1f61db9e9bf2b63 (5c1c73fd351cfb72d9ec163bc1f61db9e9bf2b63)

@rust-timer
Copy link
Collaborator

Queued 5c1c73fd351cfb72d9ec163bc1f61db9e9bf2b63 with parent 12f667f, future comparison URL.

@rust-timer
Copy link
Collaborator

Finished benchmarking try commit (5c1c73fd351cfb72d9ec163bc1f61db9e9bf2b63): comparison url.

Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. Please note that if the perf results are neutral, you should likely undo the rollup=never given below by specifying rollup- to bors.

Importantly, though, if the results of this run are non-neutral do not roll this PR up -- it will mask other regressions or improvements in the roll up.

@bors rollup=never

@lcnr
Copy link
Contributor Author

lcnr commented Oct 20, 2020

@bors try @rust-timer queue exclude=deeply-nested

updated metadata encoding to only use 1 byte

@rust-timer
Copy link
Collaborator

Awaiting bors try build completion

@bors
Copy link
Contributor

bors commented Oct 20, 2020

⌛ Trying commit 6b17a76 with merge 2f0d06e5b8f278ed4180d80b7b6be06be6da3b36...

@bors
Copy link
Contributor

bors commented Oct 20, 2020

☀️ Try build successful - checks-actions, checks-azure
Build commit: 2f0d06e5b8f278ed4180d80b7b6be06be6da3b36 (2f0d06e5b8f278ed4180d80b7b6be06be6da3b36)

@rust-timer
Copy link
Collaborator

Queued 2f0d06e5b8f278ed4180d80b7b6be06be6da3b36 with parent 9832374, future comparison URL.

@rust-timer
Copy link
Collaborator

Finished benchmarking try commit (2f0d06e5b8f278ed4180d80b7b6be06be6da3b36): comparison url.

Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. Please note that if the perf results are neutral, you should likely undo the rollup=never given below by specifying rollup- to bors.

Importantly, though, if the results of this run are non-neutral do not roll this PR up -- it will mask other regressions or improvements in the roll up.

@bors rollup=never

@bors
Copy link
Contributor

bors commented Oct 20, 2020

@rust-timer: 🔑 Insufficient privileges: not in try users

@bjorn3
Copy link
Member

bjorn3 commented Oct 20, 2020

^ cc @pietroalbini

@pietroalbini
Copy link
Member

@Mark-Simulacrum could you take a look at this? I don't think I changed anything on the bors side regarding permissions.

@Mark-Simulacrum
Copy link
Member

@bors rollup=never

@lcnr
Copy link
Contributor Author

lcnr commented Oct 28, 2020

It looks like we end up with more calls to optimized_mir in some full benchmarks which is surprising to me.
Not yet sure why this is the case. Will try to spend some more time on this next week.

@crlf0710 crlf0710 added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 13, 2020
@camelid camelid added A-mir-opt Area: MIR optimizations A-mir-opt-inlining Area: MIR inlining labels Nov 16, 2020
@camelid camelid added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Dec 4, 2020
@lqd
Copy link
Member

lqd commented Dec 29, 2020

@oli-obk and @tmiasko figured out why in this zulip thread for unicode_normalization-check: the optimized MIR is always encoded for closures (and some of those call the big tables functions in this benchmark).

This was a bit surprising, and there wasn't an obvious reason this was done (apart from the case of generators), and may have just been an oversight. This might also be interesting to #80347.

Here's my interpretation of what oli and tomasz suggested trying (errors would be my own), and it did bring back the counts of the eval_to_allocation_raw, eval_to_const_value_raw and normalize_generic_arg_after_erasing_regions queries to their previous numbers (in the dozens rather than thousands) on the unicode_normalization-check benchmark.

bors added a commit to rust-lang-ci/rust that referenced this pull request Jan 13, 2021
Consistently avoid constructing optimized MIR when not doing codegen

The optimized MIR for closures is being encoded unconditionally, while
being unnecessary for cargo check. This turns out to be especially
costly with MIR inlining enabled, since it triggers computation of
optimized MIR for all callees that are being examined for inlining
purposes rust-lang#77307 (comment).

Skip encoding of optimized MIR for closures, enum constructors, struct
constructors, and trait fns when not doing codegen, like it is already
done for other items since 49433.
@lcnr
Copy link
Contributor Author

lcnr commented Jan 16, 2021

closing in favor of #81079

@lcnr lcnr closed this Jan 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-mir-opt Area: MIR optimizations A-mir-opt-inlining Area: MIR inlining I-slow Issue: Problems and improvements with respect to performance of generated code. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.