Skip to content

Add 'NoInlining' to marshalling stubs #1953

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

Draft
wants to merge 20 commits into
base: dev/disable-marshaler-t-aot
Choose a base branch
from

Conversation

Sergio0694
Copy link
Member

This PR adds NoInlining to all marshalling stubs. This matches .NET Native and should reduce binary size.

@Sergio0694 Sergio0694 requested a review from manodasanW March 25, 2025 20:20
@Sergio0694 Sergio0694 force-pushed the dev/disable-marshaler-t-aot branch from 333f649 to 92c9e44 Compare April 1, 2025 17:58
@jkotas
Copy link
Member

jkotas commented Apr 2, 2025

Is it really profitable to mark close to everything with [MethodImpl(MethodImplOptions.NoInlining)]?

I would expect it to be profitable only for small methods that are called from many places for which you may not be happy about the codesize / perf tradeoff done by the JIT. There should be relatively a few of those.

[MethodImpl(MethodImplOptions.NoInlining)] on larger methods is unnecessary. JIT won't inline them unless it has evidence based on profile data that it is worth to inline.

[MethodImpl(MethodImplOptions.NoInlining)] on small methods that have one or a few callsites may even regress both code size and performance.

@Sergio0694
Copy link
Member Author

We're not entirely sure yet, I was going to try this out in the Store and check the size diff. @MichalStrehovsky suggested making this change to match what .NET Native is doing. Looking at some diffs in the Store, it seems we're currently inlining a ton of these marshalling stubs, and he estimated we might save ~5MB just with this change. There's more details from Michal earlier on in the email thread about .NET Native vs Native AOT regression tracking that Andy added you the other day, if you're curious 🙂

I'll report back when I get numbers from this change and then we can reevaluate, I assume?

@jkotas
Copy link
Member

jkotas commented Apr 3, 2025

It would be interesting to find the top 100 [MethodImpl(MethodImplOptions.NoInlining)] annotations that help to reduce the size the most, and how much the rest leaves on the table.

@Sergio0694 Sergio0694 force-pushed the dev/disable-marshaler-t-aot branch from 92c9e44 to c07f758 Compare April 3, 2025 19:00
@Sergio0694 Sergio0694 force-pushed the dev/disable-marshaler-t-aot branch from c07f758 to 5d21903 Compare June 3, 2025 19:02
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.

2 participants