From dotnet/corefx#34425 (comment)
Given we do not pass spans by ref within the Utf8JsonWriter, it is likely fruitful to mark certain Write methods as AggressiveInlining to reduce the amount of struct copies.
Investigate the performance of deep call graphs and consider marking the common path as AggressiveInlining (if it shows noticeable performance improvement).
For example, something like this:
// => denotes a method call in this case (not valid C# syntax)
WriteStringValue(ReadOnlySpan<char> value, bool suppressEscaping = false)
=> WriteStringSuppressFalse(ReadOnlySpan<char> value)
=> WriteStringByOptions(ReadOnlySpan<char> value)
=> WriteStringMinimized(ReadOnlySpan<char> escapedValue)
=> WriteStringValue(ReadOnlySpan<char> escapedValue, ref int idx)
The above call graph includes WriteStringSuppressFalse which has just a single callsite, so it would ok to inline it into the caller - either using AggresiveInlining (preferred); or by just not having the separate method at all and just inlining the code in manually.
From dotnet/corefx#34425 (comment)
Given we do not pass spans by ref within the
Utf8JsonWriter, it is likely fruitful to mark certain Write methods asAggressiveInliningto reduce the amount of struct copies.Investigate the performance of deep call graphs and consider marking the common path as
AggressiveInlining(if it shows noticeable performance improvement).For example, something like this:
The above call graph includes
WriteStringSuppressFalsewhich has just a single callsite, so it would ok to inline it into the caller - either using AggresiveInlining (preferred); or by just not having the separate method at all and just inlining the code in manually.