Skip to content

Improve performance of WebSocketMessageHandler - #1237

Merged
Andrew Arnott (AArnott) merged 1 commit into
mainfrom
fix1234
Aug 5, 2025
Merged

Improve performance of WebSocketMessageHandler#1237
Andrew Arnott (AArnott) merged 1 commit into
mainfrom
fix1234

Conversation

@AArnott

Copy link
Copy Markdown
Member

Fixes#1234

CopilotAI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR improves the performance of the WebSocketMessageHandler by optimizing memory allocation in the WriteCoreAsync method. It modifies the Sequence<byte> constructor to use a shared array pool and sets a minimum span length hint.

  • Uses ArrayPool<byte>.Shared instead of default memory allocation for the sequence builder
  • Sets MinimumSpanLength property to this.sizeHint to optimize buffer sizing

Comment threadsrc/StreamJsonRpc/WebSocketMessageHandler.cs
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Websocket message handler writes should consider setting MinimumSpanLength.

3 participants

@AArnott@ekoppel