Skip to content

Conversation

@GrabYourPitchforks
Copy link
Member

This is a follow-up PR to #49373 which adds ARM64 SIMD optimizations to the FindFirstCharacterToEncode code paths. I'm not able to run BenchmarkDotNet on my SPX device for some reason, but I created a small console application to get some quick measurements.

Baseline (release/5.0): 46 ns for HtmlEncoder.Default.FindFirstCharacterToEncodeUtf8(u8"The quick brown fox jumps over the lazy dog.")
advsimd-optimized: 8.8 ns for same input. (-81% wall clock time taken)

The .AdvSimd64.cs file is basically a carbon copy of the .Ssse3.cs file, but using AMD64 patterns (tbl and addp) instead of SSSE3 instructions (pshufb and pmovmskb).

We're relying on the increased unit test coverage given by the previous PR. I've also augmented the unit tests with an extra "insert this scurrilous BMP code point" check to validate that our UTF-16 -> ASCII conversion is working properly.

@ghost
Copy link

ghost commented Mar 19, 2021

Tagging subscribers to this area: @tarekgh, @eiriktsarpalis, @layomia
See info in area-owners.md if you want to be subscribed.

Issue Details

This is a follow-up PR to #49373 which adds ARM64 SIMD optimizations to the FindFirstCharacterToEncode code paths. I'm not able to run BenchmarkDotNet on my SPX device for some reason, but I created a small console application to get some quick measurements.

Baseline (release/5.0): 46 ns for HtmlEncoder.Default.FindFirstCharacterToEncodeUtf8(u8"The quick brown fox jumps over the lazy dog.")
advsimd-optimized: 8.8 ns for same input. (-81% wall clock time taken)

The .AdvSimd64.cs file is basically a carbon copy of the .Ssse3.cs file, but using AMD64 patterns (tbl and addp) instead of SSSE3 instructions (pshufb and pmovmskb).

We're relying on the increased unit test coverage given by the previous PR. I've also augmented the unit tests with an extra "insert this scurrilous BMP code point" check to validate that our UTF-16 -> ASCII conversion is working properly.

Author: GrabYourPitchforks
Assignees: -
Labels:

area-System.Text.Encodings.Web

Milestone: -

@GrabYourPitchforks
Copy link
Member Author

/cc @adamsitnik @DrewScoggins

Heads up that you're likely to see changes in the perf lab benchmark here and in System.Text.Json as a result of recent PRs.

Copy link
Member

@eiriktsarpalis eiriktsarpalis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@DrewScoggins
Copy link
Member

Thanks for the tag @GrabYourPitchforks. We will keep an eye out for this on Tuesday when we triage.

@GrabYourPitchforks
Copy link
Member Author

GrabYourPitchforks commented Mar 20, 2021

Green CI? Sure, I'll take it!
(If anybody has any extra comments, open a new issue or ping me offline and we can get them addressed in a future PR.)

@GrabYourPitchforks GrabYourPitchforks merged commit 08d282c into dotnet:main Mar 20, 2021
@GrabYourPitchforks GrabYourPitchforks deleted the encoder_arm64_b branch March 20, 2021 00:33
@adamsitnik
Copy link
Member

I'm not able to run BenchmarkDotNet on my SPX device for some reason

@GrabYourPitchforks what error are you getting?

@ghost ghost locked as resolved and limited conversation to collaborators Apr 21, 2021
@karelz karelz added this to the 6.0.0 milestone May 20, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants