-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Performance regression: Utf8String.IsAscii (x86 only) #41388
Comments
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. |
@GrabYourPitchforks can you have a look? (sorry for removing Untriaged, usually when I see a milestone assigned I think it's been triaged). |
This is a non-shipping component, but it's still useful to figure out where the perf loss came from. |
Transcoding workhorse routine on 3.1.x x86: 079e8c60 55 push ebp
079e8c61 8bec mov ebp,esp
079e8c63 57 push edi
079e8c64 56 push esi
079e8c65 53 push ebx
079e8c66 c5f877 vzeroupper
079e8c69 b880ffffff mov eax,0FFFFFF80h
079e8c6e c5f96ec0 vmovd xmm0,eax
079e8c72 c4e27979c0 vpbroadcastw xmm0,xmm0
079e8c77 c5fa6f09 vmovdqu xmm1,xmmword ptr [ecx]
079e8c7b c4e27917c8 vptest xmm1,xmm0
079e8c80 0f94c0 sete al
079e8c83 0fb6c0 movzx eax,al
079e8c86 85c0 test eax,eax
079e8c88 7509 jne System_Private_CoreLib!System.Text.ASCIIUtility.NarrowUtf16ToAscii_Sse2(Char*, Byte*, UInt32)+0xffffffff`8eb9d8ab (079e8c93)
079e8c8a 33c0 xor eax,eax
079e8c8c 5b pop ebx
079e8c8d 5e pop esi
079e8c8e 5f pop edi
079e8c8f 5d pop ebp
079e8c90 c20400 ret 4
079e8c93 c5f167d1 vpackuswb xmm2,xmm1,xmm1
079e8c97 c5f9d612 vmovq mmword ptr [edx],xmm2
079e8c9b b808000000 mov eax,8
079e8ca0 f6c208 test dl,8
079e8ca3 751d jne System_Private_CoreLib!System.Text.ASCIIUtility.NarrowUtf16ToAscii_Sse2(Char*, Byte*, UInt32)+0xffffffff`8eb9d8da (079e8cc2)
079e8ca5 c5fa6f4910 vmovdqu xmm1,xmmword ptr [ecx+10h]
079e8caa c4e27917c8 vptest xmm1,xmm0
079e8caf 0f94c3 sete bl
079e8cb2 0fb6db movzx ebx,bl
079e8cb5 85db test ebx,ebx
079e8cb7 7453 je System_Private_CoreLib!System.Text.ASCIIUtility.NarrowUtf16ToAscii_Sse2(Char*, Byte*, UInt32)+0xffffffff`8eb9d924 (079e8d0c)
079e8cb9 c5f167d1 vpackuswb xmm2,xmm1,xmm1
079e8cbd c5f9d65208 vmovq mmword ptr [edx+8],xmm2
079e8cc2 8bc2 mov eax,edx
079e8cc4 83e00f and eax,0Fh
079e8cc7 be10000000 mov esi,10h
079e8ccc 2bf0 sub esi,eax
079e8cce 8bc6 mov eax,esi
079e8cd0 8b7508 mov esi,dword ptr [ebp+8]
079e8cd3 83ee10 sub esi,10h
079e8cd6 33ff xor edi,edi
079e8cd8 8bf8 mov edi,eax
079e8cda c5fa6f0c79 vmovdqu xmm1,xmmword ptr [ecx+edi*2]
079e8cdf 33ff xor edi,edi
079e8ce1 8bf8 mov edi,eax
079e8ce3 c5fa6f547910 vmovdqu xmm2,xmmword ptr [ecx+edi*2+10h]
079e8ce9 c5f1ebda vpor xmm3,xmm1,xmm2
079e8ced c4e27917d8 vptest xmm3,xmm0
079e8cf2 0f94c3 sete bl
079e8cf5 0fb6db movzx ebx,bl
079e8cf8 85db test ebx,ebx
079e8cfa 7417 je System_Private_CoreLib!System.Text.ASCIIUtility.NarrowUtf16ToAscii_Sse2(Char*, Byte*, UInt32)+0xffffffff`8eb9d92b (079e8d13)
079e8cfc c5f167d2 vpackuswb xmm2,xmm1,xmm2
079e8d00 c5f97f1402 vmovdqa xmmword ptr [edx+eax],xmm2
079e8d05 83c010 add eax,10h
079e8d08 3bc6 cmp eax,esi
079e8d0a 76ca jbe System_Private_CoreLib!System.Text.ASCIIUtility.NarrowUtf16ToAscii_Sse2(Char*, Byte*, UInt32)+0xffffffff`8eb9d8ee (079e8cd6)
079e8d0c 5b pop ebx
079e8d0d 5e pop esi
079e8d0e 5f pop edi
079e8d0f 5d pop ebp
079e8d10 c20400 ret 4
079e8d13 c4e27917c8 vptest xmm1,xmm0
079e8d18 0f94c1 sete cl
079e8d1b 0fb6c9 movzx ecx,cl
079e8d1e 85c9 test ecx,ecx
079e8d20 74ea je System_Private_CoreLib!System.Text.ASCIIUtility.NarrowUtf16ToAscii_Sse2(Char*, Byte*, UInt32)+0xffffffff`8eb9d924 (079e8d0c)
079e8d22 c5f167d1 vpackuswb xmm2,xmm1,xmm1
079e8d26 c5f9d61402 vmovq mmword ptr [edx+eax],xmm2
079e8d2b 83c008 add eax,8
079e8d2e ebdc jmp System_Private_CoreLib!System.Text.ASCIIUtility.NarrowUtf16ToAscii_Sse2(Char*, Byte*, UInt32)+0xffffffff`8eb9d924 (079e8d0c)
System_Utf8String_Experimental!System.Text.ASCIIUtility.GetIndexOfFirstNonAsciiByte_Default(Byte*, UIntPtr):
079586c0 55 push ebp
079586c1 8bec mov ebp,esp
079586c3 57 push edi
079586c4 56 push esi
079586c5 53 push ebx
079586c6 c5f877 vzeroupper
079586c9 8bc1 mov eax,ecx
079586cb 83fa40 cmp edx,40h
079586ce 0f8292000000 jb System_Utf8String_Experimental!System.Text.ASCIIUtility.GetIndexOfFirstNonAsciiByte_Default(Byte*, UIntPtr)+0xa6 (07958766)
079586d4 c5fd1000 vmovupd ymm0,ymmword ptr [eax]
079586d8 c5f457c9 vxorps ymm1,ymm1,ymm1
079586dc c5fc28d0 vmovaps ymm2,ymm0
079586e0 c5ed74d1 vpcmpeqb ymm2,ymm2,ymm1
079586e4 c5fd64c1 vpcmpgtb ymm0,ymm0,ymm1
079586e8 c5edebc0 vpor ymm0,ymm2,ymm0
079586ec c5f576c9 vpcmpeqd ymm1,ymm1,ymm1
079586f0 c5fc28d0 vmovaps ymm2,ymm0
079586f4 c5ed76d1 vpcmpeqd ymm2,ymm2,ymm1
079586f8 c5fdd7f2 vpmovmskb esi,ymm2
079586fc 83feff cmp esi,0FFFFFFFFh
079586ff 0f94c3 sete bl
07958702 0fb6db movzx ebx,bl
07958705 0fb6db movzx ebx,bl
07958708 85db test ebx,ebx
0795870a 745a je System_Utf8String_Experimental!System.Text.ASCIIUtility.GetIndexOfFirstNonAsciiByte_Default(Byte*, UIntPtr)+0xa6 (07958766)
0795870c 33c9 xor ecx,ecx
0795870e 8bca mov ecx,edx
07958710 03c8 add ecx,eax
07958712 83e920 sub ecx,20h
07958715 8d7020 lea esi,[eax+20h]
07958718 83e6e0 and esi,0FFFFFFE0h
0795871b c5fd1006 vmovupd ymm0,ymmword ptr [esi]
0795871f c5f457c9 vxorps ymm1,ymm1,ymm1
07958723 c5f564c8 vpcmpgtb ymm1,ymm1,ymm0
07958727 c4e27d17c9 vptest ymm1,ymm1
0795872c 7507 jne System_Utf8String_Experimental!System.Text.ASCIIUtility.GetIndexOfFirstNonAsciiByte_Default(Byte*, UIntPtr)+0x75 (07958735)
0795872e 83c620 add esi,20h
07958731 3bf1 cmp esi,ecx
07958733 76e6 jbe System_Utf8String_Experimental!System.Text.ASCIIUtility.GetIndexOfFirstNonAsciiByte_Default(Byte*, UIntPtr)+0x5b (0795871b)
07958735 2bd6 sub edx,esi
07958737 03d0 add edx,eax
07958739 83fa08 cmp edx,8
0795873c 8bce mov ecx,esi
0795873e 722b jb System_Utf8String_Experimental!System.Text.ASCIIUtility.GetIndexOfFirstNonAsciiByte_Default(Byte*, UIntPtr)+0xab (0795876b)
07958740 8b31 mov esi,dword ptr [ecx]
07958742 8b7904 mov edi,dword ptr [ecx+4]
07958745 8bde mov ebx,esi
07958747 0bdf or ebx,edi
07958749 f7c380808080 test ebx,80808080h
0795874f 740f je System_Utf8String_Experimental!System.Text.ASCIIUtility.GetIndexOfFirstNonAsciiByte_Default(Byte*, UIntPtr)+0xa0 (07958760)
07958751 f7c680808080 test esi,80808080h
07958757 7550 jne System_Utf8String_Experimental!System.Text.ASCIIUtility.GetIndexOfFirstNonAsciiByte_Default(Byte*, UIntPtr)+0xe9 (079587a9)
07958759 8bf7 mov esi,edi
0795875b 83c104 add ecx,4
0795875e eb49 jmp System_Utf8String_Experimental!System.Text.ASCIIUtility.GetIndexOfFirstNonAsciiByte_Default(Byte*, UIntPtr)+0xe9 (079587a9)
07958760 83c108 add ecx,8
07958763 83c2f8 add edx,0FFFFFFF8h
07958766 83fa08 cmp edx,8
07958769 73d5 jae System_Utf8String_Experimental!System.Text.ASCIIUtility.GetIndexOfFirstNonAsciiByte_Default(Byte*, UIntPtr)+0x80 (07958740)
0795876b f6c204 test dl,4
0795876e 740d je System_Utf8String_Experimental!System.Text.ASCIIUtility.GetIndexOfFirstNonAsciiByte_Default(Byte*, UIntPtr)+0xbd (0795877d)
07958770 8b31 mov esi,dword ptr [ecx]
07958772 f7c680808080 test esi,80808080h
07958778 752f jne System_Utf8String_Experimental!System.Text.ASCIIUtility.GetIndexOfFirstNonAsciiByte_Default(Byte*, UIntPtr)+0xe9 (079587a9)
0795877a 83c104 add ecx,4
0795877d f6c202 test dl,2
07958780 740e je System_Utf8String_Experimental!System.Text.ASCIIUtility.GetIndexOfFirstNonAsciiByte_Default(Byte*, UIntPtr)+0xd0 (07958790)
07958782 0fb731 movzx esi,word ptr [ecx]
07958785 f7c680808080 test esi,80808080h
0795878b 751c jne System_Utf8String_Experimental!System.Text.ASCIIUtility.GetIndexOfFirstNonAsciiByte_Default(Byte*, UIntPtr)+0xe9 (079587a9)
0795878d 83c102 add ecx,2
07958790 f6c201 test dl,1
07958793 7406 je System_Utf8String_Experimental!System.Text.ASCIIUtility.GetIndexOfFirstNonAsciiByte_Default(Byte*, UIntPtr)+0xdb (0795879b)
07958795 803900 cmp byte ptr [ecx],0
07958798 7c01 jl System_Utf8String_Experimental!System.Text.ASCIIUtility.GetIndexOfFirstNonAsciiByte_Default(Byte*, UIntPtr)+0xdb (0795879b)
0795879a 41 inc ecx
0795879b 8bd1 mov edx,ecx
0795879d 2bd0 sub edx,eax
0795879f 8bc2 mov eax,edx
079587a1 c5f877 vzeroupper
079587a4 5b pop ebx
079587a5 5e pop esi
079587a6 5f pop edi
079587a7 5d pop ebp
079587a8 c3 ret
079587a9 81e680808080 and esi,80808080h
079587af 33d2 xor edx,edx
079587b1 f30fbcd6 tzcnt edx,esi
079587b5 c1ea03 shr edx,3
079587b8 03ca add ecx,edx
079587ba ebdf jmp System_Utf8String_Experimental!System.Text.ASCIIUtility.GetIndexOfFirstNonAsciiByte_Default(Byte*, UIntPtr)+0xdb (0795879b)
System_Utf8String_Experimental!System.Text.ASCIIUtility.GetIndexOfFirstNonAsciiByte_Default(Byte*, UIntPtr):
02cae548 55 push ebp
02cae549 8bec mov ebp,esp
02cae54b 57 push edi
02cae54c 56 push esi
02cae54d 53 push ebx
02cae54e c5f877 vzeroupper
02cae551 8bc1 mov eax,ecx
02cae553 83fa40 cmp edx,40h
02cae556 0f827f000000 jb System_Utf8String_Experimental!System.Text.ASCIIUtility.GetIndexOfFirstNonAsciiByte_Default(Byte*, UIntPtr)+0x93 (02cae5db)
02cae55c c5fd1000 vmovupd ymm0,ymmword ptr [eax]
02cae560 c5f457c9 vxorps ymm1,ymm1,ymm1
02cae564 c5fd74d1 vpcmpeqb ymm2,ymm0,ymm1
02cae568 c5fd64c1 vpcmpgtb ymm0,ymm0,ymm1
02cae56c c5edebc0 vpor ymm0,ymm2,ymm0
02cae570 c5f576c9 vpcmpeqd ymm1,ymm1,ymm1
02cae574 c5fd76c1 vpcmpeqd ymm0,ymm0,ymm1
02cae578 c5fdd7f0 vpmovmskb esi,ymm0
02cae57c 83feff cmp esi,0FFFFFFFFh
02cae57f 755a jne System_Utf8String_Experimental!System.Text.ASCIIUtility.GetIndexOfFirstNonAsciiByte_Default(Byte*, UIntPtr)+0x93 (02cae5db)
02cae581 33c9 xor ecx,ecx
02cae583 8bca mov ecx,edx
02cae585 03c8 add ecx,eax
02cae587 83e920 sub ecx,20h
02cae58a 8d7020 lea esi,[eax+20h]
02cae58d 83e6e0 and esi,0FFFFFFE0h
02cae590 c5fd1006 vmovupd ymm0,ymmword ptr [esi]
02cae594 c5f457c9 vxorps ymm1,ymm1,ymm1
02cae598 c5f564c0 vpcmpgtb ymm0,ymm1,ymm0
02cae59c c4e27d17c0 vptest ymm0,ymm0
02cae5a1 7507 jne System_Utf8String_Experimental!System.Text.ASCIIUtility.GetIndexOfFirstNonAsciiByte_Default(Byte*, UIntPtr)+0x62 (02cae5aa)
02cae5a3 83c620 add esi,20h
02cae5a6 3bf1 cmp esi,ecx
02cae5a8 76e6 jbe System_Utf8String_Experimental!System.Text.ASCIIUtility.GetIndexOfFirstNonAsciiByte_Default(Byte*, UIntPtr)+0x48 (02cae590)
02cae5aa 2bd6 sub edx,esi
02cae5ac 03d0 add edx,eax
02cae5ae 83fa08 cmp edx,8
02cae5b1 8bce mov ecx,esi
02cae5b3 722b jb System_Utf8String_Experimental!System.Text.ASCIIUtility.GetIndexOfFirstNonAsciiByte_Default(Byte*, UIntPtr)+0x98 (02cae5e0)
02cae5b5 8b31 mov esi,dword ptr [ecx]
02cae5b7 8b7904 mov edi,dword ptr [ecx+4]
02cae5ba 8bde mov ebx,esi
02cae5bc 0bdf or ebx,edi
02cae5be f7c380808080 test ebx,80808080h
02cae5c4 740f je System_Utf8String_Experimental!System.Text.ASCIIUtility.GetIndexOfFirstNonAsciiByte_Default(Byte*, UIntPtr)+0x8d (02cae5d5)
02cae5c6 f7c680808080 test esi,80808080h
02cae5cc 7550 jne System_Utf8String_Experimental!System.Text.ASCIIUtility.GetIndexOfFirstNonAsciiByte_Default(Byte*, UIntPtr)+0xd6 (02cae61e)
02cae5ce 8bf7 mov esi,edi
02cae5d0 83c104 add ecx,4
02cae5d3 eb49 jmp System_Utf8String_Experimental!System.Text.ASCIIUtility.GetIndexOfFirstNonAsciiByte_Default(Byte*, UIntPtr)+0xd6 (02cae61e)
02cae5d5 83c108 add ecx,8
02cae5d8 83c2f8 add edx,0FFFFFFF8h
02cae5db 83fa08 cmp edx,8
02cae5de 73d5 jae System_Utf8String_Experimental!System.Text.ASCIIUtility.GetIndexOfFirstNonAsciiByte_Default(Byte*, UIntPtr)+0x6d (02cae5b5)
02cae5e0 f6c204 test dl,4
02cae5e3 740d je System_Utf8String_Experimental!System.Text.ASCIIUtility.GetIndexOfFirstNonAsciiByte_Default(Byte*, UIntPtr)+0xaa (02cae5f2)
02cae5e5 8b31 mov esi,dword ptr [ecx]
02cae5e7 f7c680808080 test esi,80808080h
02cae5ed 752f jne System_Utf8String_Experimental!System.Text.ASCIIUtility.GetIndexOfFirstNonAsciiByte_Default(Byte*, UIntPtr)+0xd6 (02cae61e)
02cae5ef 83c104 add ecx,4
02cae5f2 f6c202 test dl,2
02cae5f5 740e je System_Utf8String_Experimental!System.Text.ASCIIUtility.GetIndexOfFirstNonAsciiByte_Default(Byte*, UIntPtr)+0xbd (02cae605)
02cae5f7 0fb731 movzx esi,word ptr [ecx]
02cae5fa f7c680808080 test esi,80808080h
02cae600 751c jne System_Utf8String_Experimental!System.Text.ASCIIUtility.GetIndexOfFirstNonAsciiByte_Default(Byte*, UIntPtr)+0xd6 (02cae61e)
02cae602 83c102 add ecx,2
02cae605 f6c201 test dl,1
02cae608 7406 je System_Utf8String_Experimental!System.Text.ASCIIUtility.GetIndexOfFirstNonAsciiByte_Default(Byte*, UIntPtr)+0xc8 (02cae610)
02cae60a 803900 cmp byte ptr [ecx],0
02cae60d 7c01 jl System_Utf8String_Experimental!System.Text.ASCIIUtility.GetIndexOfFirstNonAsciiByte_Default(Byte*, UIntPtr)+0xc8 (02cae610)
02cae60f 41 inc ecx
02cae610 8bd1 mov edx,ecx
02cae612 2bd0 sub edx,eax
02cae614 8bc2 mov eax,edx
02cae616 c5f877 vzeroupper
02cae619 5b pop ebx
02cae61a 5e pop esi
02cae61b 5f pop edi
02cae61c 5d pop ebp
02cae61d c3 ret
02cae61e 81e680808080 and esi,80808080h
02cae624 33d2 xor edx,edx
02cae626 f30fbcd6 tzcnt edx,esi
02cae62a c1ea03 shr edx,3
02cae62d 03ca add ecx,edx
02cae62f ebdf jmp System_Utf8String_Experimental!System.Text.ASCIIUtility.GetIndexOfFirstNonAsciiByte_Default(Byte*, UIntPtr)+0xc8 (02cae610) |
Changing milestone to 6.0.0 given Utf8String is still experimental and so as to not confuse with remaining 5.0 work. |
@adamsitnik Since Utf8String isn't in the runtime repo any more, ok if I close this issue? |
It's OK. @krwq if|when we reintroduce |
Repro
@eiriktsarpalis @GrabYourPitchforks @carlossanlop @pgovind I am setting 5.0 milestone to make sure that it gets triaged within the next few weeks.
There was a similar issue, but I've verified that #41198 is not fixing this problem.
@GrabYourPitchforks @eerhardt The benchmark throws for all other documents for 3.1.6 which might be a bug in .NET Standard implementation of Utf8String:
System.Text.Perf_Utf8String.IsAscii(Input: EnglishAllAscii)
Docs
Profiling workflow for dotnet/runtime repository
Benchmarking workflow for dotnet/runtime repository
@DrewScoggins this regression did not get detected by the bot because benchmark was added just a few days ago, so everything is 👍
The text was updated successfully, but these errors were encountered: