-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Simplify ManagedWebSocket.ApplyMask using TensorPrimitives.Xor #123669
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
base: main
Are you sure you want to change the base?
Conversation
|
Tagging subscribers to this area: @karelz, @dotnet/ncl |
…orization Co-authored-by: MihaZupan <25307628+MihaZupan@users.noreply.github.com>
Co-authored-by: MihaZupan <25307628+MihaZupan@users.noreply.github.com>
| <ProjectReference Include="$(LibrariesProjectRoot)System.Memory\src\System.Memory.csproj" /> | ||
| <ProjectReference Include="$(LibrariesProjectRoot)System.Net.Primitives\src\System.Net.Primitives.csproj" /> | ||
| <ProjectReference Include="$(LibrariesProjectRoot)System.Numerics.Vectors\src\System.Numerics.Vectors.csproj" /> | ||
| <ProjectReference Include="$(LibrariesProjectRoot)System.Numerics.Tensors\src\System.Numerics.Tensors.csproj" /> |
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.
System.Net.WebSockets is in the shared framework. This reference would require including System.Numerics.Tensors in shared framework as well. Is the extra baseline code bloat really worth it?
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.
From just the WebSockets perspective I don't think we'd care, we can live with the current setup. I was curious what copilot would do in this case.
But if there are more places where we're duplicating such logic it might be worth considering? Linq's Min/Average/Sum implementations come to mind where we have some SIMD sprinkled around (I haven't looked if they could actually be replaced).
cc: @tannergooding @stephentoub In case you've already put any thought into whether it could make sense to use Tensor helpers in other libraries.
Description
Replaces unsafe code and manual SIMD vectorization in
ManagedWebSocket.ApplyMaskwithTensorPrimitives.Xor.Changes
System.Numerics.Tensorsproject reference toSystem.Net.WebSockets.csprojunsafekeyword and all pointer operations fromApplyMaskVector<byte>loop withTensorPrimitives.Xor<int>(toMaskInts, rolledMask, toMaskInts)foreach refinstead of pointer arithmeticBefore
After
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.