-
Notifications
You must be signed in to change notification settings - Fork 5k
Replace OptimizedInboxTextEncoder vectorization with SearchValues #114494
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
Conversation
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.
Copilot reviewed 5 out of 7 changed files in this pull request and generated 1 comment.
Files not reviewed (2)
- src/libraries/System.Text.Encodings.Web/src/System.Text.Encodings.Web.csproj: Language not supported
- src/libraries/System.Text.Encodings.Web/tests/System.Text.Encodings.Web.Tests.csproj: Language not supported
Comments suppressed due to low confidence (2)
src/libraries/System.Text.Encodings.Web/tests/AllowedAsciiCodePointsTests.cs:1
- Removal of AllowedAsciiCodePointsTests.cs may reduce test coverage for the fast path. Consider adding new tests to validate the SearchValues-based approach.
// Entire test file removed
src/libraries/System.Text.Encodings.Web/src/System/Text/Encodings/Web/OptimizedInboxTextEncoder.cs:406
- Double-check that the combination of IndexOfAnyExcept with the char.IsAscii check correctly identifies the first disallowed character in all edge cases, especially when the span consists entirely of allowed characters.
if ((uint)asciiCharsSkipped >= (uint)data.Length || char.IsAscii(data[asciiCharsSkipped]))
...braries/System.Text.Encodings.Web/src/System/Text/Encodings/Web/OptimizedInboxTextEncoder.cs
Show resolved
Hide resolved
Tagging subscribers to this area: @dotnet/area-system-text-encodings-web |
@MihuBot benchmark System.Text.Json |
@MihuBot benchmark System.Text.Json -arm |
Just wondering, does the optimization using SearchValues will still work fine on previous .NET versions like .NET 8? |
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.
LGTM as long as the benchmark numbers at least not showing any regressions. Thanks!
I'd expect it to be very similar in this case since we're limiting usage to ASCII-only sets. I'll see what the numbers show for short inputs. |
Numbers for X64 System.Text.Json.Tests.Perf_Strings
ARM64 System.Text.Json.Tests.Perf_Strings
|
@EgorBot -mono --envvars MONO_ENV_OPTIONS:--interp --filter "Perf_Strings" |
Some impressive improvements here for Wasm both interpreter and aot. Nice work! |
Closes #114437
I only replaced the existing ASCII-only fast path.
If we wanted to later, we could add a SearchValues implementation that handles the large character sets that STEW uses, in which case the .NET core implementation would just directly forward to SearchValues.