Reduce TCP channel async wait allocations#3794
Draft
Copilot wants to merge 5 commits into
Draft
Conversation
Agent-Logs-Url: https://github.com/OPCFoundation/UA-.NETStandard/sessions/24828edb-ccf0-41cb-b93d-218f7111aff6 Co-authored-by: romanett <7413710+romanett@users.noreply.github.com>
Agent-Logs-Url: https://github.com/OPCFoundation/UA-.NETStandard/sessions/24828edb-ccf0-41cb-b93d-218f7111aff6 Co-authored-by: romanett <7413710+romanett@users.noreply.github.com>
Agent-Logs-Url: https://github.com/OPCFoundation/UA-.NETStandard/sessions/24828edb-ccf0-41cb-b93d-218f7111aff6 Co-authored-by: romanett <7413710+romanett@users.noreply.github.com>
Agent-Logs-Url: https://github.com/OPCFoundation/UA-.NETStandard/sessions/24828edb-ccf0-41cb-b93d-218f7111aff6 Co-authored-by: romanett <7413710+romanett@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
romanett
May 21, 2026 12:00
View session
|
|
- IMessageSocket: remove bool Send(IMessageSocketAsyncEventArgs), ReadNextMessage(), and MessageSocketEventArgs(); add ValueTask SendAsync overloads and Task ReadNextMessageAsync(CancellationToken) - TcpMessageSocket: replace SocketAsyncEventArgs state-machine with a clean async receive loop (ReadNextMessageAsync/ReceiveExactAsync/ ReceiveAsync) and ValueTask send path (SendAsync/SendAllAsync/ SendOnceAsync). Modern path uses Socket.ReceiveAsync(Memory<byte>) and Socket.SendAsync(ReadOnlyMemory<byte>); .NET Framework path wraps SocketAsyncEventArgs in TaskCompletionSource. - UaSCBinaryChannel: replace BeginWriteMessage + OnWriteComplete with BeginWriteMessage that fires-and-forgets a ValueTask send and handles completion via CompleteWriteAsync continuation helper - TcpListenerChannel, TcpServerChannel, UaSCBinaryClientChannel: update ReadNextMessage() call sites to ReadNextMessageAsync() (fire-and-forget)" Agent-Logs-Url: https://github.com/OPCFoundation/UA-.NETStandard/sessions/2b878f3d-1010-4e94-8f65-400556548045 Co-authored-by: romanett <7413710+romanett@users.noreply.github.com>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #3794 +/- ##
==========================================
- Coverage 72.00% 71.95% -0.05%
==========================================
Files 677 677
Lines 130752 130745 -7
Branches 22261 22254 -7
==========================================
- Hits 94143 94079 -64
- Misses 29946 29994 +48
- Partials 6663 6672 +9 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
IMessageSocket: removebool Send(IMessageSocketAsyncEventArgs),MessageSocketEventArgs(),void ReadNextMessage(); addValueTask SendAsync(ReadOnlyMemory<byte>, CancellationToken),ValueTask SendAsync(IList<ArraySegment<byte>>, CancellationToken),Task ReadNextMessageAsync(CancellationToken)TcpMessageSocket: replaceSocketAsyncEventArgs-based state machine withSocket.ReceiveAsync(Memory<byte>)async read loop andSocket.SendAsync(ReadOnlyMemory<byte>)writes (with .NET Framework fallback viaTaskCompletionSource+SocketAsyncEventArgs)UaSCBinaryChannel.BeginWriteMessage: removeOnWriteComplete, replace with fire-and-forgetSendAsync+CompleteWriteAsynccontinuation helperReadNextMessage()call sites inTcpListenerChannel,TcpServerChannel,UaSCBinaryClientChannel→Socket.ReadNextMessageAsync()