Skip to content

Investigate Utf8JsonWriter performance improvement by using AggressiveInlining #28408

@ahsonkhan

Description

@ahsonkhan

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions