Skip to content
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

Vectorized HttpCharacters (and used IndexOfAnyValues in other places found) #45300

Merged
merged 7 commits into from
Dec 8, 2022

Conversation

gfoidl
Copy link
Member

@gfoidl gfoidl commented Nov 27, 2022

The title sounds like a complicated change, but thanks to dotnet/runtime#68328 it got trivial and is a way better alternative to doing it manually as in #44041.

Unfortunately the .NET daily builds are way behind at the moment, so these new APIs aren't available to run benchmarks in an easy way.

Edit: searched for other places where applicable as well. Some of the found were analyzers (NS2.0) or built for older targets where this API isn't available.

@ghost ghost added the community-contribution Indicates that the PR has been added by a community member label Nov 27, 2022
@ghost
Copy link

ghost commented Nov 27, 2022

Thanks for your PR, @gfoidl. Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

@gfoidl
Copy link
Member Author

gfoidl commented Nov 27, 2022

/cc: @MihaZupan -- it gets really nice that way 😄.

Copy link
Member

@MihaZupan MihaZupan left a comment

Choose a reason for hiding this comment

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

Beautiful

src/Shared/ServerInfrastructure/HttpCharacters.cs Outdated Show resolved Hide resolved
src/Shared/ServerInfrastructure/HttpCharacters.cs Outdated Show resolved Hide resolved
@MihaZupan
Copy link
Member

Unfortunately the .NET daily builds are way behind at the moment, so these new APIs aren't available to run benchmarks in an easy way.

Grabbing some numbers from dotnet/runtime#78863 as an example:

Chars

Method Length Mean Error StdDev
IndexOfAnyAsciiChar 100000 3.936 us 0.0525 us 0.0491 us
IndexOf 100000 4.925 us 0.0186 us 0.0174 us
IndexOfAny2Values 100000 5.754 us 0.0196 us 0.0174 us

Bytes

Method Length Mean Error StdDev
IndexOfAnyAsciiByte 100000 3.189 us 0.0171 us 0.0151 us
IndexOf 100000 1.971 us 0.0186 us 0.0174 us
IndexOfAny2Values 100000 2.233 us 0.0093 us 0.0078 us

@MihaZupan MihaZupan added the Perf label Nov 27, 2022
@gfoidl gfoidl requested review from javiercn and a team as code owners November 27, 2022 15:49
@gfoidl gfoidl changed the title Vectorized HttpCharacters Vectorized HttpCharacters (and used IndexOfAnyValues in other places found) Nov 27, 2022
@adityamandaleeka adityamandaleeka added the blog-candidate Consider mentioning this in the release blog post label Nov 27, 2022
@ghost
Copy link

ghost commented Nov 27, 2022

@gfoidl, this change will be considered for inclusion in the blog post for the release it'll ship in. Nice work!

Please ensure that the original comment in this thread contains a clear explanation of what the change does, why it's important (what problem does it solve?), and, if relevant, include things like code samples and/or performance numbers.

This content may not be exactly what goes into the blog post, but it will help the team putting together the announcement.

Thanks!

@adityamandaleeka
Copy link
Member

Nice! Another example of goodness coming together across multiple layers of the stack.

@MihaZupan
Copy link
Member

MihaZupan commented Nov 27, 2022

cc: @stephentoub @danmoseley for this before and after

@gfoidl
Copy link
Member Author

gfoidl commented Nov 27, 2022

... and how it would look if vectorized w/o runtime (not showing the generator part).

@stephentoub
Copy link
Member

thanks to dotnet/runtime#68328 it got trivial and is a way better alternative to doing it manually as in #44041.

Very glad to see it's panning out as planned. Thanks.

@JamesNK JamesNK added the blocked The work on this issue is blocked due to some dependency label Dec 6, 2022
@JamesNK
Copy link
Member

JamesNK commented Dec 6, 2022

I believe verifying perf improvement is blocking this, which is itself blocked by build issues. I added blocked label.

Copy link
Member

@amcasey amcasey left a comment

Choose a reason for hiding this comment

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

Very nice!

@gfoidl gfoidl requested a review from mgravell as a code owner December 6, 2022 21:30
@adityamandaleeka
Copy link
Member

/benchmark plaintext,json kestrel

@pr-benchmarks
Copy link

pr-benchmarks bot commented Dec 8, 2022

Crank Pull Request Bot

/benchmark <benchmark[,...]> <profile[,...]> <component,[...]> <arguments>

Benchmarks:

  • plaintext: TechEmpower Plaintext Scenario - ASP.NET Platform implementation
  • json: TechEmpower JSON Scenario - ASP.NET Platform implementation
  • fortunes: TechEmpower Fortunes Scenario - ASP.NET Platform implementation
  • yarp: YARP - http-http with 10 bytes
  • mvcjsoninput2k: Sends 2Kb Json Body to an MVC controller

Profiles:

  • aspnet-perf-lin: INTEL/Linux 12 Cores
  • aspnet-perf-win: INTEL/Windows 12 Cores
  • aspnet-citrine-lin: INTEL/Linux 28 Cores
  • aspnet-citrine-win: INTEL/Windows 28 Cores
  • aspnet-citrine-arm: ARM/Linux 32 Cores
  • aspnet-citrine-amd: AMD/Linux 48 Cores

Components:

  • kestrel
  • mvc

Arguments: any additional arguments to pass through to crank, e.g. --variable name=value

@sebastienros
Copy link
Member

/benchmark plaintext,json aspnet-citrine-lin kestrel

@pr-benchmarks
Copy link

pr-benchmarks bot commented Dec 8, 2022

Benchmark started for plaintext, json on aspnet-citrine-lin with kestrel. Logs: link

@pr-benchmarks
Copy link

pr-benchmarks bot commented Dec 8, 2022

plaintext - aspnet-citrine-lin

application plaintext.base plaintext.pr
CPU Usage (%) 99 99 0.00%
Cores usage (%) 2,784 2,773 -0.40%
Working Set (MB) 118 118 0.00%
Private Memory (MB) 642 643 +0.16%
Build Time (ms) 3,152 3,282 +4.12%
Start Time (ms) 217 235 +8.29%
Published Size (KB) 96,234 96,234 0.00%
.NET Core SDK Version 8.0.100-alpha.1.22607.4 8.0.100-alpha.1.22607.4
load plaintext.base plaintext.pr
CPU Usage (%) 91 92 +1.10%
Cores usage (%) 2,559 2,564 +0.20%
Working Set (MB) 119 119 0.00%
Private Memory (MB) 370 370 0.00%
Start Time (ms) 0 0
First Request (ms) 95 96 +1.05%
Requests/sec 10,972,281 10,830,568 -1.29%
Requests 165,670,123 163,541,936 -1.28%
Mean latency (ms) 1.23 1.17 -4.88%
Max latency (ms) 75.49 64.51 -14.54%
Bad responses 0 0
Socket errors 0 0
Read throughput (MB/s) 1,320.96 1,300.48 -1.55%
Latency 50th (ms) 0.76 0.77 +1.45%
Latency 75th (ms) 1.14 1.15 +0.88%
Latency 90th (ms) 1.76 1.75 -0.57%
Latency 99th (ms) 13.76 12.43 -9.67%

json - aspnet-citrine-lin

application json.base json.pr
CPU Usage (%) 99 99 0.00%
Cores usage (%) 2,777 2,782 +0.18%
Working Set (MB) 85 88 +3.53%
Private Memory (MB) 610 612 +0.33%
Build Time (ms) 3,146 3,167 +0.67%
Start Time (ms) 217 228 +5.07%
Published Size (KB) 96,234 96,234 0.00%
.NET Core SDK Version 8.0.100-alpha.1.22607.4 8.0.100-alpha.1.22607.4
load json.base json.pr
CPU Usage (%) 79 80 +1.27%
Cores usage (%) 2,221 2,231 +0.45%
Working Set (MB) 119 119 0.00%
Private Memory (MB) 363 363 0.00%
Start Time (ms) 0 0
First Request (ms) 99 99 0.00%
Requests/sec 1,207,837 1,213,658 +0.48%
Requests 18,238,050 18,325,094 +0.48%
Mean latency (ms) 0.78 0.74 -4.80%
Max latency (ms) 44.28 39.21 -11.45%
Bad responses 0 0
Socket errors 0 0
Read throughput (MB/s) 168.17 168.99 +0.49%
Latency 50th (ms) 0.38 0.38 -0.27%
Latency 75th (ms) 0.45 0.44 -0.67%
Latency 90th (ms) 0.60 0.58 -3.67%
Latency 99th (ms) 10.96 10.40 -5.11%

@adityamandaleeka
Copy link
Member

Numbers look good. The RPS deltas appear within the usual margin of noise for these benchmarks.

@adityamandaleeka adityamandaleeka merged commit 19e4674 into dotnet:main Dec 8, 2022
@ghost ghost added this to the 8.0-preview1 milestone Dec 8, 2022
@adityamandaleeka
Copy link
Member

Thanks @gfoidl!

@gfoidl gfoidl deleted the httpcharacters branch December 8, 2022 10:05
@amcasey amcasey added area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions and removed area-runtime labels Jun 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions blocked The work on this issue is blocked due to some dependency blog-candidate Consider mentioning this in the release blog post community-contribution Indicates that the PR has been added by a community member Perf
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants