-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Aggressive Inline fast-path of BuffersExtensions split methods #28928
Conversation
Hopefully this will also allow the Jit to devirtualize the |
@@ -103,6 +107,7 @@ public static T[] ToArray<T>(in this ReadOnlySequence<T> sequence) | |||
/// <summary> | |||
/// Writes contents of <paramref name="value"/> to <paramref name="writer"/> | |||
/// </summary> | |||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | |||
public static void Write<T>(this IBufferWriter<T> writer, ReadOnlySpan<T> value) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an interface call..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Its a non-virtual static call? A static method can't implement an interface
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And hopefully when its inlined and called with the sealed class
MemoryBufferWriter
the Jit will devirtalize it as the interface call inside cannot be any other type? /cc @AndyAyersMS
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May not be able to look at this for a few days, but superficially yes sealing the class should be sufficient.
Should we start by adding no inline to slower methods and see if JIT can figure it out? |
They shouldn't be inlined; I think it rejects anything with a loop as an inline candidate if it doesn't have AggressiveInline |
@dotnet-bot test this please |
Methods are split into a fast-path inline part and a slower non-inline part. Aggressively inline the fast-path.
from aspnet/SignalR#1907 (comment)
/cc @ahsonkhan @pakrym @davidfowl @JamesNK