1 year ago
#366242
Damian
C# AggressiveInlining behaviour
I know what Inlining is supposed to mean from the JitAsm perspective. What I'm trying to determine is the following scenario The following assumptions SHOULD BE CONSIDERED:
- This code is a hotpath (it essentially gets called every 1 - 100ms)
- Performance is all that matters (Readability doesn't matter)
- The use of this attribute should not break any logic inside the method/s (if otherwise I would consider removing it)
public class A
{
B b; //injected here
public async Task FunctionOfMainInterest()
{
await b.ShouldBeInlined().ConfigureAwait(false); //Will this get inlined ?
}
}
public class B
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public async Task ShouldBeInlined()
{
//Do something here...
}
}
And pretending it does get inlined could that affect performance after jit finished all tiers (which I think are enabled by default) ? What exactly are the implications of using it ?
And last question would be pretending there are various other function calls in class B
that reference just like this example is it worth inlining them as well (because it seems to me that if this is true then Inlining will spread just like async
does) ?
UPDATE: As stated in the comments I did a sharplab test and compared the results (with and without the attribute). [Left is without and Right is with]
c#
assembly
compiler-optimization
inline-assembly
jit
0 Answers
Your Answer