Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable more intrinsics for Tier0 #83002

Merged
merged 1 commit into from
Mar 6, 2023
Merged

Conversation

EgorBo
Copy link
Member

@EgorBo EgorBo commented Mar 5, 2023

This PR extends the list of intrinsics we now expand in Tier0 (except explicit minopts and debug-friendly code). The reasons are:

  1. Some intrinsics such as get_IsValueType lead to early dead code removal in Tier0 - it means we don't waste time resolving tokens inside dead branches
  2. Most of them are simpler than call and we don't have to call all those expensive VM APIs such as getCallInfo
  3. We now never compile some of these methods in JIT separately (and install call counting stubs, etc) e.g. Interlocked.Add() function is now never compiled.

Previous round of adding intrinsics in Tier0 demonstrated nice rps/latency wins in TE benchmarks:
image

Jit-diffs (-f --tier0):

PMI CodeSize Diffs for System.Private.CoreLib.dll, framework assemblies [tier0] for  default jit

Summary of Code Size diffs:
(Lower is better)

Total bytes of base: 67834276
Total bytes of diff: 67732277
Total bytes of delta: -101999 (-0.15 % of base)
Total relative delta: NaN
    diff is an improvement.
    relative diff is a regression.


Top file improvements (bytes):
      -57370 : System.Private.CoreLib.dasm (-0.76% of base)
      -13499 : System.Text.Json.dasm (-1.07% of base)
       -9422 : System.Data.Common.dasm (-0.57% of base)
       -6040 : System.Collections.Concurrent.dasm (-1.17% of base)
       -4608 : System.Private.Xml.dasm (-0.11% of base)
       -3102 : System.Private.DataContractSerialization.dasm (-0.29% of base)
       -2025 : System.ComponentModel.TypeConverter.dasm (-0.55% of base)
       -1834 : System.Collections.Immutable.dasm (-0.09% of base)
        -774 : FSharp.Core.dasm (-0.08% of base)
        -618 : System.Linq.Parallel.dasm (-0.02% of base)
        -501 : System.Threading.Tasks.Dataflow.dasm (-0.04% of base)
        -488 : System.Collections.dasm (-0.07% of base)
        -296 : System.Threading.Channels.dasm (-0.11% of base)
        -192 : System.Linq.dasm (-0.01% of base)
        -124 : Microsoft.CodeAnalysis.VisualBasic.dasm (-0.00% of base)
        -115 : System.Runtime.Caching.dasm (-0.14% of base)
        -112 : System.Private.Xml.Linq.dasm (-0.06% of base)
        -101 : System.Net.Requests.dasm (-0.08% of base)
         -73 : Microsoft.CodeAnalysis.dasm (-0.00% of base)
         -60 : System.Net.Http.dasm (-0.01% of base)

55 total files with Code Size differences (55 improved, 0 regressed), 221 unchanged.

Top method regressions (bytes):
           6 ( 1.49% of base) : System.Collections.Concurrent.dasm - System.Collections.Concurrent.ConcurrentDictionary`2[System.__Canon,System.Nullable`1[int]]:get_Comparer():System.Collections.Generic.IEqualityComparer`1[System.__Canon]:this
           5 ( 6.02% of base) : System.Private.CoreLib.dasm - System.Buffers.Binary.BinaryPrimitives:TryWriteHalfBigEndian(System.Span`1[ubyte],System.Half):bool
           5 ( 6.58% of base) : System.Private.CoreLib.dasm - System.Buffers.Binary.BinaryPrimitives:TryWriteInt16BigEndian(System.Span`1[ubyte],short):bool
           5 ( 6.02% of base) : System.Private.CoreLib.dasm - System.Buffers.Binary.BinaryPrimitives:WriteHalfBigEndian(System.Span`1[ubyte],System.Half)
           5 ( 6.58% of base) : System.Private.CoreLib.dasm - System.Buffers.Binary.BinaryPrimitives:WriteInt16BigEndian(System.Span`1[ubyte],short)
           5 ( 3.29% of base) : System.Private.CoreLib.dasm - System.Double:System.Numerics.IFloatingPoint<System.Double>.TryWriteExponentBigEndian(System.Span`1[ubyte],byref):bool:this
           5 ( 3.47% of base) : System.Private.CoreLib.dasm - System.Int16:System.Numerics.IBinaryInteger<System.Int16>.TryWriteBigEndian(System.Span`1[ubyte],byref):bool:this
           5 ( 3.16% of base) : System.Private.CoreLib.dasm - System.Runtime.InteropServices.NFloat:System.Numerics.IFloatingPoint<System.Runtime.InteropServices.NFloat>.TryWriteExponentBigEndian(System.Span`1[ubyte],byref):bool:this
           4 ( 5.33% of base) : System.Private.CoreLib.dasm - System.Buffers.Binary.BinaryPrimitives:TryWriteUInt16BigEndian(System.Span`1[ubyte],ushort):bool
           4 ( 5.33% of base) : System.Private.CoreLib.dasm - System.Buffers.Binary.BinaryPrimitives:WriteUInt16BigEndian(System.Span`1[ubyte],ushort)
           4 ( 2.63% of base) : System.Private.CoreLib.dasm - System.Half:System.Numerics.IFloatingPoint<System.Half>.TryWriteSignificandBigEndian(System.Span`1[ubyte],byref):bool:this
           4 ( 3.88% of base) : System.Reflection.Metadata.dasm - System.Reflection.BlobUtilities:WriteUInt16BE(ubyte[],int,ushort)
           4 ( 1.13% of base) : System.Private.CoreLib.dasm - System.UInt16:System.Numerics.IBinaryInteger<System.UInt16>.TryReadBigEndian(System.ReadOnlySpan`1[ubyte],bool,byref):bool
           4 ( 2.80% of base) : System.Private.CoreLib.dasm - System.UInt16:System.Numerics.IBinaryInteger<System.UInt16>.TryWriteBigEndian(System.Span`1[ubyte],byref):bool:this
           3 ( 4.35% of base) : System.Private.CoreLib.dasm - System.Buffers.Binary.BinaryPrimitives:ReadHalfBigEndian(System.ReadOnlySpan`1[ubyte]):System.Half
           3 ( 3.19% of base) : System.Private.CoreLib.dasm - System.Buffers.Binary.BinaryPrimitives:TryReadHalfBigEndian(System.ReadOnlySpan`1[ubyte],byref):bool
           2 ( 0.39% of base) : System.Private.CoreLib.dasm - System.Int16:System.Numerics.IBinaryInteger<System.Int16>.TryReadBigEndian(System.ReadOnlySpan`1[ubyte],bool,byref):bool
           2 ( 3.03% of base) : System.Private.CoreLib.dasm - System.Text.Unicode.Utf8Utility:ExtractUtf8TwoByteSequenceFromFirstUtf16Char(uint):uint
           1 ( 1.64% of base) : System.Private.CoreLib.dasm - System.Buffers.Binary.BinaryPrimitives:ReadUInt16BigEndian(System.ReadOnlySpan`1[ubyte]):ushort
           1 ( 1.18% of base) : System.Private.CoreLib.dasm - System.Buffers.Binary.BinaryPrimitives:TryReadUInt16BigEndian(System.ReadOnlySpan`1[ubyte],byref):bool

Top method improvements (bytes):
       -1396 (-91.72% of base) : System.Private.CoreLib.dasm - System.Enum:TryParse[double](System.ReadOnlySpan`1[ushort],bool,bool,byref):bool
       -1396 (-91.72% of base) : System.Private.CoreLib.dasm - System.Enum:TryParse[int](System.ReadOnlySpan`1[ushort],bool,bool,byref):bool
       -1396 (-91.72% of base) : System.Private.CoreLib.dasm - System.Enum:TryParse[long](System.ReadOnlySpan`1[ushort],bool,bool,byref):bool
       -1396 (-91.72% of base) : System.Private.CoreLib.dasm - System.Enum:TryParse[short](System.ReadOnlySpan`1[ushort],bool,bool,byref):bool
       -1396 (-91.72% of base) : System.Private.CoreLib.dasm - System.Enum:TryParse[System.Numerics.Vector`1[float]](System.ReadOnlySpan`1[ushort],bool,bool,byref):bool
       -1396 (-91.72% of base) : System.Private.CoreLib.dasm - System.Enum:TryParse[ubyte](System.ReadOnlySpan`1[ushort],bool,bool,byref):bool
       -1196 (-91.02% of base) : System.Data.Common.dasm - System.Data.EnumerableRowCollection`1[double]:GetLinqDataView():System.Data.LinqDataView:this
       -1196 (-91.02% of base) : System.Data.Common.dasm - System.Data.EnumerableRowCollection`1[int]:GetLinqDataView():System.Data.LinqDataView:this
       -1196 (-91.02% of base) : System.Data.Common.dasm - System.Data.EnumerableRowCollection`1[long]:GetLinqDataView():System.Data.LinqDataView:this
       -1196 (-91.02% of base) : System.Data.Common.dasm - System.Data.EnumerableRowCollection`1[short]:GetLinqDataView():System.Data.LinqDataView:this
       -1196 (-91.02% of base) : System.Data.Common.dasm - System.Data.EnumerableRowCollection`1[System.Nullable`1[int]]:GetLinqDataView():System.Data.LinqDataView:this
       -1196 (-91.02% of base) : System.Data.Common.dasm - System.Data.EnumerableRowCollection`1[System.Numerics.Vector`1[float]]:GetLinqDataView():System.Data.LinqDataView:this
       -1196 (-91.02% of base) : System.Data.Common.dasm - System.Data.EnumerableRowCollection`1[ubyte]:GetLinqDataView():System.Data.LinqDataView:this
        -887 (-68.28% of base) : System.Private.CoreLib.dasm - System.MemoryExtensions:SequenceEqual[System.__Canon](System.ReadOnlySpan`1[System.__Canon],System.ReadOnlySpan`1[System.__Canon],System.Collections.Generic.IEqualityComparer`1[System.__Canon]):bool
        -702 (-36.11% of base) : System.Private.CoreLib.dasm - System.Collections.Generic.Dictionary`2[System.__Canon,System.Nullable`1[int]]:TryInsert(System.__Canon,System.Nullable`1[int],ubyte):bool:this
        -697 (-36.06% of base) : System.Private.CoreLib.dasm - System.Collections.Generic.Dictionary`2[System.__Canon,System.__Canon]:TryInsert(System.__Canon,System.__Canon,ubyte):bool:this
        -697 (-35.84% of base) : System.Private.CoreLib.dasm - System.Collections.Generic.Dictionary`2[System.__Canon,System.Resources.ResourceLocator]:TryInsert(System.__Canon,System.Resources.ResourceLocator,ubyte):bool:this
        -692 (-36.08% of base) : System.Private.CoreLib.dasm - System.Collections.Generic.Dictionary`2[System.__Canon,long]:TryInsert(System.__Canon,long,ubyte):bool:this
        -681 (-19.29% of base) : System.Collections.Immutable.dasm - System.Collections.Frozen.FrozenDictionary:ChooseImplementationOptimizedForReading[System.__Canon,System.Nullable`1[int]](System.Collections.Generic.Dictionary`2[System.__Canon,System.Nullable`1[int]]):System.Collections.Frozen.FrozenDictionary`2[System.__Canon,System.Nullable`1[int]]
        -655 (-19.58% of base) : System.Collections.Immutable.dasm - System.Collections.Frozen.FrozenSet:ChooseImplementationOptimizedForReading[System.__Canon](System.Collections.Generic.HashSet`1[System.__Canon]):System.Collections.Frozen.FrozenSet`1[System.__Canon]

Top method regressions (percentages):
           5 ( 6.58% of base) : System.Private.CoreLib.dasm - System.Buffers.Binary.BinaryPrimitives:TryWriteInt16BigEndian(System.Span`1[ubyte],short):bool
           5 ( 6.58% of base) : System.Private.CoreLib.dasm - System.Buffers.Binary.BinaryPrimitives:WriteInt16BigEndian(System.Span`1[ubyte],short)
           5 ( 6.02% of base) : System.Private.CoreLib.dasm - System.Buffers.Binary.BinaryPrimitives:TryWriteHalfBigEndian(System.Span`1[ubyte],System.Half):bool
           5 ( 6.02% of base) : System.Private.CoreLib.dasm - System.Buffers.Binary.BinaryPrimitives:WriteHalfBigEndian(System.Span`1[ubyte],System.Half)
           4 ( 5.33% of base) : System.Private.CoreLib.dasm - System.Buffers.Binary.BinaryPrimitives:TryWriteUInt16BigEndian(System.Span`1[ubyte],ushort):bool
           4 ( 5.33% of base) : System.Private.CoreLib.dasm - System.Buffers.Binary.BinaryPrimitives:WriteUInt16BigEndian(System.Span`1[ubyte],ushort)
           3 ( 4.35% of base) : System.Private.CoreLib.dasm - System.Buffers.Binary.BinaryPrimitives:ReadHalfBigEndian(System.ReadOnlySpan`1[ubyte]):System.Half
           4 ( 3.88% of base) : System.Reflection.Metadata.dasm - System.Reflection.BlobUtilities:WriteUInt16BE(ubyte[],int,ushort)
           5 ( 3.47% of base) : System.Private.CoreLib.dasm - System.Int16:System.Numerics.IBinaryInteger<System.Int16>.TryWriteBigEndian(System.Span`1[ubyte],byref):bool:this
           5 ( 3.29% of base) : System.Private.CoreLib.dasm - System.Double:System.Numerics.IFloatingPoint<System.Double>.TryWriteExponentBigEndian(System.Span`1[ubyte],byref):bool:this
           3 ( 3.19% of base) : System.Private.CoreLib.dasm - System.Buffers.Binary.BinaryPrimitives:TryReadHalfBigEndian(System.ReadOnlySpan`1[ubyte],byref):bool
           5 ( 3.16% of base) : System.Private.CoreLib.dasm - System.Runtime.InteropServices.NFloat:System.Numerics.IFloatingPoint<System.Runtime.InteropServices.NFloat>.TryWriteExponentBigEndian(System.Span`1[ubyte],byref):bool:this
           2 ( 3.03% of base) : System.Private.CoreLib.dasm - System.Text.Unicode.Utf8Utility:ExtractUtf8TwoByteSequenceFromFirstUtf16Char(uint):uint
           4 ( 2.80% of base) : System.Private.CoreLib.dasm - System.UInt16:System.Numerics.IBinaryInteger<System.UInt16>.TryWriteBigEndian(System.Span`1[ubyte],byref):bool:this
           4 ( 2.63% of base) : System.Private.CoreLib.dasm - System.Half:System.Numerics.IFloatingPoint<System.Half>.TryWriteSignificandBigEndian(System.Span`1[ubyte],byref):bool:this
           1 ( 1.64% of base) : System.Private.CoreLib.dasm - System.Buffers.Binary.BinaryPrimitives:ReadUInt16BigEndian(System.ReadOnlySpan`1[ubyte]):ushort
           6 ( 1.49% of base) : System.Collections.Concurrent.dasm - System.Collections.Concurrent.ConcurrentDictionary`2[System.__Canon,System.Nullable`1[int]]:get_Comparer():System.Collections.Generic.IEqualityComparer`1[System.__Canon]:this
           1 ( 1.18% of base) : System.Private.CoreLib.dasm - System.Buffers.Binary.BinaryPrimitives:TryReadUInt16BigEndian(System.ReadOnlySpan`1[ubyte],byref):bool
           4 ( 1.13% of base) : System.Private.CoreLib.dasm - System.UInt16:System.Numerics.IBinaryInteger<System.UInt16>.TryReadBigEndian(System.ReadOnlySpan`1[ubyte],bool,byref):bool
           1 ( 0.56% of base) : System.Private.CoreLib.dasm - System.Threading.Tasks.Task:AtomicStateUpdate(int,int,byref):bool:this

Top method improvements (percentages):
       -1396 (-91.72% of base) : System.Private.CoreLib.dasm - System.Enum:TryParse[double](System.ReadOnlySpan`1[ushort],bool,bool,byref):bool
       -1396 (-91.72% of base) : System.Private.CoreLib.dasm - System.Enum:TryParse[int](System.ReadOnlySpan`1[ushort],bool,bool,byref):bool
       -1396 (-91.72% of base) : System.Private.CoreLib.dasm - System.Enum:TryParse[long](System.ReadOnlySpan`1[ushort],bool,bool,byref):bool
       -1396 (-91.72% of base) : System.Private.CoreLib.dasm - System.Enum:TryParse[short](System.ReadOnlySpan`1[ushort],bool,bool,byref):bool
       -1396 (-91.72% of base) : System.Private.CoreLib.dasm - System.Enum:TryParse[System.Numerics.Vector`1[float]](System.ReadOnlySpan`1[ushort],bool,bool,byref):bool
       -1396 (-91.72% of base) : System.Private.CoreLib.dasm - System.Enum:TryParse[ubyte](System.ReadOnlySpan`1[ushort],bool,bool,byref):bool
       -1196 (-91.02% of base) : System.Data.Common.dasm - System.Data.EnumerableRowCollection`1[double]:GetLinqDataView():System.Data.LinqDataView:this
       -1196 (-91.02% of base) : System.Data.Common.dasm - System.Data.EnumerableRowCollection`1[int]:GetLinqDataView():System.Data.LinqDataView:this
       -1196 (-91.02% of base) : System.Data.Common.dasm - System.Data.EnumerableRowCollection`1[long]:GetLinqDataView():System.Data.LinqDataView:this
       -1196 (-91.02% of base) : System.Data.Common.dasm - System.Data.EnumerableRowCollection`1[short]:GetLinqDataView():System.Data.LinqDataView:this
       -1196 (-91.02% of base) : System.Data.Common.dasm - System.Data.EnumerableRowCollection`1[System.Nullable`1[int]]:GetLinqDataView():System.Data.LinqDataView:this
       -1196 (-91.02% of base) : System.Data.Common.dasm - System.Data.EnumerableRowCollection`1[System.Numerics.Vector`1[float]]:GetLinqDataView():System.Data.LinqDataView:this
       -1196 (-91.02% of base) : System.Data.Common.dasm - System.Data.EnumerableRowCollection`1[ubyte]:GetLinqDataView():System.Data.LinqDataView:this
        -361 (-90.25% of base) : System.ComponentModel.TypeConverter.dasm - System.ComponentModel.BindingList`1[System.Numerics.Vector`1[float]]:Initialize():this
        -285 (-87.96% of base) : System.ComponentModel.TypeConverter.dasm - System.ComponentModel.BindingList`1[double]:Initialize():this
        -277 (-87.66% of base) : System.ComponentModel.TypeConverter.dasm - System.ComponentModel.BindingList`1[long]:Initialize():this
        -277 (-87.66% of base) : System.ComponentModel.TypeConverter.dasm - System.ComponentModel.BindingList`1[System.Nullable`1[int]]:Initialize():this
        -275 (-87.58% of base) : System.ComponentModel.TypeConverter.dasm - System.ComponentModel.BindingList`1[int]:Initialize():this
        -275 (-87.58% of base) : System.ComponentModel.TypeConverter.dasm - System.ComponentModel.BindingList`1[short]:Initialize():this
        -275 (-87.58% of base) : System.ComponentModel.TypeConverter.dasm - System.ComponentModel.BindingList`1[ubyte]:Initialize():this

1268 total methods with Code Size differences (1247 improved, 21 regressed), 375945 unchanged.

--------------------------------------------------------------------------------

Example of a size "regression": https://www.diffchecker.com/qaKdHKwT/

@dotnet-issue-labeler dotnet-issue-labeler bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Mar 5, 2023
@ghost ghost assigned EgorBo Mar 5, 2023
@ghost
Copy link

ghost commented Mar 5, 2023

Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch, @kunalspathak
See info in area-owners.md if you want to be subscribed.

Issue Details

This PR extends the list of intrinsics we now expand in Tier0 (except explicit minopts and debug-friendly code). The reasons are:

  1. Some intrinsics such as get_IsValueType lead to early dead code removal in Tier0 - it means we don't waste time resolving tokens inside dead branches
  2. Most of them are simpler than call and we don't have to call all these expensive stuff such as getCallInfo
  3. We now never compile some of these method in JIT separately (and install call counting stubs, etc) e.g. Interlocked.Add() function

Previous round of adding intrinsics in Tier0 demonstrated nice TP wins in TE benchmarks:
image

Jit-diffs (-f --tier0):

PMI CodeSize Diffs for System.Private.CoreLib.dll, framework assemblies [tier0] for  default jit

Summary of Code Size diffs:
(Lower is better)

Total bytes of base: 67834276
Total bytes of diff: 67732277
Total bytes of delta: -101999 (-0.15 % of base)
Total relative delta: NaN
    diff is an improvement.
    relative diff is a regression.


Top file improvements (bytes):
      -57370 : System.Private.CoreLib.dasm (-0.76% of base)
      -13499 : System.Text.Json.dasm (-1.07% of base)
       -9422 : System.Data.Common.dasm (-0.57% of base)
       -6040 : System.Collections.Concurrent.dasm (-1.17% of base)
       -4608 : System.Private.Xml.dasm (-0.11% of base)
       -3102 : System.Private.DataContractSerialization.dasm (-0.29% of base)
       -2025 : System.ComponentModel.TypeConverter.dasm (-0.55% of base)
       -1834 : System.Collections.Immutable.dasm (-0.09% of base)
        -774 : FSharp.Core.dasm (-0.08% of base)
        -618 : System.Linq.Parallel.dasm (-0.02% of base)
        -501 : System.Threading.Tasks.Dataflow.dasm (-0.04% of base)
        -488 : System.Collections.dasm (-0.07% of base)
        -296 : System.Threading.Channels.dasm (-0.11% of base)
        -192 : System.Linq.dasm (-0.01% of base)
        -124 : Microsoft.CodeAnalysis.VisualBasic.dasm (-0.00% of base)
        -115 : System.Runtime.Caching.dasm (-0.14% of base)
        -112 : System.Private.Xml.Linq.dasm (-0.06% of base)
        -101 : System.Net.Requests.dasm (-0.08% of base)
         -73 : Microsoft.CodeAnalysis.dasm (-0.00% of base)
         -60 : System.Net.Http.dasm (-0.01% of base)

55 total files with Code Size differences (55 improved, 0 regressed), 221 unchanged.

Top method regressions (bytes):
           6 ( 1.49% of base) : System.Collections.Concurrent.dasm - System.Collections.Concurrent.ConcurrentDictionary`2[System.__Canon,System.Nullable`1[int]]:get_Comparer():System.Collections.Generic.IEqualityComparer`1[System.__Canon]:this
           5 ( 6.02% of base) : System.Private.CoreLib.dasm - System.Buffers.Binary.BinaryPrimitives:TryWriteHalfBigEndian(System.Span`1[ubyte],System.Half):bool
           5 ( 6.58% of base) : System.Private.CoreLib.dasm - System.Buffers.Binary.BinaryPrimitives:TryWriteInt16BigEndian(System.Span`1[ubyte],short):bool
           5 ( 6.02% of base) : System.Private.CoreLib.dasm - System.Buffers.Binary.BinaryPrimitives:WriteHalfBigEndian(System.Span`1[ubyte],System.Half)
           5 ( 6.58% of base) : System.Private.CoreLib.dasm - System.Buffers.Binary.BinaryPrimitives:WriteInt16BigEndian(System.Span`1[ubyte],short)
           5 ( 3.29% of base) : System.Private.CoreLib.dasm - System.Double:System.Numerics.IFloatingPoint<System.Double>.TryWriteExponentBigEndian(System.Span`1[ubyte],byref):bool:this
           5 ( 3.47% of base) : System.Private.CoreLib.dasm - System.Int16:System.Numerics.IBinaryInteger<System.Int16>.TryWriteBigEndian(System.Span`1[ubyte],byref):bool:this
           5 ( 3.16% of base) : System.Private.CoreLib.dasm - System.Runtime.InteropServices.NFloat:System.Numerics.IFloatingPoint<System.Runtime.InteropServices.NFloat>.TryWriteExponentBigEndian(System.Span`1[ubyte],byref):bool:this
           4 ( 5.33% of base) : System.Private.CoreLib.dasm - System.Buffers.Binary.BinaryPrimitives:TryWriteUInt16BigEndian(System.Span`1[ubyte],ushort):bool
           4 ( 5.33% of base) : System.Private.CoreLib.dasm - System.Buffers.Binary.BinaryPrimitives:WriteUInt16BigEndian(System.Span`1[ubyte],ushort)
           4 ( 2.63% of base) : System.Private.CoreLib.dasm - System.Half:System.Numerics.IFloatingPoint<System.Half>.TryWriteSignificandBigEndian(System.Span`1[ubyte],byref):bool:this
           4 ( 3.88% of base) : System.Reflection.Metadata.dasm - System.Reflection.BlobUtilities:WriteUInt16BE(ubyte[],int,ushort)
           4 ( 1.13% of base) : System.Private.CoreLib.dasm - System.UInt16:System.Numerics.IBinaryInteger<System.UInt16>.TryReadBigEndian(System.ReadOnlySpan`1[ubyte],bool,byref):bool
           4 ( 2.80% of base) : System.Private.CoreLib.dasm - System.UInt16:System.Numerics.IBinaryInteger<System.UInt16>.TryWriteBigEndian(System.Span`1[ubyte],byref):bool:this
           3 ( 4.35% of base) : System.Private.CoreLib.dasm - System.Buffers.Binary.BinaryPrimitives:ReadHalfBigEndian(System.ReadOnlySpan`1[ubyte]):System.Half
           3 ( 3.19% of base) : System.Private.CoreLib.dasm - System.Buffers.Binary.BinaryPrimitives:TryReadHalfBigEndian(System.ReadOnlySpan`1[ubyte],byref):bool
           2 ( 0.39% of base) : System.Private.CoreLib.dasm - System.Int16:System.Numerics.IBinaryInteger<System.Int16>.TryReadBigEndian(System.ReadOnlySpan`1[ubyte],bool,byref):bool
           2 ( 3.03% of base) : System.Private.CoreLib.dasm - System.Text.Unicode.Utf8Utility:ExtractUtf8TwoByteSequenceFromFirstUtf16Char(uint):uint
           1 ( 1.64% of base) : System.Private.CoreLib.dasm - System.Buffers.Binary.BinaryPrimitives:ReadUInt16BigEndian(System.ReadOnlySpan`1[ubyte]):ushort
           1 ( 1.18% of base) : System.Private.CoreLib.dasm - System.Buffers.Binary.BinaryPrimitives:TryReadUInt16BigEndian(System.ReadOnlySpan`1[ubyte],byref):bool

Top method improvements (bytes):
       -1396 (-91.72% of base) : System.Private.CoreLib.dasm - System.Enum:TryParse[double](System.ReadOnlySpan`1[ushort],bool,bool,byref):bool
       -1396 (-91.72% of base) : System.Private.CoreLib.dasm - System.Enum:TryParse[int](System.ReadOnlySpan`1[ushort],bool,bool,byref):bool
       -1396 (-91.72% of base) : System.Private.CoreLib.dasm - System.Enum:TryParse[long](System.ReadOnlySpan`1[ushort],bool,bool,byref):bool
       -1396 (-91.72% of base) : System.Private.CoreLib.dasm - System.Enum:TryParse[short](System.ReadOnlySpan`1[ushort],bool,bool,byref):bool
       -1396 (-91.72% of base) : System.Private.CoreLib.dasm - System.Enum:TryParse[System.Numerics.Vector`1[float]](System.ReadOnlySpan`1[ushort],bool,bool,byref):bool
       -1396 (-91.72% of base) : System.Private.CoreLib.dasm - System.Enum:TryParse[ubyte](System.ReadOnlySpan`1[ushort],bool,bool,byref):bool
       -1196 (-91.02% of base) : System.Data.Common.dasm - System.Data.EnumerableRowCollection`1[double]:GetLinqDataView():System.Data.LinqDataView:this
       -1196 (-91.02% of base) : System.Data.Common.dasm - System.Data.EnumerableRowCollection`1[int]:GetLinqDataView():System.Data.LinqDataView:this
       -1196 (-91.02% of base) : System.Data.Common.dasm - System.Data.EnumerableRowCollection`1[long]:GetLinqDataView():System.Data.LinqDataView:this
       -1196 (-91.02% of base) : System.Data.Common.dasm - System.Data.EnumerableRowCollection`1[short]:GetLinqDataView():System.Data.LinqDataView:this
       -1196 (-91.02% of base) : System.Data.Common.dasm - System.Data.EnumerableRowCollection`1[System.Nullable`1[int]]:GetLinqDataView():System.Data.LinqDataView:this
       -1196 (-91.02% of base) : System.Data.Common.dasm - System.Data.EnumerableRowCollection`1[System.Numerics.Vector`1[float]]:GetLinqDataView():System.Data.LinqDataView:this
       -1196 (-91.02% of base) : System.Data.Common.dasm - System.Data.EnumerableRowCollection`1[ubyte]:GetLinqDataView():System.Data.LinqDataView:this
        -887 (-68.28% of base) : System.Private.CoreLib.dasm - System.MemoryExtensions:SequenceEqual[System.__Canon](System.ReadOnlySpan`1[System.__Canon],System.ReadOnlySpan`1[System.__Canon],System.Collections.Generic.IEqualityComparer`1[System.__Canon]):bool
        -702 (-36.11% of base) : System.Private.CoreLib.dasm - System.Collections.Generic.Dictionary`2[System.__Canon,System.Nullable`1[int]]:TryInsert(System.__Canon,System.Nullable`1[int],ubyte):bool:this
        -697 (-36.06% of base) : System.Private.CoreLib.dasm - System.Collections.Generic.Dictionary`2[System.__Canon,System.__Canon]:TryInsert(System.__Canon,System.__Canon,ubyte):bool:this
        -697 (-35.84% of base) : System.Private.CoreLib.dasm - System.Collections.Generic.Dictionary`2[System.__Canon,System.Resources.ResourceLocator]:TryInsert(System.__Canon,System.Resources.ResourceLocator,ubyte):bool:this
        -692 (-36.08% of base) : System.Private.CoreLib.dasm - System.Collections.Generic.Dictionary`2[System.__Canon,long]:TryInsert(System.__Canon,long,ubyte):bool:this
        -681 (-19.29% of base) : System.Collections.Immutable.dasm - System.Collections.Frozen.FrozenDictionary:ChooseImplementationOptimizedForReading[System.__Canon,System.Nullable`1[int]](System.Collections.Generic.Dictionary`2[System.__Canon,System.Nullable`1[int]]):System.Collections.Frozen.FrozenDictionary`2[System.__Canon,System.Nullable`1[int]]
        -655 (-19.58% of base) : System.Collections.Immutable.dasm - System.Collections.Frozen.FrozenSet:ChooseImplementationOptimizedForReading[System.__Canon](System.Collections.Generic.HashSet`1[System.__Canon]):System.Collections.Frozen.FrozenSet`1[System.__Canon]

Top method regressions (percentages):
           5 ( 6.58% of base) : System.Private.CoreLib.dasm - System.Buffers.Binary.BinaryPrimitives:TryWriteInt16BigEndian(System.Span`1[ubyte],short):bool
           5 ( 6.58% of base) : System.Private.CoreLib.dasm - System.Buffers.Binary.BinaryPrimitives:WriteInt16BigEndian(System.Span`1[ubyte],short)
           5 ( 6.02% of base) : System.Private.CoreLib.dasm - System.Buffers.Binary.BinaryPrimitives:TryWriteHalfBigEndian(System.Span`1[ubyte],System.Half):bool
           5 ( 6.02% of base) : System.Private.CoreLib.dasm - System.Buffers.Binary.BinaryPrimitives:WriteHalfBigEndian(System.Span`1[ubyte],System.Half)
           4 ( 5.33% of base) : System.Private.CoreLib.dasm - System.Buffers.Binary.BinaryPrimitives:TryWriteUInt16BigEndian(System.Span`1[ubyte],ushort):bool
           4 ( 5.33% of base) : System.Private.CoreLib.dasm - System.Buffers.Binary.BinaryPrimitives:WriteUInt16BigEndian(System.Span`1[ubyte],ushort)
           3 ( 4.35% of base) : System.Private.CoreLib.dasm - System.Buffers.Binary.BinaryPrimitives:ReadHalfBigEndian(System.ReadOnlySpan`1[ubyte]):System.Half
           4 ( 3.88% of base) : System.Reflection.Metadata.dasm - System.Reflection.BlobUtilities:WriteUInt16BE(ubyte[],int,ushort)
           5 ( 3.47% of base) : System.Private.CoreLib.dasm - System.Int16:System.Numerics.IBinaryInteger<System.Int16>.TryWriteBigEndian(System.Span`1[ubyte],byref):bool:this
           5 ( 3.29% of base) : System.Private.CoreLib.dasm - System.Double:System.Numerics.IFloatingPoint<System.Double>.TryWriteExponentBigEndian(System.Span`1[ubyte],byref):bool:this
           3 ( 3.19% of base) : System.Private.CoreLib.dasm - System.Buffers.Binary.BinaryPrimitives:TryReadHalfBigEndian(System.ReadOnlySpan`1[ubyte],byref):bool
           5 ( 3.16% of base) : System.Private.CoreLib.dasm - System.Runtime.InteropServices.NFloat:System.Numerics.IFloatingPoint<System.Runtime.InteropServices.NFloat>.TryWriteExponentBigEndian(System.Span`1[ubyte],byref):bool:this
           2 ( 3.03% of base) : System.Private.CoreLib.dasm - System.Text.Unicode.Utf8Utility:ExtractUtf8TwoByteSequenceFromFirstUtf16Char(uint):uint
           4 ( 2.80% of base) : System.Private.CoreLib.dasm - System.UInt16:System.Numerics.IBinaryInteger<System.UInt16>.TryWriteBigEndian(System.Span`1[ubyte],byref):bool:this
           4 ( 2.63% of base) : System.Private.CoreLib.dasm - System.Half:System.Numerics.IFloatingPoint<System.Half>.TryWriteSignificandBigEndian(System.Span`1[ubyte],byref):bool:this
           1 ( 1.64% of base) : System.Private.CoreLib.dasm - System.Buffers.Binary.BinaryPrimitives:ReadUInt16BigEndian(System.ReadOnlySpan`1[ubyte]):ushort
           6 ( 1.49% of base) : System.Collections.Concurrent.dasm - System.Collections.Concurrent.ConcurrentDictionary`2[System.__Canon,System.Nullable`1[int]]:get_Comparer():System.Collections.Generic.IEqualityComparer`1[System.__Canon]:this
           1 ( 1.18% of base) : System.Private.CoreLib.dasm - System.Buffers.Binary.BinaryPrimitives:TryReadUInt16BigEndian(System.ReadOnlySpan`1[ubyte],byref):bool
           4 ( 1.13% of base) : System.Private.CoreLib.dasm - System.UInt16:System.Numerics.IBinaryInteger<System.UInt16>.TryReadBigEndian(System.ReadOnlySpan`1[ubyte],bool,byref):bool
           1 ( 0.56% of base) : System.Private.CoreLib.dasm - System.Threading.Tasks.Task:AtomicStateUpdate(int,int,byref):bool:this

Top method improvements (percentages):
       -1396 (-91.72% of base) : System.Private.CoreLib.dasm - System.Enum:TryParse[double](System.ReadOnlySpan`1[ushort],bool,bool,byref):bool
       -1396 (-91.72% of base) : System.Private.CoreLib.dasm - System.Enum:TryParse[int](System.ReadOnlySpan`1[ushort],bool,bool,byref):bool
       -1396 (-91.72% of base) : System.Private.CoreLib.dasm - System.Enum:TryParse[long](System.ReadOnlySpan`1[ushort],bool,bool,byref):bool
       -1396 (-91.72% of base) : System.Private.CoreLib.dasm - System.Enum:TryParse[short](System.ReadOnlySpan`1[ushort],bool,bool,byref):bool
       -1396 (-91.72% of base) : System.Private.CoreLib.dasm - System.Enum:TryParse[System.Numerics.Vector`1[float]](System.ReadOnlySpan`1[ushort],bool,bool,byref):bool
       -1396 (-91.72% of base) : System.Private.CoreLib.dasm - System.Enum:TryParse[ubyte](System.ReadOnlySpan`1[ushort],bool,bool,byref):bool
       -1196 (-91.02% of base) : System.Data.Common.dasm - System.Data.EnumerableRowCollection`1[double]:GetLinqDataView():System.Data.LinqDataView:this
       -1196 (-91.02% of base) : System.Data.Common.dasm - System.Data.EnumerableRowCollection`1[int]:GetLinqDataView():System.Data.LinqDataView:this
       -1196 (-91.02% of base) : System.Data.Common.dasm - System.Data.EnumerableRowCollection`1[long]:GetLinqDataView():System.Data.LinqDataView:this
       -1196 (-91.02% of base) : System.Data.Common.dasm - System.Data.EnumerableRowCollection`1[short]:GetLinqDataView():System.Data.LinqDataView:this
       -1196 (-91.02% of base) : System.Data.Common.dasm - System.Data.EnumerableRowCollection`1[System.Nullable`1[int]]:GetLinqDataView():System.Data.LinqDataView:this
       -1196 (-91.02% of base) : System.Data.Common.dasm - System.Data.EnumerableRowCollection`1[System.Numerics.Vector`1[float]]:GetLinqDataView():System.Data.LinqDataView:this
       -1196 (-91.02% of base) : System.Data.Common.dasm - System.Data.EnumerableRowCollection`1[ubyte]:GetLinqDataView():System.Data.LinqDataView:this
        -361 (-90.25% of base) : System.ComponentModel.TypeConverter.dasm - System.ComponentModel.BindingList`1[System.Numerics.Vector`1[float]]:Initialize():this
        -285 (-87.96% of base) : System.ComponentModel.TypeConverter.dasm - System.ComponentModel.BindingList`1[double]:Initialize():this
        -277 (-87.66% of base) : System.ComponentModel.TypeConverter.dasm - System.ComponentModel.BindingList`1[long]:Initialize():this
        -277 (-87.66% of base) : System.ComponentModel.TypeConverter.dasm - System.ComponentModel.BindingList`1[System.Nullable`1[int]]:Initialize():this
        -275 (-87.58% of base) : System.ComponentModel.TypeConverter.dasm - System.ComponentModel.BindingList`1[int]:Initialize():this
        -275 (-87.58% of base) : System.ComponentModel.TypeConverter.dasm - System.ComponentModel.BindingList`1[short]:Initialize():this
        -275 (-87.58% of base) : System.ComponentModel.TypeConverter.dasm - System.ComponentModel.BindingList`1[ubyte]:Initialize():this

1268 total methods with Code Size differences (1247 improved, 21 regressed), 375945 unchanged.

--------------------------------------------------------------------------------

Example of a size "regression": https://www.diffchecker.com/qaKdHKwT/

Author: EgorBo
Assignees: EgorBo
Labels:

area-CodeGen-coreclr

Milestone: -

@EgorBo
Copy link
Member Author

EgorBo commented Mar 5, 2023

cc @MichalStrehovsky do you want me to mark Unsafe intrinsics as "always expand no matter what" as part of this PR for NativeAOT?

@EgorBo
Copy link
Member Author

EgorBo commented Mar 5, 2023

@dotnet/jit-contrib PTAL, spmi diffs - only 3 collections have Tier0 contexts

@MichalStrehovsky
Copy link
Member

cc @MichalStrehovsky do you want me to mark Unsafe intrinsics as "always expand no matter what" as part of this PR for NativeAOT?

We would only really take advantage of it if we merged #82589 as well. The improvement from that is marginal and not worth duplicating some of the logic from RyuJIT to the C# side.

We'll eventually get that "for free" if/when we start using RyuJIT as a IL scanner to build the whole program view. The scanner is currently written in C# and cannot assume RyuJIT's optimizations.

@BruceForstall
Copy link
Member

/azp run runtime-coreclr outerloop

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Member

@BruceForstall BruceForstall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM if outerloop passes. Note that Pri0/innerloop doesn't run any (coreclr) tests with tiering enabled.

@EgorBo
Copy link
Member Author

EgorBo commented Mar 6, 2023

/azp run runtime-coreclr pgo, runtime-coreclr libraries-pgo

@azure-pipelines
Copy link

Azure Pipelines successfully started running 2 pipeline(s).

@EgorBo
Copy link
Member Author

EgorBo commented Mar 6, 2023

there is a single assert in PGO outerloop pipeline but it's not related (it's Tier1) - will file an issue for it as part of Test Monitor duty

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants