[dotnet] [bidi] Eliminate BiDi context on hot path - #18069
Merged
Merged
Conversation
Contributor
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
Contributor
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
All reviewed changes are coherent, with no unresolved issues.
Review effort: Balanced
Findings: None
What changed in this PR
Refactors .NET BiDi context handling to reduce hot-path allocations while preserving message-processing context.
Changes:
- Stores
IBiDidirectly inAsyncLocal. - Consolidates broker context scoping.
- Updates identifiable-object deserialization.
| File | Description |
|---|---|
dotnet/src/webdriver/BiDi/Json/Converters/IdentifiableConverter.cs |
Uses the current IBiDi directly. |
dotnet/src/webdriver/BiDi/Broker.cs |
Applies context once around message processing. |
dotnet/src/webdriver/BiDi/BiDiContext.cs |
Simplifies context storage and restoration. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This was referenced Oct 1, 2026
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.
Improve performance and memoty allocation.
💥 What does this PR do?
This pull request refactors the
BiDiContextclass and streamlines its usage across the BiDi WebDriver implementation. The main goal is to simplify context management by makingBiDiContexta static class that directly holds theIBiDiinstance, eliminating unnecessary object wrapping. Additionally, the pull request cleans up redundant context scoping in several methods and ensures correct usage of the new context pattern.Refactoring and simplification of BiDi context management:
BiDiContextfrom a sealed class to a static class, storing theIBiDiinstance directly in theAsyncLocal, and removed the unnecessaryBiDiContextwrapper object. (dotnet/src/webdriver/BiDi/BiDiContext.cs)IdentifiableConverterto use the new staticBiDiContext.Currentdirectly, instead of accessing.BiDifrom a context object. (dotnet/src/webdriver/BiDi/Json/Converters/IdentifiableConverter.cs)Cleanup and correct scoping in BiDi broker:
BiDiContext.UseinExecuteAsyncandProcessReceivedMessage, as the context is now managed at a higher level. (dotnet/src/webdriver/BiDi/Broker.cs) [1] [2] [3]BiDiContext.Useis invoked once at the start ofProcessMessagesAsync, so all message processing occurs within the correct context scope. (dotnet/src/webdriver/BiDi/Broker.cs)🔧 Implementation Notes
🤖 AI assistance
🔄 Types of changes