[dotnet] [bidi] Parallel event handlers - #17213
Conversation
Review Summary by QodoImplement parallel event handler execution in BiDi EventDispatcher
WalkthroughsDescription• Execute event handlers in parallel without blocking each other • Track running handler tasks for proper cleanup during disposal • Extract handler invocation logic into separate method with error handling • Ensure all pending handlers complete before EventDispatcher disposal File Changes1. dotnet/src/webdriver/BiDi/EventDispatcher.cs
|
Code Review by Qodo
1. Logs raw exception ex
|
There was a problem hiding this comment.
Pull request overview
This PR changes the .NET BiDi EventDispatcher so event handlers are invoked without awaiting them, allowing multiple handlers (and multiple events) to be processed concurrently rather than serially blocking the event loop.
Changes:
- Dispatch BiDi event handlers in a fire-and-forget fashion instead of awaiting each handler inline.
- Track in-flight handler tasks and await their completion during
DisposeAsync. - Centralize handler exception logging in a dedicated
InvokeHandlerAsyncwrapper.
Now all event handlers are executed in parallel, non blocking each others.
Why:
I have 100 tests, each test is executed in isolated
userContextenvironment. Each test is executed in parallel sharing one single bidi connection. Each test wants to listen to network traffic (just an example). So, ideally any event handler should not block others, never.Experiment:
I have executed this kind of simulation. Performance is great!
💥 What does this PR do?
This pull request introduces improvements to the event handling mechanism in the
EventDispatcherclass, focusing on better management of asynchronous event handler tasks and ensuring proper cleanup during disposal.💡 Additional Considerations
It is still considerable to configure this behaviour.
🔄 Types of changes