[dotnet] [bidi] Decouple transport and processing#17291
[dotnet] [bidi] Decouple transport and processing#17291nvborisenko merged 15 commits intoSeleniumHQ:trunkfrom
Conversation
Review Summary by QodoDecouple BiDi transport and message processing with channel pattern
WalkthroughsDescription• Decouple message receiving and processing into separate async tasks • Implement channel-based producer/consumer pattern for message handling • Add buffer pooling to reduce memory allocations and improve performance • Improve resource management with proper cleanup of pooled buffers File Changes1. dotnet/src/webdriver/BiDi/Broker.cs
|
Code Review by Qodo
1.
|
There was a problem hiding this comment.
Pull request overview
Refactors the .NET BiDi Broker message flow to decouple transport receiving from message processing, aiming to improve throughput and reduce allocations via buffering and pooling.
Changes:
- Introduced a bounded
Channel<PooledBufferWriter>to queue received messages and process them on a dedicated task. - Added a
ConcurrentBag<PooledBufferWriter>pool with rent/return helpers to reuse buffers. - Updated disposal to await both receiving and processing tasks and to dispose pooled buffers.
|
I am here, let's continue. |
Always receiving from remote end, processing from queue.
💥 What does this PR do?
This pull request significantly refactors the
Brokerclass in the WebDriver BiDi implementation to improve message handling, resource management, and error propagation. The changes introduce asynchronous message processing using channels, enhance buffer pooling, and ensure more robust disposal and error handling throughout the broker lifecycle. Additionally, related test code is updated for proper asynchronous disposal and a new test is added to verify idempotent disposal.Message Handling and Processing Improvements:
ReceiveMessagesAsync) and another for processing messages (ProcessMessagesAsync), communicating via a bounded channel to apply backpressure and improve throughput. This also introduces a buffer pool to reduce allocations and ensure proper buffer reuse. [1] [2] [3] [4]Resource and Buffer Management:
PooledBufferWriterinstances, and ensured all buffers are disposed of during broker disposal. [1] [2] [3]AdvanceandEnsureCapacitymethods ofPooledBufferWriterto guard against invalid buffer operations and ensure correct buffer sizing. [1] [2]Disposal and Test Enhancements:
DisposeAsyncare safe (idempotent). [1] [2]🔄 Types of changes