Closed performanceautofiler[bot] closed 2 years ago
Type equality is related to https://github.com/dotnet/runtime/pull/59499
area of improvement: Align methods that are recursion - Ackermann benchmark? Double check if we set fgHasLoops
flag when we convert a recursive method to loops
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.
I guess the native implementation could potentially benefit from Native PGO? since it's a question of nanoseconds (or maybe it's Managed PGO that made C# impl worse). As a quick fix we can mark operator== as AggressiveInlining if it worth it
cc @jkotas
operator == should exit at if (left is RuntimeType || right is RuntimeType)
check
The regression is caused by several factors:
mov rax,rcx
mov r8,qword ptr [rax]
mov rax,7FF9CBD49280h
cmp r8,rax
This can be just:
mov r8,7FF9CBD49280h
cmp [rcx],r8
@EgorBo How hard would be to fix this in the JIT?
As a quick fix we can mark operator== as AggressiveInlining
I think it would break late recognition of the operator==
intrinsic. (Also, the AggressiveInlining does not feel like the right tradeoff here.)
Tagging subscribers to this area: @JulieLeeMSFT See info in area-owners.md if you want to be subscribed.
Author: | performanceautofiler[bot] |
---|---|
Assignees: | - |
Labels: | `os-windows`, `tenet-performance`, `tenet-performance-benchmarks`, `arch-x64`, `area-CodeGen-coreclr`, `untriaged` |
Milestone: | - |
The remaining actionable problem here is the unnecessary register shuffling from is RuntimeType
check (see above).
@EgorBo How hard would be to fix this in the JIT?
@jkotas from a quick look I guess it's because of the way we inline cast/isinst - isinst
in this case is only used for a bool expression but we save its result into a temp always.
STMT00006 (IL 0x003... ???)
N009 ( 18, 22) [000040] -A---O------ * JTRUE void
N008 ( 16, 20) [000010] JA---O?N---- \--* EQ int $c2
N006 ( 13, 9) [000052] -A---O------ +--* COMMA long $102
N004 ( 10, 7) [000050] -A---O--R--- | +--* ASG long $VN.Void
N003 ( 3, 2) [000049] D------N---- | | +--* LCL_VAR long V03 cse0 d:1 $102
N002 ( 6, 4) [000009] #----O?----- | | \--* IND long $102
N001 ( 3, 2) [000008] ------?----- | | \--* LCL_VAR ref V02 tmp1 u:1 $80
N005 ( 3, 2) [000051] ------------ | \--* LCL_VAR long V03 cse0 u:1 $102
N007 ( 2, 10) [000007] H-----?----- \--* CNS_INT(h) long 0x7ffdc8eaf480 class $140
so in theory in this specific case there should not be any COMMA/ASG, just JTRUE(EQ(IND...
there was an issue for it already somewhere.
Simple repro:
using System;
using System.Runtime.CompilerServices;
class Program
{
static void Main()
{
Test("hello");
}
[MethodImpl(MethodImplOptions.NoInlining |
MethodImplOptions.AggressiveOptimization)]
public static int Test(object left)
{
if (left is null || left is string)
return 0;
return left.GetHashCode();
}
}
Setting this to .NET 7. Please update it if you think it needs to be addressed in .NET 6. Assigning to @EgorBo since inlining related work remains.
Closing as the regression is no more:
Run Information
Regressions in System.Tests.Perf_Type
Test Report
Repro
Run Information