-
Notifications
You must be signed in to change notification settings - Fork 10.1k
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 Websocket HandshakeHelpers.IsRequestKeyValid #13196
Conversation
/cc: @BrennanConroy And how did you run the benchmarks like in #12386 (comment)? |
I added some microbenchmarks as part of the PR https://github.com/aspnet/AspNetCore/pull/12386/files#diff-9053f4069af50f90080ba287c034c066 |
I have some tests in the PR https://github.com/aspnet/AspNetCore/pull/12386/files#diff-66cc560b423b43d03d69a6fbd14ea5f8 |
Ohh, shame on me. I've viewed the PR and can't see the changes 😉 Can I copy these (bench + tests) to this PR? Or is there a better way to avoid a duplication? |
I'm ok with you copying them :) |
… isrequestkeyvalid_vectorize Removed / reverted unrelated changes to this PR.
Baseline
PR12386
This PR (vectorized)
HW infoBenchmarkDotNet=v0.10.13, OS=ubuntu 16.04
Intel Core i7-7700HQ CPU 2.80GHz (Kaby Lake), 1 CPU, 4 logical cores and 4 physical cores
.NET Core SDK=3.0.100-preview9-013927
[Host] : .NET Core 3.0.0-preview9-19415-13 (CoreCLR 4.700.19.40902, CoreFX 4.700.19.40917), 64bit RyuJIT
Job-NGKFFV : .NET Core 3.0.0-preview9-19415-13 (CoreCLR 4.700.19.40902, CoreFX 4.700.19.40917), 64bit RyuJIT
Runtime=Core Server=True Toolchain=.NET Core 3.0
RunStrategy=Throughput
|
public class HandshakeTests | ||
{ | ||
[Fact] | ||
public void CreatesCorrectResponseKey() |
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 just merged the branch from #12386 into my branch. That's why this unrelated (to this PR) test is also here.
|
Lots of unsafe code being added as part of this PR. This appears to be something that occurs only once per WebSocket request and which already only takes fewer than 100 nanoseconds. aspnet team, do you believe the added complexity to be a worthwhile trade-off? If so, please consider using APIs like Additionally, if using the |
I'm with Levi on this one, I don't see the benefit of micro optimizing this code path, especially in such an unmaintainable way. |
@gfoidl Looks like we're not going to take this at this time, sorry. I do like seeing the amazing improvements vectorizing code can do! Thanks for trying it out. |
Me too 😃 -- unfortunately code gets non-intuitive quickly... |
Description
Based on #12386 (comment) here's a vectorized version of Websocket's
HandshakeHelpers.IsRequestKeyValid
.The code is commented to give the outline of the algorithm, which is based on dotnet/corefx#34529.
In short:
Benchmarks
Code
Valid key
Invalid key
Open questions
IsRequestKeyValid
-- as it is an internal member, is it tested through public apis or should I add tests for it?