-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
[dotnet] [bidi] Rent buffer for receiving bytes in WebSocket #16650
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
PR Compliance Guide 🔍Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label |
||||||||||||||||||||||||
PR Code Suggestions ✨Explore these optional code suggestions:
|
|||||||||||
User description
Most likely the memory is already allocated.
💥 What does this PR do?
Instead of allocating new memory, try to use already allocated 8KB.
🔧 Implementation Notes
And return it back when disposing.
PR Type
Enhancement
Description
Use ArrayPool to rent reusable buffer instead of allocating new memory
Reduces memory allocations by reusing pre-allocated 8KB buffer
Returns buffer to pool when WebSocketTransport is disposed
Improves performance through reduced garbage collection pressure
Diagram Walkthrough
File Walkthrough
WebSocketTransport.cs
Implement ArrayPool buffer renting for WebSocket operationsdotnet/src/webdriver/BiDi/WebSocketTransport.cs
System.Buffersnamespace import for ArrayPool support_receiveBufferfromArraySegmentwith new allocation to rentedbyte[]from ArrayPoolArraySegmentwrapper inReceiveAsyncmethod forWebSocket API compatibility
Dispose()method to release rentedmemory