MethodImplOptions.AggressiveInlining vs TargetedPatchingOptOut
Asked Answered
C

1

27

What is the difference between the MethodImplAttribute with the option MethodImplOptions.AggressiveInlining and the TargetedPatchingOptOut?

When I searched on Google everybody seems to says that both (might) inline the method but without giving the difference.

Concomitance answered 10/3, 2013 at 4:47 Comment(6)
TargetedPatchingOptOut is quite well explained here: stackoverflow.com/questions/6109745 The crucial part seems to be that the inlining is performed across assembly boundaries, which is not done by default. I would expect that AggressiveInlining is a hint to inline the method, but unlike TargetedPatchingOptOut does not allow inlining across assembly boundaries.Sunburn
After I read your comment I did a little bit more research and found this link. My understanding of this post is that you can apply both attribute AggressiveInlining will remove the size limit of the method while like you said the TargetedPatchingOptOut will allow inlining accross assembly boundaries. Is that correct?Concomitance
That's how I'd interpret it as well.Sunburn
How to i mark your comment as answer?Concomitance
You can't -- it's a comment :-) You seem to have spent more effort on this than me, so feel free to post an answer to your question yourself and accept it.Sunburn
@Sunburn and Yann: See here. tl;dr: inlining across assembly bounds is already done by the JIT for everything but the .Net core library, where TargetedPatchingOptOut is useful. For everyone else (all of us), TargetedPatchingOptOut is completely useless.Federal
C
14

I was waiting to see if someone else could have a better answer but it seems no.

After I read dtb comment I did a little bit more research and found this http://blogs.microsoft.co.il/blogs/sasha/archive/2012/01/20/aggressive-inlining-in-the-clr-4-5-jit.aspx.

My understanding of this post is that you can apply both attribute AggressiveInlining will remove the in-lining size limit of the method while like dtb said the TargetedPatchingOptOut will allow inlining accross assembly boundaries.

Concomitance answered 28/3, 2013 at 15:26 Comment(1)
As mentioned above, don't apply TargetedPatchingOptOut in your own code - see https://mcmap.net/q/161539/-method-inlining-across-native-images-of-assembliesBedwarmer

© 2022 - 2024 — McMap. All rights reserved.