From 41859b64a34a7b8575ca5767536d8d4fc6172c3c Mon Sep 17 00:00:00 2001 From: Roman Ettlinger Date: Mon, 19 Oct 2026 15:12:16 +0200 Subject: [PATCH] Client channel: pool the state machine of SendRequestAsync Every request allocated the async state machine box of UaSCUaBinaryClientChannel.SendRequestAsync (~170 B). On .NET 6 and later it uses PoolingAsyncValueTaskMethodBuilder, like the transport's send and receive; the callers await the returned task once. Co-Authored-By: Claude Opus 5.5 --- src/Opc.Ua.Core/Stack/Tcp/UaSCBinaryClientChannel.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Opc.Ua.Core/Stack/Tcp/UaSCBinaryClientChannel.cs b/src/Opc.Ua.Core/Stack/Tcp/UaSCBinaryClientChannel.cs index b39c58895d..0f989e2679 100644 --- a/src/Opc.Ua.Core/Stack/Tcp/UaSCBinaryClientChannel.cs +++ b/src/Opc.Ua.Core/Stack/Tcp/UaSCBinaryClientChannel.cs @@ -358,6 +358,14 @@ namespace Opc.Ua.Bindings /// is null. /// /// + /// + /// The state machine of a request is pooled, so the returned task must be awaited + /// once, like any value task. + /// +#if NET6_0_OR_GREATER + [System.Runtime.CompilerServices.AsyncMethodBuilder( + typeof(System.Runtime.CompilerServices.PoolingAsyncValueTaskMethodBuilder<>))] +#endif public async ValueTask SendRequestAsync( IServiceRequest request, int timeout,