You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
dotnet/coreclr#14125 made EqualityComparer<T>.Default an intrinsic recognized by the JIT, teaching the JIT what concrete type of comparer would be used for any given T and enabling EqualityComparer<T>.Default.Equals to be fully devirtualized and inlined. This in turn led to optimizations in managed code, where code that was making heavy use of EqualityComparer<T>.Default as a default implementation added specialized code paths that used EqualityComparer<T>.Default, e.g. in various collections like Dictionary<>.
Comparer<T>.Default could benefit from similar optimizations. Comparer<T>.Default.Compare doesn't show up quite as much as EqualityComparer<T>.Default.Equals, but it still shows up in a lot of places, and there are a variety of collections (e.g. the new PriorityQueue<> being added in .NET 6) that would similarly optimize for Comparer<T>.Default if Comparer<T>.Default.Compare could be devirtualized and inlined.
dotnet/coreclr#14125 made
EqualityComparer<T>.Default
an intrinsic recognized by the JIT, teaching the JIT what concrete type of comparer would be used for any given T and enablingEqualityComparer<T>.Default.Equals
to be fully devirtualized and inlined. This in turn led to optimizations in managed code, where code that was making heavy use ofEqualityComparer<T>.Default
as a default implementation added specialized code paths that usedEqualityComparer<T>.Default
, e.g. in various collections likeDictionary<>
.Comparer<T>.Default
could benefit from similar optimizations.Comparer<T>.Default.Compare
doesn't show up quite as much asEqualityComparer<T>.Default.Equals
, but it still shows up in a lot of places, and there are a variety of collections (e.g. the newPriorityQueue<>
being added in .NET 6) that would similarly optimize forComparer<T>.Default
ifComparer<T>.Default.Compare
could be devirtualized and inlined.Is this feasible?
cc: @AndyAyersMS, @eiriktsarpalis
The text was updated successfully, but these errors were encountered: