dotnet / dotnet/runtime

Tracking issue for microbenchmarks performance issues when running in composite-r2r + interpreter fallback

Open
#126,037 0 comments 0 reactions 1 assignee Claimed by @BrzVlad View on GitHub
area-ReadyToRun
Dominant language
C#
Stars
18.3k
Forks
5.6k
PR merge metrics
PR metrics pending

Description

These numbers were obtained via an automated workflow where a subset of microbenchmarks is profiled (sampling information is obtained, for native code, compiled managed code as well as for interpreted managed code). The benchmarks to be profiled were selected from the slowest set of a full microbenchmark run (System.Numerics are heavily present, they were skipped for this workflow, I suspect most of them are impacted by a common problem, probably INumber related generics). The obtained profiling data was attached to the bottom of this issue as a reference. An AI tool was used for a high level analysis over these issues. Below are sources of problems detected by the tool together with how many benchmarks are impacted by this.

Based on this information, the problems are caused by fallback to the interpreter at runtime. The iOS solution would be to make sure we r2r the missing methods.

# Interpreter Execution Analysis

## Issues

**I1** (18 benchmarks): DateTimeFormat/Number generic formatting (FormatDigits, UInt32ToDecChars, WriteFourDigits, WriteTwoDigits)

**I2** (4 benchmarks): IPAddress formatting via generic Span ops (FormatIPv4/v6Address, Span.get_Item, Unsafe.Add)

**I3** (18 benchmarks): Reflection/DI InvokeStub + DelegateShuffleThunk (dynamically emitted IL stubs)

**I4** (12 benchmarks): Logger.Log generic dispatch (Logger::Log, LoggerLog, InstantiatingStub for logging)

**I5** (4 benchmarks): LINQ EnumerableSorter generic comparisons (CompareAnyKeys, QuickSelect, ComputeKeys)

**I6** (2 benchmarks): LINQ AggregateBy/CountBy generic dictionary ops (PopulateDictionary, CollectionsMarshal)

**I7** (15 benchmarks): IL_STUB_UnboxingStub — generic interface unboxing dispatch

**I8** (5 benchmarks): SortedSet generic traversal (IsWithinRange, VersionCheck, get_Left/Right, Min/MaxInternal)

**I9** (5 benchmarks): ImmutableCollection enumerator generic stubs (ISecurePooledObjectUser.get_PoolUserId)

**I10** (19 benchmarks): SZArrayHelper generic interface methods (GetEnumerator, get_Count, get_Item, CopyTo)

**I11** (6 benchmarks): Binary/XML serialization library generics (ProtoBuf, MessagePack, DataContractSerializer)

**I12** (4 benchmarks): Double.ConvertToIntegerNative — generic numeric conversion

**I13** (2 benchmarks): MulticastDelegate invoke stub (IL_STUB_MulticastDelegate_Invoke)

**I14** (1 benchmarks): Uri/IPv6 address parsing via generic Span ops (IPv6AddressHelper::Parse)

## Benchmark Table

| Benchmark | Interp% | Issues |
|---|---|---|
| System.Net.Primitives.Tests.IPAddressPerformanceTests.TryFormat(address: 1020:3040:5060:7080:9010:1112:1314:1516) | 88.9% | I2 |
| System.Net.Primitives.Tests.IPAddressPerformanceTests.CtorAndToString(address: [16, 32, 48, 64, 80, ...]) | 88.5% | I2 |
| System.Net.Primitives.Tests.IPAddressPerformanceTests.TryFormat(address: 143.24.20.36) | 86.2% | I2 |
| System.Net.Primitives.Tests.IPAddressPerformanceTests.CtorAndToString(address: [143, 24, 20, 36]) | 85.4% | I2 |
| LinqBenchmarks.Order00LinqMethodX | 83.6% | I5 |
| LinqBenchmarks.Order00LinqQueryX | 83.2% | I5 |
| PerfLabTests.DelegatePerf.MulticastDelegateInvoke(length: 1000) | 82.1% | I13 |
| PerfLabTests.DelegatePerf.MulticastDelegateInvoke(length: 100) | 81.1% | I13 |
| System.Collections.Tests.Perf_SortedSet.Min | 80.3% | I8 |
| System.Collections.Tests.Perf_SortedSet.Max | 77.8% | I8 |
| System.Tests.Perf_Uri.DnsSafeHost | 75.5% | I14 |
| System.Tests.Perf_DateTime.ToString(format: null) | 71.7% | I1 |
| System.Tests.Perf_DateTimeOffset.ToString(value: 12/30/2017 3:45:22 AM -08:00) | 71.4% | I1 |
| System.Tests.Perf_DateTimeOffset.ToString(format: null) | 70.8% | I1 |
| LinqBenchmarks.AggregateBy00LinqMethodX | 70.5% | I6 |
| System.Globalization.Tests.Perf_DateTimeCultureInfo.ToString(culturestring: ja) | 70.4% | I1 |
| System.Text.Tests.Perf_StringBuilder.Append_ValueTypes_Interpolated | 70.1% | I1 |
| System.Globalization.Tests.Perf_DateTimeCultureInfo.ToString(culturestring: da) | 69.2% | I1 |
| System.Text.Tests.Perf_StringBuilder.Append_ValueTypes | 68.9% | I1 |
| System.Globalization.Tests.Perf_DateTimeCultureInfo.ToString(culturestring: fr) | 68.8% | I1 |
| System.Globalization.Tests.Perf_DateTimeCultureInfo.ToString(culturestring: ) | 68.5% | I1 |
| System.Globalization.Tests.Perf_DateTimeCultureInfo.ToStringHebrewIsrael | 62.3% | I1 |
| System.Text.Json.Serialization.Tests.WriteJson.SerializeToStream(Mode: SourceGen) | 61.3% | I1 |
| MicroBenchmarks.Serializers.Json_ToStream.SystemTextJson_SourceGen_ | 60.8% | I1 |
| System.Text.Json.Serialization.Tests.WriteJson.SerializeToWriter(Mode: SourceGen) | 60.5% | I1 |
| MicroBenchmarks.Serializers.Binary_FromStream.ProtoBuffNet | 60.2% | I11 |
| System.Text.Json.Serialization.Tests.WriteJson.SerializeToUtf8Bytes(Mode: SourceGen) | 60.0% | I1 |
| System.Linq.Tests.Perf_OrderBy.OrderByValueType(NumberOfPeople: 512) | 59.3% | I5 |
| System.Text.Json.Serialization.Tests.WriteJson.SerializeToWriter(Mode: Reflection) | 57.9% | I1 |
| System.Text.Json.Serialization.Tests.WriteJson.SerializeToUtf8Bytes(Mode: Reflection) | 57.5% | I1 |
| System.Text.Json.Serialization.Tests.WriteJson.SerializeToStream(Mode: Reflection) | 57.2% | I1 |
| System.Linq.Tests.Perf_OrderBy.OrderByCustomComparer(NumberOfPeople: 512) | 55.6% | I5 |
| MicroBenchmarks.Serializers.Xml_FromStream.DataContractSerializer_BinaryXml_ | 55.6% | I11 |
| MicroBenchmarks.Serializers.Json_ToStream.SystemTextJson_Reflection_ | 55.3% | I1 |
| Microsoft.Extensions.Logging.LoggingOverhead.TwoArguments_DefineMessage | 52.8% | I4 |
| Microsoft.Extensions.Logging.ScopesOverheadBenchmark.NotFiltered(HasISupportLoggingScopeLogger: True, CaptureScopes: True) | 52.4% | I4 |
| Microsoft.Extensions.Logging.ScopesOverheadBenchmark.NotFiltered(HasISupportLoggingScopeLogger: False, CaptureScopes: True) | 52.4% | I4 |
| Microsoft.Extensions.Logging.ScopesOverheadBenchmark.NotFiltered(HasISupportLoggingScopeLogger: True, CaptureScopes: False) | 52.3% | I4 |
| LinqBenchmarks.CountBy00AggregateByX | 52.3% | I6, I7 |
| MicroBenchmarks.Serializers.Xml_ToStream.DataContractSerializer_BinaryXml_ | 52.0% | I11 |
| Microsoft.Extensions.Logging.ScopesOverheadBenchmark.NotFiltered_InsideScope(HasISupportLoggingScopeLogger: False, CaptureScopes: False) | 49.6% | I4 |
| Microsoft.Extensions.Logging.ScopesOverheadBenchmark.NotFiltered_InsideScope(HasISupportLoggingScopeLogger: True, CaptureScopes: False) | 49.3% | I4 |
| Microsoft.Extensions.Logging.ScopesOverheadBenchmark.NotFiltered(HasISupportLoggingScopeLogger: False, CaptureScopes: False) | 48.2% | I4 |
| Microsoft.Extensions.Logging.EventSourceLogger.NestedScopes_TwoMessages(HasSubscribers: False, Json: False) | 47.2% | I4 |
| Microsoft.Extensions.Logging.EventSourceLogger.NestedScopes_TwoMessages(HasSubscribers: False, Json: True) | 47.0% | I4 |
| Microsoft.Extensions.DependencyInjection.ActivatorUtilitiesBenchmark.Factory_1Injected_2Explicit_OutOfOrder | 46.5% | I3 |
| Microsoft.Extensions.Logging.ScopesOverheadBenchmark.NotFiltered_InsideScope(HasISupportLoggingScopeLogger: False, CaptureScopes: True) | 46.4% | I4 |
| System.Collections.Sort.Array_ComparerStruct(Size: 512) | 46.0% | I7 |
| System.Diagnostics.Perf_Activity.EnumerateActivityTagObjectsLarge | 45.4% | I7 |
| MicroBenchmarks.Serializers.Binary_ToStream.MessagePack_ | 45.2% | I11 |
| MicroBenchmarks.Serializers.Binary_ToStream.ProtoBuffNet | 43.0% | I11 |
| System.Linq.Tests.Perf_ImmutableArrayExtensions.SequenceEqual(input: IList) | 42.7% | I10 |
| MicroBenchmarks.Serializers.Binary_ToStream.ProtoBuffNet | 42.3% | I11 |
| Microsoft.Extensions.DependencyInjection.ActivatorUtilitiesBenchmark.Factory_3Explicit | 42.0% | I3 |
| Microsoft.Extensions.Logging.Formatting.TwoArguments | 41.3% | I4 |
| Microsoft.Extensions.Logging.FormattingOverhead.TwoArguments_DefineMessage | 41.2% | I4 |
| System.Diagnostics.Perf_Activity.EnumerateActivityTagObjectsSmall | 39.1% | I7 |
| System.Reflection.Invoke.StaticMethod4_int_string_struct_class | 38.8% | I3 |
| System.Reflection.Invoke.StaticMethod4_int_string_struct_class_MethodInvoker | 38.1% | I3 |
| System.Reflection.Invoke.Property_Set_class | 37.6% | I3 |
| LinqBenchmarks.CountBy00LinqMethodX | 37.5% | I7 |
| System.Text.Json.Serialization.Tests.WriteJson>.SerializeToWriter(Mode: Reflection) | 34.7% | I7 |
| System.Diagnostics.Perf_Activity.EnumerateActivityLinksLarge | 33.2% | I7 |
| System.Reflection.Invoke.StaticMethod4_int_string_struct_class_MethodInvokerWithSpan | 32.4% | I3 |
| System.Collections.IterateForEach.ImmutableSortedDictionary(Size: 512) | 32.4% | I9 |
| System.Tests.Perf_Random.Next_long_long | 32.3% | I12 |
| System.Reflection.Invoke.Ctor4_int_string_struct_class | 32.3% | I3 |
| System.Collections.IterateForEach.ImmutableList(Size: 512) | 32.3% | I9 |
| System.Tests.Perf_Random.Next_long | 32.2% | I12 |
| System.Collections.IterateForEach.ImmutableSortedSet(Size: 512) | 32.2% | I9 |
| System.Collections.IterateForEach.ImmutableDictionary(Size: 512) | 31.6% | I9 |
| System.Reflection.Invoke.Method0_NoParms_MethodInvoker | 31.5% | I3 |
| System.Diagnostics.Perf_Activity.EnumerateActivityLinksSmall | 31.5% | I7 |
| System.Collections.IterateForEach.ImmutableHashSet(Size: 512) | 31.4% | I9 |
| System.Tests.Perf_Random.Next_int | 31.1% | I12 |
| System.Reflection.Invoke.Property_Set_int | 29.7% | I3 |
| PerfLabTests.LowLevelPerf.StaticDelegate | 29.4% | I3 |
| System.Collections.Sort.Array_ComparerStruct(Size: 512) | 28.5% | I7 |
| System.Diagnostics.Perf_Activity.EnumerateActivityEventsLarge | 27.9% | I7 |
| System.Reflection.Invoke.Ctor4_int_string_struct_class_ConstructorInvoker | 27.7% | I3 |
| Microsoft.Extensions.DependencyInjection.ActivatorUtilitiesBenchmark.Factory_1Injected_2Explicit | 27.7% | I3 |
| System.Diagnostics.Perf_Activity.EnumerateActivityEventsSmall | 27.3% | I7 |
| System.Tests.Perf_Random.Next_int_int | 26.5% | I12 |
| System.Collections.Sort.Array_ComparerStruct(Size: 512) | 25.8% | I7 |
| System.Collections.Sort.Array_ComparerStruct(Size: 512) | 25.8% | I7 |
| System.Collections.IterateForEach.SortedSet(Size: 512) | 25.3% | I8 |
| System.Collections.IterateForEach.SortedDictionary(Size: 512) | 25.2% | I8 |
| System.Reflection.Invoke.Ctor0_NoParams_ConstructorInvoker | 24.7% | I3 |
| System.Collections.IterateForEach.SortedDictionary(Size: 512) | 22.7% | I8 |
| System.Reflection.Invoke.Method0_NoParms | 21.0% | I3 |
| Microsoft.Extensions.DependencyInjection.ScopeValidation.Transient | 20.8% | I3 |
| Microsoft.Extensions.DependencyInjection.GetService.Transient | 20.6% | I3 |
| Microsoft.Extensions.DependencyInjection.GetServiceIEnumerable.Transient | 20.5% | I3 |
| System.Perf_Convert.ChangeType | 19.9% | I7 |
| System.Linq.Tests.Perf_Enumerable.EmptyTakeSelectToArray | 18.6% | I10 |
| Microsoft.Extensions.DependencyInjection.ScopeValidation.TransientWithScopeValidation | 18.4% | I3 |
| System.Collections.CtorFromCollectionNonGeneric.SortedList(Size: 512) | 17.3% | I7 |
| System.Linq.Tests.Perf_Enumerable.ElementAt(input: IEnumerable) | 10.2% | I10 |
| System.Linq.Tests.Perf_Enumerable.Count(input: IEnumerable) | 6.3% | I10 |
| System.Linq.Tests.Perf_Enumerable.CastToSameType(input: IEnumerable) | 5.6% | I10 |
| System.Linq.Tests.Perf_ImmutableArrayExtensions.SequenceEqual(input: ICollection) | 5.2% | I10 |
| System.Linq.Tests.Perf_Enumerable.Sum(input: IEnumerable) | 5.1% | I10 |
| System.Linq.Tests.Perf_Enumerable.Aggregate_Seed(input: IEnumerable) | 4.4% | I10 |
| System.Linq.Tests.Perf_Enumerable.FirstWithPredicate_LastElementMatches(input: IEnumerable) | 4.3% | I10 |
| System.Linq.Tests.Perf_Enumerable.All_AllElementsMatch(input: IEnumerable) | 4.2% | I10 |
| System.Linq.Tests.Perf_Enumerable.WhereAny_LastElementMatches(input: IEnumerable) | 4.1% | I10 |
| System.Linq.Tests.Perf_Enumerable.AnyWithPredicate_LastElementMatches(input: IEnumerable) | 4.1% | I10 |
| System.Linq.Tests.Perf_Enumerable.WhereFirst_LastElementMatches(input: IEnumerable) | 3.9% | I10 |
| System.Linq.Tests.Perf_Enumerable.LastWithPredicate_FirstElementMatches(input: IOrderedEnumerable) | 2.4% | I10 |
| ArrayDeAbstraction.foreach_member_array_via_interface | 1.6% | I10 |
| System.Collections.IterateForEach.IEnumerable(Size: 512) | 1.5% | I10 |
| ArrayDeAbstraction.foreach_static_readonly_array_via_interface | 1.5% | I10 |
| ArrayDeAbstraction.foreach_static_readonly_array_via_interface_property | 1.4% | I10 |
| ArrayDeAbstraction.foreach_opaque_array_via_interface | 1.4% | I10 |

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.