Skip to content

[Internal] Thin Client Integration: Fixes the ThinClientTransportSerializer to avoid creating memory stream.#5137

Merged
kirankumarkolli merged 5 commits intomasterfrom
users/aavasthy/fixmemorystream
Apr 25, 2025
Merged

[Internal] Thin Client Integration: Fixes the ThinClientTransportSerializer to avoid creating memory stream.#5137
kirankumarkolli merged 5 commits intomasterfrom
users/aavasthy/fixmemorystream

Conversation

@aavasthy
Copy link
Copy Markdown
Contributor

@aavasthy aavasthy commented Apr 16, 2025

Pull Request Template

Description

Optimize the serialization logic by avoiding the creation of a new large MemoryStream every time by switching to a pooled byte array using ArrayPool.Shared. Instead of allocating a fresh buffer inside the stream, now renting a reusable one, copying data into it, and wrapping it with MemoryStream. This reduces memory usage.

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)

Closing issues

To automatically close an issue: closes #5070

@aavasthy aavasthy changed the title [Internal] Thin Client Integration: Fixes the ThinClientTransportSerializer to avoid creating memory stream.Using pool array byte. [Internal] Thin Client Integration: Fixes the ThinClientTransportSerializer to avoid creating memory stream. Apr 16, 2025
Comment thread Microsoft.Azure.Cosmos/src/ThinClientTransportSerializer.cs
Copy link
Copy Markdown
Member

@kundadebdatta kundadebdatta left a comment

Choose a reason for hiding this comment

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

Approved with minor suggestions.

@aavasthy aavasthy added the auto-merge Enables automation to merge PRs label Apr 23, 2025
@aavasthy aavasthy self-assigned this Apr 25, 2025
@kirankumarkolli kirankumarkolli merged commit e4ec354 into master Apr 25, 2025
26 checks passed
@kirankumarkolli kirankumarkolli deleted the users/aavasthy/fixmemorystream branch April 25, 2025 17:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auto-merge Enables automation to merge PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Thin Client Integration] Optimize the ThinClientTransportSerializer to Avoid Creating Memory Stream

3 participants