-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Intrinsicify JsonReaderHelper.IndexOfOrLessThan #40877
Conversation
efb91b9
to
6cfe3c7
Compare
src/libraries/System.Text.Json/src/System/Text/Json/Reader/JsonReaderHelper.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Text.Json/src/System/Text/Json/Reader/JsonReaderHelper.cs
Outdated
Show resolved
Hide resolved
} | ||
|
||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
private static ref byte AddByteOffset(ref byte start, nuint offset) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the following methods I see this pattern quite often. Maybe it's time to make these a public api?
Yeah, they're still easy to type helpers, but repeated often enough. Furthermore there could be asserts that the reads are within bounds, etc.
Most similar issue I've found is #36182
fecb348
to
1aca492
Compare
1aca492
to
3a58170
Compare
3a58170
to
f4f85a3
Compare
|
Libraries Test Run release coreclr OSX x64 Debug failed: AcceptV4BoundToAnyV6_Success #40913 |
src/libraries/System.Text.Json/src/System/Text/Json/Reader/JsonReaderHelper.SpeedOpts.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Text.Json/src/System/Text/Json/Reader/JsonReaderHelper.SpeedOpts.cs
Outdated
Show resolved
Hide resolved
// Same as method as above | ||
matches = Avx2.MoveMask( | ||
Avx2.Or( | ||
Avx2.CompareGreaterThan( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: Avx2
doesn't have less than so arguments are switched for greater than
Avx2.Or( | ||
Avx2.CompareGreaterThan( | ||
valuesLessThan, | ||
Avx2.Subtract(search, Vector256.Create((byte)0x80)).AsSByte()).AsByte(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: Also CompareGreaterThan
is only sbyte
(and CompareLessThan
on Sse2), so subtract 0x80
before casting and doing the compare to keep the order correct
7ffc080
to
3a10197
Compare
2108029
to
19facfe
Compare
Can't workout the linker test issues :(
|
Taking a look now. |
@layomia when I add the browser type
On Windows, Linux and OSX. However doesn't seem to provide much helpful detail in the binlog as to why its becoming "unsupported" :( |
So the |
Current working idea looking at other build is need to override
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried out some changes wrt wasm/non-wasm builds, pls see if this helps - layomia@137ac47. We don't run the linker tests specifically on wasm builds afaict so I don't think any linker test changes are needed in this PR.
@@ -1,7 +1,7 @@ | |||
<Project Sdk="Microsoft.NET.Sdk"> | |||
<PropertyGroup> | |||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> | |||
<TargetFrameworks>$(NetCoreAppCurrent);netstandard2.0;netcoreapp3.0;net461</TargetFrameworks> | |||
<TargetFrameworks>$(NetCoreAppCurrent)-Windows_NT;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Browser;netstandard2.0;netcoreapp3.0;net461</TargetFrameworks> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this change needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it will only output an AnyCPU
assembly if either the TargetFrameworks
doesn't have browser or the Architectures aren't included to have wasm
which will mean '$(TargetArchitecture)' == 'wasm'
will never be true?
src/libraries/System.Text.Json/src/System/Text/Json/Reader/JsonReaderHelper.SpeedOpts.cs
Show resolved
Hide resolved
So its looks like NuGet chokes on However the linker tests look to shell out to a basic build which uses the standard restore causing them to fail for all frameworks (where this changed |
🥳 Going to close this PR and open a fresh one as its a bit of a tire fire |
Opened #41097 |
Update to use newer Sse2, Axv2 intrinsics; and add ARM as per the method it mimics (with changes) from SpanHelpers
Also add size optimization/simplification for wasm
x64 performance changes (up to +20% improvement)
/cc @kunalspathak @jeffhandley for the intrinsics