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

use approved SocketAddress API instead of direct internal access #89841

Merged
merged 4 commits into from
Aug 4, 2023

Conversation

wfurt
Copy link
Member

@wfurt wfurt commented Aug 2, 2023

This is cleanup to avoid using SocketAddress internals directly.
Avoids allocation for local and remote address in typical case.

With all the external access to internal array gone, I'm wondering if it would be beneficial to have something like this @stephentoub to avoid creation of the memory on each access.

private Memory<byte> _buffer = new Memory<byte>(new byte[Size]);

contributes to #30797
follow-up on #88970

@wfurt wfurt requested a review from stephentoub August 2, 2023 05:52
@wfurt wfurt self-assigned this Aug 2, 2023
@ghost
Copy link

ghost commented Aug 2, 2023

Tagging subscribers to this area: @dotnet/ncl
See info in area-owners.md if you want to be subscribed.

Issue Details

This is cleanup to avoid using SocketAddress internals directly.
Avoids allocation for local and remote address in typical case.

With all the external access to internal array gone, I'm wondering if it would be beneficial to have something like this @stephentoub to avoid creation of the memory on each access.

private Memory<byte> _buffer = new Memory<byte>(new byte[Size]);

contributes to #30797
follow-up on #88970

Author: wfurt
Assignees: wfurt
Labels:

area-System.Net.Sockets

Milestone: -

@stephentoub
Copy link
Member

stephentoub commented Aug 2, 2023

I'm wondering if it would be beneficial to have something like this @stephentoub to avoid creation of the memory on each access.

I doubt it. That'd increase the size of the object, and the cost of constructing a Memory is minimal. Feel free to measure, though I expect it's entirely within the noise.

@wfurt wfurt changed the title PoC: use approved SocketAddress API instead of direct internal access use approved SocketAddress API instead of direct internal access Aug 3, 2023
@wfurt wfurt added this to the 8.0.0 milestone Aug 3, 2023
@wfurt
Copy link
Member Author

wfurt commented Aug 4, 2023

this is final stepping stone. Please take another look @stephentoub

<Compile Include="$(CommonPath)System\Net\Sockets\ProtocolType.cs"
Link="Common\System\Net\Sockets\ProtocolType.cs" />
<Compile Include="$(CommonPath)System\Net\Sockets\SocketType.cs"
Link="Common\System\Net\Sockets\SocketType.cs" />
Copy link
Member

Choose a reason for hiding this comment

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

We can do it later if you'd prefer, but these files should also move out of common into the appropriate library folder

Copy link
Member Author

Choose a reason for hiding this comment

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

yes, I was thinking about SocketAddress.cs as well once the changes are over. Probably separate PR with just moves/renames.

@wfurt wfurt merged commit 072fd17 into dotnet:main Aug 4, 2023
103 checks passed
@wfurt wfurt deleted the sockAddr3 branch August 4, 2023 17:38
@ghost ghost locked as resolved and limited conversation to collaborators Sep 3, 2023
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.

2 participants