runtime icon indicating copy to clipboard operation
runtime copied to clipboard

Recoup some of the perf losses in cold start serialization

Open eiriktsarpalis opened this issue 3 years ago • 1 comments

Makes the following changes:

  • Use ConstructorInfo invocations instead of static MethodInfo when instantiating generic metadata types. In my measurements this is ~2x faster.
  • Delegate JsonTypeInfo<T> construction to existing JsonConverter<T> instances, where possible.
Method Job Toolchain Mean Error StdDev Median Min Max Ratio MannWhitney(3%) RatioSD Gen 0 Gen 1 Allocated Alloc Ratio
NewCustomConverter Job-GMEIGR main 24.35 us 0.312 us 0.244 us 24.37 us 23.92 us 24.78 us 1.00 Base 0.00 0.9720 0.0972 9.74 KB 1.00
NewCustomConverter Job-XOBSON PR 19.80 us 0.389 us 0.400 us 19.78 us 19.23 us 20.45 us 0.82 Faster 0.02 0.7650 0.0765 7.86 KB 0.81

Fix #73388.

eiriktsarpalis avatar Aug 05 '22 20:08 eiriktsarpalis

Tagging subscribers to this area: @dotnet/area-system-text-json, @gregsdennis See info in area-owners.md if you want to be subscribed.

Issue Details

Reflection-based initialization of the generic metadata types was being done via generic MethodInfo invocations, which can be ~2x slower compared to ConstructorInfo invocations.

Method Job Toolchain Mean Error StdDev Median Min Max Ratio MannWhitney(3%) RatioSD Gen 0 Gen 1 Allocated Alloc Ratio
NewCustomConverter Job-CBOUFE main 27.58 us 1.400 us 1.556 us 27.92 us 24.88 us 30.32 us 1.00 Base 0.00 0.8943 0.0994 9.74 KB 1.00
NewCustomConverter Job-NMGPDV PR 24.55 us 1.478 us 1.702 us 24.16 us 21.94 us 27.43 us 0.89 Faster 0.09 0.8059 0.0895 8.52 KB 0.88

Fix #73388.

Author: eiriktsarpalis
Assignees: eiriktsarpalis
Labels:

area-System.Text.Json

Milestone: 7.0.0

msftbot[bot] avatar Aug 05 '22 20:08 msftbot[bot]