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

[WIP] Allow functions to be inlined across crates without an inline attribute #70550

Closed
wants to merge 1 commit into from

Conversation

Zoxc
Copy link
Contributor

@Zoxc Zoxc commented Mar 30, 2020

r? @ghost

@Zoxc Zoxc changed the title [WIP] Allow functions to be inline across crates without an inline attribute [WIP] Allow functions to be inlined across crates without an inline attribute Mar 30, 2020
@Zoxc
Copy link
Contributor Author

Zoxc commented Mar 30, 2020

@bors try @rust-timer queue

@rust-timer
Copy link
Collaborator

Awaiting bors try build completion

@bors
Copy link
Contributor

bors commented Mar 30, 2020

⌛ Trying commit 9d6086f with merge 72176503fc0d08a32adfdda3aea038c0f6561a0e...

@bors
Copy link
Contributor

bors commented Mar 30, 2020

☀️ Try build successful - checks-azure
Build commit: 72176503fc0d08a32adfdda3aea038c0f6561a0e (72176503fc0d08a32adfdda3aea038c0f6561a0e)

@rust-timer
Copy link
Collaborator

Queued 72176503fc0d08a32adfdda3aea038c0f6561a0e with parent 4911572, future comparison URL.

@jonas-schievink
Copy link
Contributor

Wow those are some nice gains!

@bjorn3
Copy link
Member

bjorn3 commented Mar 30, 2020

inflate-check clean:

Totals 0.833 99.31%* -15.7% (-0.155) 48219 0.3% (130.000) 0.000 0.0% (0.000)
typeck_tables_of 0.578 69.35% -20.4% (-0.148) 43 0.0% (0.000) 0.000 0.0% (0.000)

Similar for other crates. Some functions called by typeck_tables_of could use a #[inline] it seems.

@nikomatsakis
Copy link
Contributor

Closing this pull request as Zoxc is stepping back from compiler development; see rust-lang/team#316.

@jonas-schievink
Copy link
Contributor

I might pick this one up. Having to put #[inline] on tiny functions is fairly unnecessary and I see that all the time.

@Zoxc
Copy link
Contributor Author

Zoxc commented Apr 15, 2020

@jonas-schievink If you pick this up, there's still some test failures if the threshold is high (related to allocators). MIR inlining is likely to have a large interaction with this, so it might be less beneficial once we get that working. Also using ThinLTO might be better for optimizing the compiler itself, but that is blocked on LLVM 10 due to ThinLTO bugs,

These benchmarks show that we don't do enough inlining in the compiler currently, and one way or another we should find a way to increase that.

bors added a commit to rust-lang-ci/rust that referenced this pull request Oct 14, 2023
Automatically enable cross-crate inlining for small functions

This is basically reviving rust-lang#70550

The `#[inline]` attribute can have a significant impact on code generation or runtime performance (because it enables inlining between CGUs where it would normally not happen) and also on compile-time performance (because it enables MIR inlining). But it has to be added manually, which is awkward.

This PR factors whether a DefId is cross-crate inlinable into a query, and replaces all uses of `CodegenFnAttrs::requests_inline` with this new query. The new query incorporates all the other logic that is used to determine whether a Def should be treated as cross-crate-inlinable, and as a last step inspects the function's optimized_mir to determine if it should be treated as cross-crate-inlinable.

The heuristic implemented here is deliberately conservative; we only infer inlinability for functions whose optimized_mir does not contain any calls or asserts. I plan to study adjusting the cost model later, but for now the compile time implications of this change are so significant that I think this very crude heuristic is well worth landing.
bors added a commit to rust-lang-ci/rust that referenced this pull request Oct 15, 2023
Automatically enable cross-crate inlining for small functions

This is basically reviving rust-lang#70550

The `#[inline]` attribute can have a significant impact on code generation or runtime performance (because it enables inlining between CGUs where it would normally not happen) and also on compile-time performance (because it enables MIR inlining). But it has to be added manually, which is awkward.

This PR factors whether a DefId is cross-crate inlinable into a query, and replaces all uses of `CodegenFnAttrs::requests_inline` with this new query. The new query incorporates all the other logic that is used to determine whether a Def should be treated as cross-crate-inlinable, and as a last step inspects the function's optimized_mir to determine if it should be treated as cross-crate-inlinable.

The heuristic implemented here is deliberately conservative; we only infer inlinability for functions whose optimized_mir does not contain any calls or asserts. I plan to study adjusting the cost model later, but for now the compile time implications of this change are so significant that I think this very crude heuristic is well worth landing.
bors added a commit to rust-lang-ci/rust that referenced this pull request Oct 15, 2023
Automatically enable cross-crate inlining for small functions

This is basically reviving rust-lang#70550

The `#[inline]` attribute can have a significant impact on code generation or runtime performance (because it enables inlining between CGUs where it would normally not happen) and also on compile-time performance (because it enables MIR inlining). But it has to be added manually, which is awkward.

This PR factors whether a DefId is cross-crate inlinable into a query, and replaces all uses of `CodegenFnAttrs::requests_inline` with this new query. The new query incorporates all the other logic that is used to determine whether a Def should be treated as cross-crate-inlinable, and as a last step inspects the function's optimized_mir to determine if it should be treated as cross-crate-inlinable.

The heuristic implemented here is deliberately conservative; we only infer inlinability for functions whose optimized_mir does not contain any calls or asserts. I plan to study adjusting the cost model later, but for now the compile time implications of this change are so significant that I think this very crude heuristic is well worth landing.
bors added a commit to rust-lang-ci/rust that referenced this pull request Oct 18, 2023
Automatically enable cross-crate inlining for small functions

This is basically reviving rust-lang#70550

The `#[inline]` attribute can have a significant impact on code generation or runtime performance (because it enables inlining between CGUs where it would normally not happen) and also on compile-time performance (because it enables MIR inlining). But it has to be added manually, which is awkward.

This PR factors whether a DefId is cross-crate inlinable into a query, and replaces all uses of `CodegenFnAttrs::requests_inline` with this new query. The new query incorporates all the other logic that is used to determine whether a Def should be treated as cross-crate-inlinable, and as a last step inspects the function's optimized_mir to determine if it should be treated as cross-crate-inlinable.

The heuristic implemented here is deliberately conservative; we only infer inlinability for functions whose optimized_mir does not contain any calls or asserts. I plan to study adjusting the cost model later, but for now the compile time implications of this change are so significant that I think this very crude heuristic is well worth landing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants